Skip to content

Commit 2572a2c

Browse files
committed
Add StringOps from scala-reflect
1 parent 6585953 commit 2572a2c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Names._, StdNames._, ast.Trees._, ast.{tpd, untpd}
1010
import Symbols._, Contexts._
1111
import util.Positions._
1212
import Parsers.Parser
13-
import scala.reflect.internal.util.StringOps.splitWhere
13+
import util.StringOps.splitWhere
1414
import scala.language.implicitConversions
1515

1616
/** This class builds instance of `Tree` that represent XML.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* NSC -- new Scala compiler
2+
* Copyright 2002-2013 LAMP/EPFL
3+
* @author Martin Odersky
4+
*/
5+
6+
package dotty.tools
7+
package dotc
8+
package util
9+
10+
/** This object provides utility methods to extract elements
11+
* from Strings.
12+
*
13+
* This was adapted from https://github.com/scala/scala/blob/2.11.x/src/reflect/scala/reflect/internal/util/StringOps.scala
14+
*/
15+
object StringOps {
16+
def splitWhere(str: String, f: Char => Boolean, doDropIndex: Boolean = false): Option[(String, String)] =
17+
splitAt(str, str indexWhere f, doDropIndex)
18+
19+
def splitAt(str: String, idx: Int, doDropIndex: Boolean = false): Option[(String, String)] =
20+
if (idx == -1) None
21+
else Some((str take idx, str drop (if (doDropIndex) idx + 1 else idx)))
22+
}

compiler/src/dotty/tools/io/ClassPath.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
package dotty.tools
77
package io
88

9+
import dotc.util.StringOps.splitWhere
910
import java.net.URL
1011
import scala.collection.{ mutable, immutable }
11-
import scala.reflect.internal.util.StringOps.splitWhere
1212
import File.pathSeparator
1313
import java.net.MalformedURLException
1414
import Jar.isJarOrZip

0 commit comments

Comments
 (0)