@@ -708,46 +708,60 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "")
708
708
709
709
/** Implements CompilerControl.askLinkPos */
710
710
private [interactive] def getLinkPos (sym : Symbol , source : SourceFile , response : Response [Position ]) {
711
- informIDE(" getLinkPos " + sym+ " " + source)
712
- respond(response) {
713
- val preExisting = unitOfFile isDefinedAt source.file
714
- val originalTypeParams = sym.owner.typeParams
715
- reloadSources(List (source))
716
- parseAndEnter(getUnit(source).get)
717
- val owner = sym.owner
718
- if (owner.isClass) {
719
- val pre = adaptToNewRunMap(ThisType (owner))
720
- val newsym = pre.decl(sym.name) filter { alt =>
711
+ def doGetLinkPos (sym : Symbol , source : SourceFile , response : Response [Position ]) {
712
+ informIDE(" getLinkPos " + sym+ " " + source)
713
+ respond(response) {
714
+ val preExisting = unitOfFile isDefinedAt source.file
715
+ val originalTypeParams = sym.owner.typeParams
716
+ reloadSources(List (source))
717
+ parseAndEnter(getUnit(source).get)
718
+ val owner = sym.owner
719
+ if (owner.isClass) {
720
+ val pre = adaptToNewRunMap(ThisType (owner))
721
+ val newsym = pre.decl(sym.name) filter { alt =>
721
722
sym.isType || {
722
723
try {
723
724
val tp1 = pre.memberType(alt) onTypeError NoType
724
725
val tp2 = adaptToNewRunMap(sym.tpe) substSym (originalTypeParams, owner.typeParams)
725
726
matchesType(tp1, tp2, false )
726
727
} catch {
727
- case ex : Throwable =>
728
- println(" error in hyperlinking: " + ex)
729
- ex.printStackTrace()
730
- false
728
+ case ex : Throwable =>
729
+ println(" error in hyperlinking: " + ex)
730
+ ex.printStackTrace()
731
+ false
731
732
}
732
733
}
733
- }
734
- if (! preExisting) removeUnitOf(source)
735
- if (newsym == NoSymbol ) {
736
- debugLog(" link not found " + sym+ " " + source+ " " + pre)
737
- NoPosition
738
- } else if (newsym.isOverloaded) {
739
- settings.uniqid.value = true
740
- debugLog(" link ambiguous " + sym+ " " + source+ " " + pre+ " " + newsym.alternatives)
741
- NoPosition
734
+ }
735
+ if (! preExisting) removeUnitOf(source)
736
+ if (newsym == NoSymbol ) {
737
+ debugLog(" link not found " + sym+ " " + source+ " " + pre)
738
+ NoPosition
739
+ } else if (newsym.isOverloaded) {
740
+ settings.uniqid.value = true
741
+ debugLog(" link ambiguous " + sym+ " " + source+ " " + pre+ " " + newsym.alternatives)
742
+ NoPosition
743
+ } else {
744
+ debugLog(" link found for " + newsym+ " : " + newsym.pos)
745
+ newsym.pos
746
+ }
742
747
} else {
743
- debugLog(" link found for " + newsym + " : " + newsym.pos )
744
- newsym.pos
748
+ debugLog(" link not in class " + sym + " " + source + " " + owner )
749
+ NoPosition
745
750
}
746
- } else {
747
- debugLog(" link not in class " + sym+ " " + source+ " " + owner)
748
- NoPosition
749
751
}
750
752
}
753
+
754
+ try {
755
+ reload(List (source), new Response [Unit ])
756
+ doGetLinkPos(sym, source, response)
757
+ }
758
+ finally {
759
+ /* Make sure to unload the `source` file that is supposed to contain
760
+ * the definition of the symbol referenced by the link (i.e., `sym`).
761
+ * The source is unloaded for performance reasons, as the more are the loaded
762
+ * units, the slower is the background compiler. */
763
+ removeUnitOf(source)
764
+ }
751
765
}
752
766
753
767
def stabilizedType (tree : Tree ): Type = tree match {
0 commit comments