summaryrefslogtreecommitdiff
path: root/src/repl/scala/tools/nsc/interpreter/ILoop.scala
Commit message (Collapse)AuthorAgeFilesLines
* Create shaded JLine in sbt buildStefan Zeiger2015-10-291-1/+1
| | | | | | | | | | | | | | | | | | Reusing parts of #4593, this commits adds two additional subprojects to the sbt build: - repl-jline, which is already used by the ant build, builds the part of the REPL that depends on JLine. The actual JLine depenency is moved to this project. - repl-jline-shaded uses JarJar to create a shaded version of repl-jline and jline.jar. Unlike the ant build, this setup does not use any circular dependencies. dist/mkBin puts all of quick/repl, quick/repl-jline and quick/repl-jline-shaded onto the classpath of build-sbt/quick/bin/scala. A future addition to the sbt build for building build-sbt/pack will have to put the generated classfiles into the correct JARs, mirroring the old structure.
* SI-9492 Line trimming pasteSom Snytt2015-09-271-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use `-` stripmargin character to indicate trim (i.e. remove leading indentation). `<<` looks more like shift left, but is already the standard here doc sequence. Indentation is often mangled by pasting, so trimming normalizes lines for error messages. The entire paste text was already trimmed as a whole. `-Dscala.repl.here` provides a default end string, which is unset unless specified. ``` scala> :pa <- // Entering paste mode (ctrl-D to finish) def g = 10 def f! = 27 -- // Exiting paste mode, now interpreting. <console>:2: error: '=' expected but identifier found. def f! = 27 ^ ```
* SI-9492 REPL paste here docSom Snytt2015-09-271-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple here documentish syntax for REPL paste. This makes it easier to paste a block of script (as opposed to transcript). It also means you won't accidentally ctl-D out of the REPL and then out of SBT and then out of the terminal window. ``` scala> :paste < EOF // Entering paste mode (EOF to finish) class C { def c = 42 } EOF // Exiting paste mode, now interpreting. defined class C scala> new C().c res0: Int = 42 scala> :paste <| EOF // Entering paste mode (EOF to finish) |class D { def d = 42 } EOF // Exiting paste mode, now interpreting. defined class D scala> new D().d res1: Int = 42 scala> :quit ```
* Fix completion for multi-line entriesJason Zaugg2015-09-091-12/+16
| | | | | | | | | We need to include the previously entered lines into the code that we presentation compile. Management of this state makes the interpret method non tail recursive, so we could blow the default stack with a multi-line entry of hundreds of lines. I think thats an acceptable limitation.
* Use the presentation compiler to drive REPL tab completionJason Zaugg2015-09-021-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old implementation is still avaiable under a flag, but we'll remove it in due course. Design goal: - Push as much code in src/interactive as possible to enable reuse outside of the REPL - Don't entangle the REPL completion with JLine. The enclosed test case drives the REPL and autocompletion programatically. - Don't hard code UI choices, like how to render symbols or how to filter candidates. When completion is requested, we wrap the entered code into the same "interpreter wrapper" synthetic code as is done for regular execution. We then start a throwaway instance of the presentation compiler, which takes this as its one and only source file, and has a classpath formed from the REPL's classpath and the REPL's output directory (by default, this is in memory). We can then typecheck the tree, and find the position in the synthetic source corresponding to the cursor location. This is enough to use the new completion APIs in the presentation compiler to prepare a list of candidates. We go to extra lengths to allow completion of partially typed identifiers that appear to be keywords, e.g `global.def` should offer `definitions`. Two secret handshakes are included; move the the end of the line, type `// print<TAB>` and you'll see the post-typer tree. `// typeAt 4 6<TAB>` shows the type of the range position within the buffer. The enclosed unit test exercises most of the new functionality.
* SI-5408 Prompt after incomplete script pasteSom Snytt2015-09-021-47/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Transcript paste mode invites the user to keep typing like regular paste mode, but really you must enter more transcript. This matters if the script ends in the middle of incomplete code that the user wants to complete by hand. Previously, ``` scala> scala> def f() = { // Detected repl transcript paste: ctrl-D to finish. // Replaying 1 commands from transcript. scala> def f() = { scala> scala> def f() = { // Detected repl transcript paste: ctrl-D to finish. | } // Replaying 1 commands from transcript. scala> def f() = { } f: ()Unit ``` Now, ``` scala> scala> def f() = { // Detected repl transcript. Paste more, or ctrl-D to finish. // Replaying 1 commands from transcript. scala> def f() = { | 42 | } f: ()Int scala> f() res0: Int = 42 ```
* Update power mode bannerSom Snytt2015-09-021-6/+3
| | | | | | | | | | | The classic banner is available under -Dscala.repl.power.banner=classic. ``` scala> :power Power mode enabled. :phase is at typer. import scala.tools.nsc._, intp.global._, definitions._ Try :help or completions for vals._ and power._ ```
* SI-9206 REPL custom continuation promptSom Snytt2015-06-231-3/+5
| | | | | | | | | | Because who doesn't want to customize their continuation prompt? `scala -Dscala.repl.continue="..."` looks especially nice with `-Dscala.color`. Somewhat works when pasting, but the test rig for running a transcript does not seek to support custom secondary prompts.
* SI-9206: REPL custom welcome messageSom Snytt2015-06-231-11/+3
| | | | | | | | Can be specified by `-Dscala.repl.welcome=Greeting` or in properties file. It takes the same format arguments as the prompt, viz, version, Java version and JVM name. It can be disabled by `-Dscala.repl.welcome` with no text.
* SI-9206: No REPL message on :silent, unless -Dscala.repl.infoIgor Racic2015-06-231-3/+2
| | | | | | | | | Anyone who doesn't understand why result printing was turned off after they entered `:silent` mode will start the REPL with `-Dscala.repl.debug` and be enlightened. For infotainment purposes, the verbose message is also emitted under info mode.
* Merge pull request #4564 from som-snytt/issue/promptv2.11.7Adriaan Moors2015-06-221-59/+51
|\ | | | | SI-9206 Fix REPL code indentation
| * SI-9206 Local refactor to save eyesightSom Snytt2015-06-211-41/+38
| | | | | | | | | | | | We talk about bit rot but not about how dust accumulates on code that hasn't been swept since the last time the furniture was moved around.
| * SI-9206 Accept paste with custom promptSom Snytt2015-06-211-12/+8
| | | | | | | | But sans test.
| * SI-9206 Fix REPL code indentationSom Snytt2015-06-191-5/+4
| | | | | | | | | | | | | | | | | | | | To make code in error messages line up with the original line of code, templated code is indented by the width of the prompt. Use the raw prompt (without ANSI escapes or newlines) to determine the indentation. Also, indent only once per line.
| * SI-9206 REPL prompt is more easily configuredSom Snytt2015-06-191-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The scala shell prompt can be provided as either a system property or in compiler.properties. The prompt string is taken as a format string with one argument that is the version string. ``` $ scala -Dscala.repl.prompt="%nScala %s> " Welcome to Scala version 2.11.7-20150616-093756-43a56fb5a1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). Type in expressions to have them evaluated. Type :help for more information. Scala 2.11.7-20150616-093756-43a56fb5a1> 42 res0: Int = 42 Scala 2.11.7-20150616-093756-43a56fb5a1> :quit ```
* | SI-9339 Support classpaths with no single compatible jlineAdriaan Moors2015-06-181-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As usual, the repl will use whatever jline 2 jar on the classpath, if there is one. Failing that, there's a fallback and an override. If instantiating the standard `jline.InteractiveReader` fails, we fall back to an embedded, shaded, version of jline, provided by `jline_embedded.InteractiveReader`. (Assume `import scala.tools.nsc.interpreter._` for this message.) The instantiation of `InteractiveReader` eagerly exercises jline, so that a linkage error will result if jline is missing or if the provided one is not binary compatible. The property `scala.repl.reader` overrides this behavior, if set to the FQN of a class that looks like `YourInteractiveReader` below. ``` class YourInteractiveReader(completer: () => Completion) extends InteractiveReader ``` The repl logs which classes it tried to instantiate under `-Ydebug`. # Changes to source & build The core of the repl (`src/repl`) no longer depends on jline. The jline interface is now in `src/repl-jline`. The embedded jline + our interface to it are generated by the `quick.repl` target. The build now also enforces that only `src/repl-jline` depends on jline. The sources in `src/repl` are now sure to be independent of it, though they do use reflection to instantiate a suitable subclass of `InteractiveReader`, as explained above. The `quick.repl` target builds the sources in `src/repl` and `src/repl-jline`, producing a jar for the `repl-jline` classes, which is then transformed using jarjar to obtain a shaded copy of the `scala.tools.nsc.interpreter.jline` package. Jarjar is used to combine the `jline` jar and the `repl-jline` into a new jar, rewriting package names as follows: - `org.fusesource` -> `scala.tools.fusesource_embedded` - `jline` -> `scala.tools.jline_embedded` - `scala.tools.nsc.interpreter.jline` -> `scala.tools.nsc.interpreter.jline_embedded` Classes not reachable from `scala.tools.**` are pruned, as well as empty dirs. The classes in the `repl-jline` jar as well as those in the rewritten one are copied to the repl's output directory. PS: The sbt build is not updated, sorry. PPS: A more recent fork of jarjar: https://github.com/shevek/jarjar.
* | Centralize dependencies on jlineAdriaan Moors2015-06-171-24/+17
|/ | | | | | | | | | | | | | Code that depends on jline is now in package `scala.tools.nsc.interpreter.jline`. To make this possible, remove the `entries` functionality from `History`, and add the `historicize` method. Also provide an overload for `asStrings`. Clean up a little along the way in `JLineHistory.scala` and `JLineReader.scala`. Next step: fall back to an embedded jline when the expected jline jar is not on the classpath. The gist of the refactor: https://gist.github.com/adriaanm/02e110d4da0a585480c1
* SI-9170 More flexible SessionTestSom Snytt2015-03-031-9/+14
| | | | | | | | SessionTest session text can include line continuations and pasted text. Pasted script (which looks like a double prompt) probably doesn't work. This commit includes @retronym's SI-9170 one-liner.
* SI-6502 More robust REPL :requireJason Zaugg2015-01-161-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - handle missing files gracefully (rather than NPE) - read the class name with ASM, rather than with a dummy classloader. The dummy classloader is prone to throwing `LinkageError`s, as reported in the comments of SI-6502. Manual test of the original report: ``` % qscala Welcome to Scala version 2.11.5-20150115-183424-155dbf3fdf (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25). Type in expressions to have them evaluated. Type :help for more information. scala> :require does/not/exist Cannot read: does/not/exist scala> classOf[org.junit.Test] <console>:8: error: object junit is not a member of package org classOf[org.junit.Test] ^ scala> :require /Users/jason/.m2/repository/junit/junit/4.11/junit-4.11.jar Added '/Users/jason/.m2/repository/junit/junit/4.11/junit-4.11.jar' to classpath. scala> classOf[org.junit.Test] res1: Class[org.junit.Test] = interface org.junit.Test ``` I have commited an automated test that is a minimization of this one.
* Merge pull request #4176 from mpociecha/flat-classpath2Grzegorz Kossakowski2014-12-051-4/+4
|\ | | | | The alternative, flat representation of classpath elements
| * Use new asClassPathString method and create FileUtils for classpathmpociecha2014-11-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The method asClasspathString is now deprecated. Moreover it's moved to ClassFileLookup in the case someone was using it in some project (an alternative classpath also will support it - just in the case). All its usages existing in Scala sources are changed to asClassPathString method. The only difference is the name. Some operations on files or their names are moved from ClassPath to the newly created FileUtils dedicated to classpath. It will be possible to reuse them when implementing an alternative classpath representation. Moreover such allocation-free extension methods like the one added in this commit will improve the readability.
* | Merge pull request #4131 from som-snytt/issue/8981Lukas Rytz2014-12-041-28/+27
|\ \ | |/ |/| SI-8981 Tweak REPL help
| * SI-8981 Tweak REPL helpSom Snytt2014-11-141-28/+27
| | | | | | | | | | | | Tweak colon command processing. Fixes an unhelpful message about the ambiguity of colon.
* | Merge pull request #4051 from heathermiller/repl-cp-fix2Jason Zaugg2014-11-181-4/+49
|\ \ | |/ |/| SI-6502 Reenables loading jars into the running REPL (regression in 2.10)
| * Addresses review commentsHeather Miller2014-11-051-27/+8
| |
| * SI-6502 Addresses comments by @som-snyttHeather Miller2014-11-051-9/+3
| |
| * SI-6502 Addressing review commentsHeather Miller2014-11-051-9/+19
| |
| * SI-6502 Reenables loading jars into the running REPL (regression in 2.10)Heather Miller2014-11-051-4/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes SI-6502, reenables loading jars into the running REPL (regression in 2.10). This PR allows adding a jar to the compile and runtime classpaths without resetting the REPL state (crucial for Spark SPARK-3257). This follows the lead taken by @som-snytt in PR #3986, which differentiates two jar-loading behaviors (muddled by cp): - adding jars and replaying REPL expressions (using replay) - adding jars without resetting the REPL (deprecated cp, introduced require) This PR implements require (left unimplemented in #3986) This PR is a simplification of a similar approach taken by @gkossakowski in #3884. In this attempt, we check first to make sure that a jar is only added if it only contains new classes/traits/objects, otherwise we emit an error. This differs from the old invalidation approach which also tracked deleted classpath entries.
* | SI-8922 REPL load -vSom Snytt2014-11-041-26/+39
|/ | | | | | | | | | | | | Verbose mode causes the familiar prompt and line echo so you can see what you just loaded. The quit message is pushed up a level in the process loop. This has the huge payoff that if you start the repl and immediately hit ctl-D, you don't have to wait for the compiler to init (yawn) before you get a shell prompt back.
* Merge pull request #3993 from puffnfresh/feature/color-replGrzegorz Kossakowski2014-10-091-1/+7
|\ | | | | Color REPL under -Dscala.color
| * Color REPL under -Dscala.colorBrian McKenna2014-09-211-1/+7
| | | | | | | | | | | | | | | | | | | | We already use -Dscala.color when using -Ytyper-debug This tries to reuse the colors chosen from the debug flag: * Bold blue for vals (e.g. "res0") * Bold green for types (e.g. "Int") * Magenta for the shell prompt (e.g. "scala>")
* | Merge pull request #3986 from som-snytt/issue/6502-no-cpGrzegorz Kossakowski2014-10-071-62/+45
|\ \ | | | | | | SI-6502 Repl reset/replay take settings args
| * | SI-6502 Repl reset/replay take settings argsSom Snytt2014-09-221-61/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reset and replay commands take arbitrary command line args. When settings args are supplied, the compiler is recreated. For uniformity, the settings command performs only the usual arg parsing: use -flag:true instead of +flag, and clearing a setting is promoted to the command line, so that -Xlint: is not an error but clears the flags. ``` scala> maqicode.Test main null <console>:8: error: not found: value maqicode maqicode.Test main null ^ scala> :reset -classpath/a target/scala-2.11/sample_2.11-1.0.jar Resetting interpreter state. Forgetting all expression results and named terms: $intp scala> maqicode.Test main null Hello, world. scala> val i = 42 i: Int = 42 scala> s"$i is the loneliest numbah." res1: String = 42 is the loneliest numbah. scala> :replay -classpath "" Replaying: maqicode.Test main null Hello, world. Replaying: val i = 42 i: Int = 42 Replaying: s"$i is the loneliest numbah." res1: String = 42 is the loneliest numbah. scala> :replay -classpath/a "" Replaying: maqicode.Test main null <console>:8: error: not found: value maqicode maqicode.Test main null ^ Replaying: val i = 42 i: Int = 42 Replaying: s"$i is the loneliest numbah." res1: String = 42 is the loneliest numbah. ``` Clearing a clearable setting: ``` scala> :reset -Xlint:missing-interpolator Resetting interpreter state. scala> { val i = 42 ; "$i is the loneliest numbah." } <console>:8: warning: possible missing interpolator: detected interpolated identifier `$i` { val i = 42 ; "$i is the loneliest numbah." } ^ res0: String = $i is the loneliest numbah. scala> :reset -Xlint: Resetting interpreter state. Forgetting this session history: { val i = 42 ; "$i is the loneliest numbah." } scala> { val i = 42 ; "$i is the loneliest numbah." } res0: String = $i is the loneliest numbah. ```
| * | SI-6502 Remove cp command as unworkableSom Snytt2014-09-211-1/+5
| |/ | | | | | | | | | | | | | | People expect to change the class path midstream. Let's disabuse them by removing the broken command. The internals are deprecated.
* / Increase REPL startup timeout to avoid test failuresJason Zaugg2014-10-011-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | Under load on Jenkins, we've been seeing: ``` % diff /localhome/jenkins/a/workspace/scala-nightly-auxjvm-2.12.x/jdk/jdk7/label/auxjvm/test/files/run/t4542-run.log /localhome/jenkins/a/workspace/scala-nightly-auxjvm-2.12.x/jdk/jdk7/label/auxjvm/test/files/run/t4542.check @@ -2,75 +2,14 @@ Type in expressions to have them evaluated. Type :help for more information. scala> @deprecated("foooo", "ReplTest version 1.0-FINAL") class Foo() { java.util.concurrent.TimeoutException: Futures timed out after [60 seconds] at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219) at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:153) at scala.concurrent.Await$$anonfun$ready$1.apply(package.scala:95) at scala.concurrent.Await$$anonfun$ready$1.apply(package.scala:95) at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53) at scala.concurrent.Await$.ready(package.scala:95) at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:431) at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:457) at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:875) ``` This commit bumps the timeout up be a factor of ten to try to restore that comforting green glow to https://scala-webapps.epfl.ch/jenkins/view/2.N.x
* SI-4563 friendlier behavior for Ctrl+D in the REPLAntoine Gourlay2014-07-291-1/+8
| | | | | | | | | | | | | Closing the REPL with Ctrl+D does not issue a newline, so the user's prompt displays on the same line as the `scala>` prompt. This is bad. We now force a newline before closing the interpreter, and display `:quit` while we're at it so that people know how to exit the REPL (since `exit` doesn't exist anymore). The tricky part was to only add a newline when the console is interrupted, and *not* when it is closed by a command (like `:quit`), since commands are processed after their text (including newline) has been sent to the console.
* SI-8415 Exception handling in REPL initSom Snytt2014-03-151-2/+8
| | | | | | | | Incremental robustness, and probe for typer phase. The probe would be unnecessary if repl contributed a terminal phase that "requires" whatever it needs; that is checked when the Run is built.
* SI-7634 resurrect the REPL's :sh commandAntoine Gourlay2013-11-061-1/+1
| | | | | | ProcessResult had a companion object in 2.10 that somehow disappeared in 2.11. It only called "new ProcessResult(...)", so the REPL might just as well do that.
* Removing unused code.Paul Phillips2013-10-021-1/+0
| | | | | | | Most of this was revealed via -Xlint with a flag which assumes closed world. I can't see how to check the assumes-closed-world code in without it being an ordeal. I'll leave it in a branch in case anyone wants to finish the long slog to the merge.
* Cull extraneous whitespace.Paul Phillips2013-09-181-4/+3
| | | | | | | | | | | | | | | | | | | | | One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
* SI-7805 REPL -i startupSom Snytt2013-09-061-1/+1
| | | | | | | | | Tested with a ReplTest that loads an include script. ReplTests can choose to be `Welcoming` and keep a normalized welcome message in their check transcript. One recent SessionTest is updated to use the normalizing API.
* SI-4684 Repl supports raw pasteSom Snytt2013-07-111-9/+30
| | | | | | | | By special request, :paste -raw simply compiles the pasted code to the repl output dir. The -raw flag means no wrapping; the pasted code must be ordinary top level Scala code, not script.
* SI-4684 Repl supports whole-file pasteSom Snytt2013-07-111-15/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a file argument to the :paste command which loads the file's contents as though entered in :paste mode. The :paste command is replayable. Samples, including companions defined together: ``` scala> :paste junk.scala File contains no code: junk.scala scala> :paste no-file.scala That file does not exist scala> :paste obj-repl.scala Pasting file obj-repl.scala... <console>:2: error: expected start of definition private foo = 7 ^ scala> :paste hw-repl.scala Pasting file hw-repl.scala... The pasted code is incomplete! <pastie>:5: error: illegal start of simple expression } ^ scala> :replay Replaying: :paste junk.scala File contains no code: junk.scala Replaying: :paste obj-repl.scala Pasting file obj-repl.scala... defined trait Foo defined object Foo Replaying: Foo(new Foo{}) res0: Int = 7 ```
* Merge pull request #2697 from som-snytt/issue/6419-repl-saveAdriaan Moors2013-07-101-0/+7
|\ | | | | SI-6419 Repl save session command
| * SI-6419 Repl save session commandSom Snytt2013-07-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A simple save command to write out the current replay stack. ``` scala> val i = 7 i: Int = 7 scala> val j= 8 j: Int = 8 scala> i * j res0: Int = 56 scala> :save multy.script scala> :q apm@mara:~/tmp$ cat multy.script val i = 7 val j= 8 i * j apm@mara:~/tmp$ skala Welcome to Scala version 2.11.0-20130626-204845-a83ca5bdf7 (OpenJDK 64-Bit Server VM, Java 1.7.0_21). Type in expressions to have them evaluated. Type :help for more information. scala> :load multy.script Loading multy.script... i: Int = 7 j: Int = 8 res0: Int = 56 scala> :load multy.script Loading multy.script... i: Int = 7 j: Int = 8 res1: Int = 56 ```
* | Merge pull request #2701 from som-snytt/issue/4594-repl-settingsAdriaan Moors2013-07-101-10/+54
|\ \ | | | | | | SI-4594 Repl settings command
| * | SI-4594 Repl settings commandSom Snytt2013-07-041-10/+54
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A settings command for the rest of us. The usual command line options are used, except that boolean flags are enabled with +flag and disabled with -flag. ``` scala> :settings +deprecation scala> new BigInt(java.math.BigInteger.TEN) { } <console>:8: warning: inheritance from class BigInt in package math is deprecated: This class will me made final. new BigInt(java.math.BigInteger.TEN) { } ^ res0: BigInt = 10 scala> :settings -deprecation scala> new BigInt(java.math.BigInteger.TEN) { } res1: BigInt = 10 ``` Multivalue "colon" options can be reset by supplying no values after the colon. This behavior is different from the command line. ``` scala> 1 toString warning: there were 1 feature warning(s); re-run with -feature for details res0: String = 1 scala> :settings -language:postfixOps scala> 1 toString res1: String = 1 scala> :settings -d = . -encoding = UTF-8 -explaintypes = false -language = List(postfixOps) -nowarn = false scala> :settings -language: scala> :settings -d = . -encoding = UTF-8 -explaintypes = false -language = List() -nowarn = false ```
* / SI-7637 Repl edit commandSom Snytt2013-07-041-0/+86
|/ | | | | | | | | | | | | | | | | | | Open an editor with historical text. :edit id will use the complete text of the defining line, including a multiline expression or template definition. The id must be a term or type in scope, in particular, defined in the current session. :edit line will use the specified line(s) from history, as a line number (123), range (123-130), offset (123+7), remaining (123-) or previous (-10 for last ten lines). The env var EDITOR is used to specify an editor to invoke. If EDITOR is not set or if :line command is used, the selected text is added to the end of history. Text is still added to history one line at a time (cf SI-1067).
* SI-6855: REPL emits error on partial pastieSom Snytt2013-06-221-2/+14
| | | | | | | If pasted code is interpreted with an incomplete result, attempt to compile it to display an error. Unfancily, the code is wrapped in an object for compilation.
* SI-7418 Avoid concurrent use of compiler in REPL startupJason Zaugg2013-06-051-4/+5
| | | | | | | | | | | | | | Enable the tab completer *after* we're finished binding $intp and unleashing power mode on the asynchronous REPL startup thread. Tested manually: - run qbin/scala - Paste "".toUp - Hit <TAB> like a maniac Before this patch, the crash was reproducible almost every time. Afterwards, not the once.