diff options
author | Martin Odersky <odersky@gmail.com> | 2011-01-26 12:47:27 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-01-26 12:47:27 +0000 |
commit | 5be3517c4ffc1d10b904af2a26328a2a5e2e9094 (patch) | |
tree | e35eec13ffca88b37d2333ebb04211a0c3e7779e /src | |
parent | dc39ab60d579029e094a7e4c4c077c8aba0810dc (diff) | |
download | scala-5be3517c4ffc1d10b904af2a26328a2a5e2e9094.tar.gz scala-5be3517c4ffc1d10b904af2a26328a2a5e2e9094.tar.bz2 scala-5be3517c4ffc1d10b904af2a26328a2a5e2e9094.zip |
Added an askParse method
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/CompilerControl.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index 5a1cd0fdde..e93ed3d48f 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -37,6 +37,8 @@ import scala.tools.nsc.ast._ */ trait CompilerControl { self: Global => + import syntaxAnalyzer.SourceFileParser + type Response[T] = scala.tools.nsc.interactive.Response[T] /** The scheduler by which client and compiler communicate @@ -188,6 +190,13 @@ 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(...)) + */ + def askParse(source: SourceFile, response: Response[Tree]) = respond(response) { + new SourceFileParser(source).parse() + } + /** Asks for a computation to be done quickly on the presentation compiler thread */ def ask[A](op: () => A): A = scheduler doQuickly op @@ -214,7 +223,7 @@ trait CompilerControl { self: Global => // items that get sent to scheduler - abstract class WorkItem extends (() => Unit) + abstract class WorkItem extends (() => Unit) case class ReloadItem(sources: List[SourceFile], response: Response[Unit]) extends WorkItem { def apply() = reload(sources, response) |