summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-01-26 21:39:50 +0000
committerMartin Odersky <odersky@gmail.com>2011-01-26 21:39:50 +0000
commitda33ea21895283dafd9c2862eb7e82313e3a763b (patch)
tree72e10f178f6aed577d9b611b8b091176f51989b8
parentc888bb422d6132e090f36efc400a97c60435d577 (diff)
downloadscala-da33ea21895283dafd9c2862eb7e82313e3a763b.tar.gz
scala-da33ea21895283dafd9c2862eb7e82313e3a763b.tar.bz2
scala-da33ea21895283dafd9c2862eb7e82313e3a763b.zip
Made askParse survive syntax errors.
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index e93ed3d48f..32a780104d 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -37,7 +37,7 @@ import scala.tools.nsc.ast._
*/
trait CompilerControl { self: Global =>
- import syntaxAnalyzer.SourceFileParser
+ import syntaxAnalyzer.UnitParser
type Response[T] = scala.tools.nsc.interactive.Response[T]
@@ -190,11 +190,15 @@ trait CompilerControl { self: Global =>
/** Tells the compile server to shutdown, and not to restart again */
def askShutdown() = scheduler raise ShutdownReq
- /** Returns parse tree for source `source`. No symbols are entered. No errors are reported.
- * Instead, any syntax error will raise a MalformedInput exception in response. (raise means: set to Right(...))
+ /** Returns parse tree for source `source`. No symbols are entered. Syntax errors are reported.
*/
def askParse(source: SourceFile, response: Response[Tree]) = respond(response) {
- new SourceFileParser(source).parse()
+ getUnit(source) match {
+ case Some(unit) if unit.status >= JustParsed =>
+ unit.body
+ case _ =>
+ new UnitParser(new CompilationUnit(source)).parse()
+ }
}
/** Asks for a computation to be done quickly on the presentation compiler thread */