aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Decorators.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-03-05 20:42:17 +0900
committerGuillaume Martres <smarter@ubuntu.com>2017-03-08 13:30:25 +0100
commitecbb73ccf21302bf2a5df1c8d97811581d4f8637 (patch)
treef1ddd8322f24a144ae9960924ad01febf353692b /compiler/src/dotty/tools/dotc/core/Decorators.scala
parentb5bdfab87b9be2cfbbc67370d1b6fbb5eb374098 (diff)
downloaddotty-ecbb73ccf21302bf2a5df1c8d97811581d4f8637.tar.gz
dotty-ecbb73ccf21302bf2a5df1c8d97811581d4f8637.tar.bz2
dotty-ecbb73ccf21302bf2a5df1c8d97811581d4f8637.zip
Remove uses of StringOps from scala-reflect
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Decorators.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Decorators.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala
index a105741f5..f8267072e 100644
--- a/compiler/src/dotty/tools/dotc/core/Decorators.scala
+++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala
@@ -15,12 +15,22 @@ import printing.Formatting._
object Decorators {
/** Turns Strings into PreNames, adding toType/TermName methods */
- implicit class StringDecorator(val s: String) extends AnyVal with PreName {
+ implicit class PreNamedString(val s: String) extends AnyVal with PreName {
def toTypeName: TypeName = typeName(s)
def toTermName: TermName = termName(s)
def toText(printer: Printer): Text = Str(s)
}
+ implicit class StringDecorator(val s: String) extends AnyVal {
+ def splitWhere(f: Char => Boolean, doDropIndex: Boolean): Option[(String, String)] = {
+ def splitAt(idx: Int, doDropIndex: Boolean): Option[(String, String)] =
+ if (idx == -1) None
+ else Some((s.take(idx), s.drop(if (doDropIndex) idx + 1 else idx)))
+
+ splitAt(s.indexWhere(f), doDropIndex)
+ }
+ }
+
/** Implements a findSymbol method on iterators of Symbols that
* works like find but avoids Option, replacing None with NoSymbol.
*/