Skip to content

Fix #1552: REPL file loading #1585

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

Merged
merged 1 commit into from
Oct 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions src/dotty/tools/dotc/repl/InterpreterLoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,16 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con

/** interpret all lines from a specified file */
def interpretAllFrom(filename: String): Unit = {
val fileIn = try {
new FileReader(filename)
} catch {
case _: IOException =>
output.println("Error opening file: " + filename)
return
}
val oldIn = in
val oldReplay = replayCommandsRev
import java.nio.file.{Files, Paths}
import scala.collection.JavaConversions._
try {
val inFile = new BufferedReader(fileIn)
in = new SimpleReader(inFile, output, false)
val lines = Files.readAllLines(Paths.get(filename)).mkString("\n")
output.println("Loading " + filename + "...")
output.flush
repl()
} finally {
in = oldIn
replayCommandsRev = oldReplay
fileIn.close
interpreter.interpret(lines)
} catch {
case _: IOException =>
output.println("Error opening file: " + filename)
}
}

Expand Down