diff options
author | Martin Odersky <odersky@gmail.com> | 2009-06-18 15:22:12 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-06-18 15:22:12 +0000 |
commit | e6c140fecd361fdec9ad1d3c1579b8bbd3e9f007 (patch) | |
tree | 4ce37c932a6e5dff0237f4d2cbc1b2b0258bb41e /src/compiler/scala/tools/nsc/interactive/CompilerControl.scala | |
parent | 5d11bc473378d30483488889de7b8c381c1d66c7 (diff) | |
download | scala-e6c140fecd361fdec9ad1d3c1579b8bbd3e9f007.tar.gz scala-e6c140fecd361fdec9ad1d3c1579b8bbd3e9f007.tar.bz2 scala-e6c140fecd361fdec9ad1d3c1579b8bbd3e9f007.zip |
(1) some changes to interactive compiler interf...
(1) some changes to interactive compiler interface. 2) added
(symbol.hasTypeAt 3) Added flatten/transpose/unzip to TraversableClass
Diffstat (limited to 'src/compiler/scala/tools/nsc/interactive/CompilerControl.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/CompilerControl.scala | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index 9db09c7f88..d7b5c3eedb 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -10,18 +10,29 @@ import scala.tools.nsc.ast._ */ trait CompilerControl { self: Global => + /** Response wrapper to client + */ + type Response[T] = SyncVar[Either[T, Throwable]] + + abstract class WorkItem extends (() => Unit) + + /** The status of a member that's returned by completion. + */ object MemberStatus extends Enumeration { val Accessible, Inherited, Implicit = Value } - type Response[T] = SyncVar[Either[T, Throwable]] - + /** Info given for every member found by completion + */ type Member = (Symbol, Type, MemberStatus.ValueSet) - /* Must be initialized before starting compilerRunner */ + /** The scheduler by which client and compiler communicate + * Must be initialized before starting compilerRunner + */ protected val scheduler = new WorkScheduler - /** The compilation unit corresponding to a source file */ + /** The compilation unit corresponding to a source file + */ def unitOf(s: SourceFile): RichCompilationUnit = unitOfFile get s.file match { case Some(unit) => unit @@ -31,34 +42,53 @@ trait CompilerControl { self: Global => unit } - /** Remove the corresponding CompilationUnit from consideration for recompilation */ - def removeUnitOf(s: SourceFile) = unitOfFile remove s.file - /** The compilation unit corresponding to a position */ def unitOf(pos: Position): RichCompilationUnit = unitOf(pos.source.get) - /** Locate smallest tree that encloses position */ + /** Remove the CompilationUnit corresponding to the given SourceFile + * from consideration for recompilation. + */ + def removeUnitOf(s: SourceFile) = unitOfFile remove s.file + + /** Locate smallest tree that encloses position + */ def locateTree(pos: Position): Tree = new Locator(pos) locateIn unitOf(pos).body - /** Locate smallest context that encloses position */ + /** Locate smallest context that encloses position + */ def locateContext(pos: Position): Option[Context] = locateContext(unitOf(pos).contexts, pos) - /** Make sure a set of compilation units is loaded and parsed */ + /** Make sure a set of compilation units is loaded and parsed. + * Return () to syncvar `result` on completion. + */ def askReload(sources: List[SourceFile], result: Response[Unit]) = - scheduler.postWorkItem(() => reload(sources, result)) + scheduler postWorkItem new WorkItem { + def apply() = reload(sources, result) + override def toString = "reload "+sources + } - /** Set sync var `result` to a fully attributed tree located at position `pos` */ + /** Set sync var `result` to a fully attributed tree located at position `pos` + */ def askTypeAt(pos: Position, result: Response[Tree]) = - scheduler.postWorkItem(() => self.getTypedTreeAt(pos, result)) + scheduler postWorkItem new WorkItem { + def apply() = self.getTypedTreeAt(pos, result) + override def toString = "typeat "+pos.source+" "+pos.show + } def askCompletion(pos: Position, result: Response[List[Member]]) = - scheduler.postWorkItem(() => self.completion(pos, result)) + scheduler postWorkItem new WorkItem { + def apply() = self.completion(pos, result) + override def toString = "completion "+pos.source+" "+pos.show + } /** Ask to do unit first on present and subsequent type checking passes */ def askToDoFirst(f: SourceFile) = { - scheduler.postWorkItem { () => moveToFront(List(f)) } + scheduler postWorkItem new WorkItem { + def apply() = moveToFront(List(f)) + override def toString = "dofirst "+f + } } /** Cancel currently pending high-priority jobs */ |