mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 15:25:49 +02:00
Improve tracking of lookup points
ASTCache now sets the AST as the initial lookup point when invoking an ASTRunnable. In addition, OpenDeclarationsJob sets the selected node as a more precise lookup point. Change-Id: I9b32fccd80bc1b13e6da49a80a896b595784b868
This commit is contained in:
parent
45101e2a64
commit
1054a38b44
2 changed files with 74 additions and 71 deletions
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.index.IIndexManager;
|
|||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.ISafeRunnable;
|
||||
|
@ -216,8 +217,10 @@ public class ASTCache {
|
|||
return astRunnable.runOnAST(lang, ast);
|
||||
}
|
||||
try {
|
||||
CPPSemantics.pushLookupPoint(ast);
|
||||
return astRunnable.runOnAST(lang, ast);
|
||||
} finally {
|
||||
CPPSemantics.popLookupPoint();
|
||||
releaseSharedAST(ast);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -252,6 +252,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
|||
if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, implicitTargets))
|
||||
return Status.OK_STATUS;
|
||||
} else {
|
||||
CPPSemantics.pushLookupPoint(sourceName);
|
||||
try {
|
||||
boolean found= false;
|
||||
final IASTNode parent = sourceName.getParent();
|
||||
if (parent instanceof IASTPreprocessorIncludeStatement) {
|
||||
|
@ -286,17 +288,12 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
|||
// To try to do something useful anyways, we try to heuristically
|
||||
// resolve the unknown binding to one or more concrete bindings,
|
||||
// and use those instead.
|
||||
try {
|
||||
CPPSemantics.pushLookupPoint(sourceName);
|
||||
IBinding[] resolved = HeuristicResolver.resolveUnknownBinding(
|
||||
(ICPPUnknownBinding) binding);
|
||||
if (resolved.length > 0) {
|
||||
bindings = ArrayUtil.addAll(bindings, resolved);
|
||||
continue;
|
||||
}
|
||||
} finally {
|
||||
CPPSemantics.popLookupPoint();
|
||||
}
|
||||
}
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
// Skip using-declaration bindings. Their delegates will be among the implicit targets.
|
||||
|
@ -338,6 +335,9 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
|||
fAction.reportSymbolLookupFailure(new String(sourceName.toCharArray()));
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
} finally {
|
||||
CPPSemantics.popLookupPoint();
|
||||
}
|
||||
}
|
||||
|
||||
// No enclosing name, check if we're in an include statement
|
||||
|
|
Loading…
Add table
Reference in a new issue