scala.tools.nsc.scratchpad.SourceInserter.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-compiler Show documentation
Show all versions of scala-compiler Show documentation
Compiler for the Scala Programming Language
package scala.tools.nsc
package scratchpad
import java.io.Writer
import scala.reflect.internal.util.SourceFile
import scala.reflect.internal.Chars._
@deprecated("SI-6458: Instrumentation logic will be moved out of the compiler.","2.10.0")
object SourceInserter {
def stripRight(cs: Array[Char]): Array[Char] = {
val lines =
new String(cs) split "\n"
def leftPart(str: String) =
(str split """//>|//\|""").head
def isContinuation(str: String) =
((str contains "//>") || (str contains "//|")) && (leftPart(str) forall isWhitespace)
def stripTrailingWS(str: String) =
str take (str lastIndexWhere (!isWhitespace(_))) + 1
val prefixes =
lines filterNot isContinuation map leftPart map stripTrailingWS
(prefixes mkString "\n").toArray
}
}