-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add native Dotty REPL #2991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add native Dotty REPL #2991
Conversation
812f141
to
2fd10d9
Compare
8d15906
to
83bacf2
Compare
6aed7ac
to
fade8b8
Compare
final val REPL_ASSIGN_SUFFIX = "$assign" | ||
final val REPL_RES_PREFIX = "res" | ||
|
||
// TODO: remove! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
@@ -197,7 +197,6 @@ class CompilationTests extends ParallelTesting { | |||
compileDir("../compiler/src/dotty/tools/dotc/config", picklingOptions) + | |||
compileDir("../compiler/src/dotty/tools/dotc/parsing", picklingOptions) + | |||
compileDir("../compiler/src/dotty/tools/dotc/printing", picklingOptions) + | |||
compileDir("../compiler/src/dotty/tools/dotc/repl", picklingOptions) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make sense to keep all that code somewhere under /tests
given that it helped detect some nasty pattern matching edge cases... WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, it still has the same components, so adding this should be trivial 👍
`dotty-compiler`, | ||
`dotty-compiler` % "test->test" | ||
). | ||
settings(commonNonBootstrappedSettings). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we the repl would be both complied by scala and bootstrapped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I guess adding the sources in dottyCompilerSettings
does the trick...
|:load <path> interpret lines in a file | ||
|:quit exit the interpreter | ||
|:type <expression> evaluate the type of the given expression | ||
|:reset reset the repl to its initial state, forgetting all session entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:imports
is missing from that list
val text = | ||
"""The REPL has several commands available: | ||
| | ||
|:help print this summary or command-specific help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command-specific part is not implemented
package repl | ||
package terminal | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old school scaladoc comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ammonite strikes again!
"val res0: Int = 2", | ||
"var y: Int = 5") | ||
|
||
expected === storedOutput().split("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does ===
do with a Set and an Array oO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a cooooool thingy that sorts, asserts and prints if assertion fails
|
||
import dotc.reporting.MessageRendering | ||
|
||
/** Runs all tests contained withing `/repl/test-resources/scripts` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/withing/in/
@@ -20,6 +19,24 @@ class ConsoleInterface { | |||
def run(args: Array[String], | |||
bootClasspathString: String, | |||
classpathString: String, | |||
// TODO: initial commands needs to be run under some form of special |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make an issue out of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is: #3007
AnsiNav.resetForegroundColor | ||
) | ||
|
||
val autocompleteFilter: Filter = Filter.action("autocompleteFilter")(SpecialKeys.Tab :: Nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the completion behavior is a bit too aggressive, at least compared to my bash habits:
$ touch equals
$ touch equalsIgnoreCase
$ cat equ # Press tab
equals equalsIgnoreCase
$ cat equals # Press tab again
equals equalsIgnoreCase
$ cat equals # and again
equals equalsIgnoreCase
scala> "".equ // Press tab
equals equalsIgnoreCase
scala> "".equals // Press tab again
equalsIgnoreCase
scala> "".equalsIgnoreCase // and again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but that's the way it's implemented in ammonite. We could probably enhance it so that you get a more bash-like behaviour. But IMO outside of the scope of this PR being merged :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Low-hanging fruit perhaps?
If the show member is a value, then when mutation ocurs in the real value - the shown value will not reflect the change.
Previously if user code was equal to null, then the accompanying show method would in effect call `null.show` which would crash the repl in a mysterious way.
5964e04
to
331892e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
FYI, on a clean clone,
|
Adding this here to check using CI that all is well in the world so far.
Will probably be ready for review in a day or two.