diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2011-03-27 11:27:29 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2011-03-27 11:27:29 +0000 |
commit | e6d026304f8efbc1f3adde6c16ae75b76d61283e (patch) | |
tree | ce0b0ced9facfb65547bc2e6488cef46d318edae /src/compiler | |
parent | 3387d04757e89cead6f9c58ee23c1684d03ed53a (diff) | |
download | scala-e6d026304f8efbc1f3adde6c16ae75b76d61283e.tar.gz scala-e6d026304f8efbc1f3adde6c16ae75b76d61283e.tar.bz2 scala-e6d026304f8efbc1f3adde6c16ae75b76d61283e.zip |
Revert "All compiler control methods now do som...
Revert "All compiler control methods now do something sensible when
called from presentation compiler thread itself."
This reverts commit bb290ba26e1d4677a36b7278ab370e841cca2605.
It leads to consistent lockups on the IDE, so we revert this
temporarily. We'll re-enable it after we can make sure it works
correctly.
Diffstat (limited to 'src/compiler')
3 files changed, 39 insertions, 32 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index 51ee6bf5fb..76df0a6bd6 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -132,8 +132,13 @@ trait CompilerControl { self: Global => /** Sets sync var `response` to the fully attributed & typechecked tree contained in `source`. * @pre `source` needs to be loaded. */ - def askType(source: SourceFile, forceReload: Boolean, response: Response[Tree]) = + def askType(source: SourceFile, forceReload: Boolean, response: Response[Tree]) = { + if (debugIDE) { + println("ask type called") + new Exception().printStackTrace() + } postWorkItem(new AskTypeItem(source, forceReload, response)) + } /** Sets sync var `response` to the position of the definition of the given link in * the given sourcefile. @@ -176,7 +181,7 @@ trait CompilerControl { self: Global => * the a NoSuchUnitError is raised in the response. */ def askLoadedTyped(source: SourceFile, response: Response[Tree]) = - postWorkItem(new AskLoadedTypedItem(source, response, onCompilerThread)) + postWorkItem(new AskLoadedTypedItem(source, response)) /** If source if not yet loaded, get an outline view with askParseEntered. * If source is loaded, wait for it to be typechecked. @@ -197,7 +202,7 @@ trait CompilerControl { self: Global => * @param response The response. */ def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) = - postWorkItem(new AskParsedEnteredItem(source, keepLoaded, response, onCompilerThread)) + postWorkItem(new AskParsedEnteredItem(source, keepLoaded, response)) /** Cancels current compiler run and start a fresh one where everything will be re-typechecked * (but not re-loaded). @@ -225,7 +230,7 @@ trait CompilerControl { self: Global => } /** Asks for a computation to be done quickly on the presentation compiler thread */ - def ask[A](op: () => A): A = if (onCompilerThread) op() else scheduler doQuickly op + def ask[A](op: () => A): A = scheduler doQuickly op /** Info given for every member found by completion */ @@ -290,13 +295,13 @@ trait CompilerControl { self: Global => override def toString = "linkpos "+sym+" in "+source } - class AskLoadedTypedItem(val source: SourceFile, response: Response[Tree], val onSameThread: Boolean) extends WorkItem { - def apply() = self.waitLoadedTyped(source, response, onSameThread) + class AskLoadedTypedItem(val source: SourceFile, response: Response[Tree]) extends WorkItem { + def apply() = self.waitLoadedTyped(source, response) override def toString = "wait loaded & typed "+source } - class AskParsedEnteredItem(val source: SourceFile, val keepLoaded: Boolean, response: Response[Tree], val onSameThread: Boolean) extends WorkItem { - def apply() = self.getParsedEntered(source, keepLoaded, response, onSameThread) + class AskParsedEnteredItem(val source: SourceFile, val keepLoaded: Boolean, response: Response[Tree]) extends WorkItem { + def apply() = self.getParsedEntered(source, keepLoaded, response) override def toString = "getParsedEntered "+source+", keepLoaded = "+keepLoaded } } diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 2e76a6378e..a2426d2212 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -848,38 +848,40 @@ class Global(settings: Settings, reporter: Reporter) } } + /** Synchronous version of askStructure. */ + def getStructure(source: SourceFile, response: Response[Tree]) { + getUnit(source) match { + case Some(_) => waitLoadedTyped(source, response) + case None => getParsedEntered(source, false, response) + } + } + /** Implements CompilerControl.askLoadedTyped */ - protected def waitLoadedTyped(source: SourceFile, response: Response[Tree], onSameThread: Boolean) { + protected def waitLoadedTyped(source: SourceFile, response: Response[Tree]) { getUnit(source) match { - case Some(unit) if unit.isUpToDate => - debugLog("already typed"); - response set unit.body - case Some(_) if !onSameThread => - debugLog("wait for later") - outOfDate = true - waitLoadedTypeResponses(source) += response - case _ => + case Some(unit) => + if (unit.isUpToDate) { debugLog("already typed"); response set unit.body } + else { debugLog("wait for later"); outOfDate = true; waitLoadedTypeResponses(source) += response } + case None => debugLog("load unit and type") try reloadSources(List(source)) - finally waitLoadedTyped(source, response, onSameThread) + finally waitLoadedTyped(source, response) } } /** Implements CompilerControl.askParsedEntered */ - protected def getParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree], onSameThread: Boolean) { + protected def getParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) { getUnit(source) match { case Some(unit) => getParsedEnteredNow(source, response) case None => - try { - if (keepLoaded || outOfDate && onSameThread) - reloadSources(List(source)) - } finally { - if (keepLoaded || !outOfDate || onSameThread) - getParsedEnteredNow(source, response) - else - getParsedEnteredResponses(source) += response - } + if (keepLoaded) + try reloadSources(List(source)) + finally getParsedEnteredNow(source, response) + else if (outOfDate) + getParsedEnteredResponses(source) += response + else + getParsedEnteredNow(source, response) } } diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala index 4591cf2522..250f648250 100644 --- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala +++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala @@ -159,13 +159,13 @@ trait Picklers { self: Global => .asClass (classOf[AskLinkPosItem]) implicit def askLoadedTypedItem: CondPickler[AskLoadedTypedItem] = - (pkl[SourceFile] ~ pkl[Boolean]) - .wrapped { case source ~ onSameThread => new AskLoadedTypedItem(source, new Response, onSameThread) } { w => w.source ~ w.onSameThread } + pkl[SourceFile] + .wrapped { new AskLoadedTypedItem(_, new Response) } { _.source } .asClass (classOf[AskLoadedTypedItem]) implicit def askParsedEnteredItem: CondPickler[AskParsedEnteredItem] = - (pkl[SourceFile] ~ pkl[Boolean] ~ pkl[Boolean]) - .wrapped { case source ~ keepLoaded ~ onSameThread => new AskParsedEnteredItem(source, keepLoaded, new Response, onSameThread) } { w => w.source ~ w.keepLoaded ~ w.onSameThread } + (pkl[SourceFile] ~ pkl[Boolean]) + .wrapped { case source ~ keepLoaded => new AskParsedEnteredItem(source, keepLoaded, new Response) } { w => w.source ~ w.keepLoaded } .asClass (classOf[AskParsedEnteredItem]) implicit def emptyAction: CondPickler[EmptyAction] = |