From ecbb73ccf21302bf2a5df1c8d97811581d4f8637 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sun, 5 Mar 2017 20:42:17 +0900 Subject: Remove uses of StringOps from scala-reflect --- compiler/src/dotty/tools/dotc/core/Decorators.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'compiler/src/dotty/tools/dotc/core/Decorators.scala') 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. */ -- cgit v1.2.3