summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Vigdorchik <eugenevigdorchik@epfl.ch>2011-04-23 12:18:53 +0000
committerEugene Vigdorchik <eugenevigdorchik@epfl.ch>2011-04-23 12:18:53 +0000
commit6af1d5c526a6394065bb8d42ff1df36e8cb4272b (patch)
tree07ee22312effbf0d2e1b39d4cbaa86e06e9f5ef3
parent97b620ae63449d024e7147131484f104f6652edd (diff)
downloadscala-6af1d5c526a6394065bb8d42ff1df36e8cb4272b.tar.gz
scala-6af1d5c526a6394065bb8d42ff1df36e8cb4272b.tar.bz2
scala-6af1d5c526a6394065bb8d42ff1df36e8cb4272b.zip
Introduce new request for informing the present...
Introduce new request for informing the presentation compiler of files deletion. Review by odersky.
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala14
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala16
2 files changed, 29 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index 0c5d85d2a8..40bc89764b 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -107,7 +107,7 @@ trait CompilerControl { self: Global =>
if (item.onCompilerThread) item() else scheduler.postWorkItem(item)
/** Makes sure a set of compilation units is loaded and parsed.
- * Returns () to syncvar `response` on completions.
+ * Returns () to syncvar `response` on completion.
* Afterwards a new background compiler run is started with
* the given sources at the head of the list of to-be-compiled sources.
*/
@@ -120,6 +120,13 @@ trait CompilerControl { self: Global =>
postWorkItem(new ReloadItem(sources, response))
}
+ /** Removes source files and toplevel symbols, and issues a new typer run.
+ * Returns () to syncvar `response` on completion.
+ */
+ def askFilesDeleted(sources: List[SourceFile], response: Response[Unit]) = {
+ postWorkItem(new FilesDeletedItem(sources, response))
+ }
+
/** Sets sync var `response` to the smallest fully attributed tree that encloses position `pos`.
* Note: Unlike for most other ask... operations, the source file belonging to `pos` needs not be be loaded.
*/
@@ -261,6 +268,11 @@ trait CompilerControl { self: Global =>
override def toString = "reload "+sources
}
+ case class FilesDeletedItem(sources: List[SourceFile], response: Response[Unit]) extends WorkItem {
+ def apply() = filesDeleted(sources, response)
+ override def toString = "files deleted "+sources
+ }
+
class AskTypeAtItem(val pos: Position, response: Response[Tree]) extends WorkItem {
def apply() = self.getTypedTreeAt(pos, response)
override def toString = "typeat "+pos.source+" "+pos.show
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index 2b920c8c03..d8f43fd209 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -578,6 +578,22 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "")
demandNewCompilerRun()
}
+ private[interactive] def filesDeleted(sources: List[SourceFile], response: Response[Unit]) {
+ informIDE("files deleted: " + sources)
+ val deletedFiles = sources.map(_.file).toSet
+ val deletedSyms = currentTopLevelSyms filter {sym => deletedFiles contains sym.sourceFile}
+ for (d <- deletedSyms) {
+ d.owner.info.decls unlink d
+ deletedTopLevelSyms += d
+ currentTopLevelSyms -= d
+ }
+ sources foreach (removeUnitOf(_))
+ minRunId = currentRunId
+ respond(response) ()
+ demandNewCompilerRun()
+ }
+
+
/** A fully attributed tree located at position `pos` */
private def typedTreeAt(pos: Position): Tree = getUnit(pos.source) match {
case None =>