SI-4684 Repl supports whole-file paste#2696
Conversation
|
Great! We should really change the help text of You ought to be able to test this easily enough, see: test/files/run/repl-paste.scala Here's a variation I'd really like: |
|
In fact, I did look at the paste tests, but it wasn't obvious how to supply a robust path. But on second look, I guess there's |
|
@retronym Line-wise = non-pastily. |
|
"interpret lines in a file". I didn't attempt to align compile error output with the pasted file name, since line numbers would be misleading anyway. |
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
```
|
The cwd is right for the simple path after all in the test paste command. At least now I know the meaning of true companionship. |
|
IDE validation running at https://scala-webapps.epfl.ch/jenkins/job/pr-scala/60/ |
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.
|
I'm no replxpert, but LGTM. |
|
I am a rebasepert, though. |
TIL! |
|
for anyone happening upon this PR, note that Jason's http://docs.scala-lang.org/overviews/repl/overview.html has |
now that http://docs.scala-lang.org/overviews/repl/overview.html exists we can write a Moby Dick about this instead of a haiku |
|
For anyone chancing upon this PR before @SethTisue quits his day job to write his novel, here is the back of the napkin. Paul's |
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:
Review by @retronym for whom I'll throw in
:paste -rawif it otherwise looks good to him.-rawis repl speak for "without wrapping", hence top-level.