diff options
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ILoop.scala | 9 | ||||
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/Power.scala | 41 | ||||
-rw-r--r-- | test/files/jvm/throws-annot-from-java.check | 8 | ||||
-rw-r--r-- | test/files/run/class-symbol-contravariant.check | 8 | ||||
-rw-r--r-- | test/files/run/constant-type.check | 8 | ||||
-rw-r--r-- | test/files/run/repl-power.check | 8 | ||||
-rw-r--r-- | test/files/run/t6146b.check | 8 | ||||
-rw-r--r-- | test/files/run/t6439.check | 8 | ||||
-rw-r--r-- | test/files/run/t7747-repl.check | 8 | ||||
-rw-r--r-- | test/files/run/tpeCache-tyconCache.check | 8 |
10 files changed, 50 insertions, 64 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 _) } diff --git a/test/files/jvm/throws-annot-from-java.check b/test/files/jvm/throws-annot-from-java.check index ace264a4f5..bf639260e7 100644 --- a/test/files/jvm/throws-annot-from-java.check +++ b/test/files/jvm/throws-annot-from-java.check @@ -1,10 +1,8 @@ scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> :paste // Entering paste mode (ctrl-D to finish) diff --git a/test/files/run/class-symbol-contravariant.check b/test/files/run/class-symbol-contravariant.check index 1d95273b50..5166fce96a 100644 --- a/test/files/run/class-symbol-contravariant.check +++ b/test/files/run/class-symbol-contravariant.check @@ -1,10 +1,8 @@ scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> val u = rootMirror.universe u: $r.intp.global.type = <global> diff --git a/test/files/run/constant-type.check b/test/files/run/constant-type.check index b92f1481a3..9df1353354 100644 --- a/test/files/run/constant-type.check +++ b/test/files/run/constant-type.check @@ -1,10 +1,8 @@ scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> val s = transformedType(StringClass.toType).asInstanceOf[Type] s: $r.intp.global.Type = String diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 4e030bd9fa..0d4a30b8e3 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -1,10 +1,8 @@ scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> // guarding against "error: reference to global is ambiguous" diff --git a/test/files/run/t6146b.check b/test/files/run/t6146b.check index 0e0c216cd7..11149c50fd 100644 --- a/test/files/run/t6146b.check +++ b/test/files/run/t6146b.check @@ -4,11 +4,9 @@ It would fail on the following inputs: S2(), S3() ^ scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> val u = rootMirror.universe; import u._, language._ u: $r.intp.global.type = <global> diff --git a/test/files/run/t6439.check b/test/files/run/t6439.check index eee2da1b12..dd7ba9f81d 100644 --- a/test/files/run/t6439.check +++ b/test/files/run/t6439.check @@ -48,11 +48,9 @@ scala> type F = Int // no warn defined type alias F scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> object lookup { import intp._ diff --git a/test/files/run/t7747-repl.check b/test/files/run/t7747-repl.check index 487daf4878..d698ea668d 100644 --- a/test/files/run/t7747-repl.check +++ b/test/files/run/t7747-repl.check @@ -295,11 +295,9 @@ scala> b(a) res4: String = Found Sum scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> intp.lastRequest res5: $r.intp.Request = Request(line=def $ires3 = intp.global, 1 trees) diff --git a/test/files/run/tpeCache-tyconCache.check b/test/files/run/tpeCache-tyconCache.check index ac13d32f91..b26f1ab8a1 100644 --- a/test/files/run/tpeCache-tyconCache.check +++ b/test/files/run/tpeCache-tyconCache.check @@ -1,10 +1,8 @@ scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** +Power mode enabled. :phase is at typer. +import scala.tools.nsc._, intp.global._, definitions._ +Try :help or completions for vals._ and power._ scala> |