diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ILoop.scala | 9 | ||||
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/Power.scala | 41 |
2 files changed, 26 insertions, 24 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index 6470a450b2..92655ba643 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -658,12 +658,9 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) unleashAndSetPhase() asyncEcho(isDuringInit, power.banner) } - private def unleashAndSetPhase() { - if (isReplPower) { - power.unleash() - // Set the phase to "typer" - intp beSilentDuring phaseCommand("typer") - } + private def unleashAndSetPhase() = if (isReplPower) { + power.unleash() + intp beSilentDuring phaseCommand("typer") // Set the phase to "typer" } def asyncEcho(async: Boolean, msg: => String) { diff --git a/src/repl/scala/tools/nsc/interpreter/Power.scala b/src/repl/scala/tools/nsc/interpreter/Power.scala index 8d8140b638..a14a60d216 100644 --- a/src/repl/scala/tools/nsc/interpreter/Power.scala +++ b/src/repl/scala/tools/nsc/interpreter/Power.scala @@ -113,10 +113,13 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re } } - private def customBanner = replProps.powerBanner.option flatMap (f => io.File(f).safeSlurp()) + private def customBanner = replProps.powerBanner.option flatMap { + case f if f.getName == "classic" => Some(classic) + case f => io.File(f).safeSlurp() + } private def customInit = replProps.powerInitCode.option flatMap (f => io.File(f).safeSlurp()) - def banner = customBanner getOrElse """ + def classic = """ |** Power User mode enabled - BEEP WHIR GYVE ** |** :phase has been set to 'typer'. ** |** scala.tools.nsc._ has been imported ** @@ -124,28 +127,30 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re |** Try :help, :vals, power.<tab> ** """.stripMargin.trim - private def initImports = List( - "scala.tools.nsc._", - "scala.collection.JavaConverters._", - "intp.global.{ error => _, _ }", - "definitions.{ getClass => _, _ }", - "power.rutil._", - "replImplicits._", - "treedsl.CODE._" - ) - - def init = customInit match { - case Some(x) => x - case _ => initImports.mkString("import ", ", ", "") - } + def banner = customBanner getOrElse """ + |Power mode enabled. :phase is at typer. + |import scala.tools.nsc._, intp.global._, definitions._ + |Try :help or completions for vals._ and power._ + """.stripMargin.trim + + private def initImports = + """scala.tools.nsc._ + |scala.collection.JavaConverters._ + |intp.global.{ error => _, _ } + |definitions.{ getClass => _, _ } + |power.rutil._ + |replImplicits._ + |treedsl.CODE._""".stripMargin.lines + + def init = customInit getOrElse initImports.mkString("import ", ", ", "") - /** Starts up power mode and runs whatever is in init. + /** Quietly starts up power mode and runs whatever is in init. */ def unleash(): Unit = beQuietDuring { // First we create the ReplVals instance and bind it to $r intp.bind("$r", replVals) // Then we import everything from $r. - intp interpret ("import " + intp.originalPath("$r") + "._") + intp interpret s"import ${ intp.originalPath("$r") }._" // And whatever else there is to do. init.lines foreach (intp interpret _) } |