summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMicro Dotta <mirco.dotta@gmail.com>2011-10-24 12:43:55 +0000
committerMicro Dotta <mirco.dotta@gmail.com>2011-10-24 12:43:55 +0000
commit78db538e1dd1b9f4d078309568d237fa6c1fb25c (patch)
treeabed4abc9e911a3f26d3843d7ea64a7d93d07886 /src
parent36adada0d53f9cd982a122558dd654aa9e99e1bf (diff)
downloadscala-78db538e1dd1b9f4d078309568d237fa6c1fb25c.tar.gz
scala-78db538e1dd1b9f4d078309568d237fa6c1fb25c.tar.bz2
scala-78db538e1dd1b9f4d078309568d237fa6c1fb25c.zip
Fixes IDE ticket #1000692.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala70
1 files changed, 42 insertions, 28 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index ec364e237f..1030643d39 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -708,46 +708,60 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "")
/** Implements CompilerControl.askLinkPos */
private[interactive] def getLinkPos(sym: Symbol, source: SourceFile, response: Response[Position]) {
- informIDE("getLinkPos "+sym+" "+source)
- respond(response) {
- val preExisting = unitOfFile isDefinedAt source.file
- val originalTypeParams = sym.owner.typeParams
- reloadSources(List(source))
- parseAndEnter(getUnit(source).get)
- val owner = sym.owner
- if (owner.isClass) {
- val pre = adaptToNewRunMap(ThisType(owner))
- val newsym = pre.decl(sym.name) filter { alt =>
+ def doGetLinkPos(sym: Symbol, source: SourceFile, response: Response[Position]) {
+ informIDE("getLinkPos "+sym+" "+source)
+ respond(response) {
+ val preExisting = unitOfFile isDefinedAt source.file
+ val originalTypeParams = sym.owner.typeParams
+ reloadSources(List(source))
+ parseAndEnter(getUnit(source).get)
+ val owner = sym.owner
+ if (owner.isClass) {
+ val pre = adaptToNewRunMap(ThisType(owner))
+ val newsym = pre.decl(sym.name) filter { alt =>
sym.isType || {
try {
val tp1 = pre.memberType(alt) onTypeError NoType
val tp2 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, owner.typeParams)
matchesType(tp1, tp2, false)
} catch {
- case ex: Throwable =>
- println("error in hyperlinking: "+ex)
- ex.printStackTrace()
- false
+ case ex: Throwable =>
+ println("error in hyperlinking: "+ex)
+ ex.printStackTrace()
+ false
}
}
- }
- if (!preExisting) removeUnitOf(source)
- if (newsym == NoSymbol) {
- debugLog("link not found "+sym+" "+source+" "+pre)
- NoPosition
- } else if (newsym.isOverloaded) {
- settings.uniqid.value = true
- debugLog("link ambiguous "+sym+" "+source+" "+pre+" "+newsym.alternatives)
- NoPosition
+ }
+ if (!preExisting) removeUnitOf(source)
+ if (newsym == NoSymbol) {
+ debugLog("link not found "+sym+" "+source+" "+pre)
+ NoPosition
+ } else if (newsym.isOverloaded) {
+ settings.uniqid.value = true
+ debugLog("link ambiguous "+sym+" "+source+" "+pre+" "+newsym.alternatives)
+ NoPosition
+ } else {
+ debugLog("link found for "+newsym+": "+newsym.pos)
+ newsym.pos
+ }
} else {
- debugLog("link found for "+newsym+": "+newsym.pos)
- newsym.pos
+ debugLog("link not in class "+sym+" "+source+" "+owner)
+ NoPosition
}
- } else {
- debugLog("link not in class "+sym+" "+source+" "+owner)
- NoPosition
}
}
+
+ try {
+ reload(List(source), new Response[Unit])
+ doGetLinkPos(sym, source, response)
+ }
+ finally {
+ /* Make sure to unload the `source` file that is supposed to contain
+ * the definition of the symbol referenced by the link (i.e., `sym`).
+ * The source is unloaded for performance reasons, as the more are the loaded
+ * units, the slower is the background compiler. */
+ removeUnitOf(source)
+ }
}
def stabilizedType(tree: Tree): Type = tree match {