mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +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.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
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.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.ISafeRunnable;
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
|
@ -216,8 +217,10 @@ public class ASTCache {
|
||||||
return astRunnable.runOnAST(lang, ast);
|
return astRunnable.runOnAST(lang, ast);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
CPPSemantics.pushLookupPoint(ast);
|
||||||
return astRunnable.runOnAST(lang, ast);
|
return astRunnable.runOnAST(lang, ast);
|
||||||
} finally {
|
} finally {
|
||||||
|
CPPSemantics.popLookupPoint();
|
||||||
releaseSharedAST(ast);
|
releaseSharedAST(ast);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
|
|
@ -252,6 +252,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
||||||
if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, implicitTargets))
|
if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, implicitTargets))
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
} else {
|
} else {
|
||||||
|
CPPSemantics.pushLookupPoint(sourceName);
|
||||||
|
try {
|
||||||
boolean found= false;
|
boolean found= false;
|
||||||
final IASTNode parent = sourceName.getParent();
|
final IASTNode parent = sourceName.getParent();
|
||||||
if (parent instanceof IASTPreprocessorIncludeStatement) {
|
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
|
// To try to do something useful anyways, we try to heuristically
|
||||||
// resolve the unknown binding to one or more concrete bindings,
|
// resolve the unknown binding to one or more concrete bindings,
|
||||||
// and use those instead.
|
// and use those instead.
|
||||||
try {
|
|
||||||
CPPSemantics.pushLookupPoint(sourceName);
|
|
||||||
IBinding[] resolved = HeuristicResolver.resolveUnknownBinding(
|
IBinding[] resolved = HeuristicResolver.resolveUnknownBinding(
|
||||||
(ICPPUnknownBinding) binding);
|
(ICPPUnknownBinding) binding);
|
||||||
if (resolved.length > 0) {
|
if (resolved.length > 0) {
|
||||||
bindings = ArrayUtil.addAll(bindings, resolved);
|
bindings = ArrayUtil.addAll(bindings, resolved);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
CPPSemantics.popLookupPoint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (binding instanceof ICPPUsingDeclaration) {
|
if (binding instanceof ICPPUsingDeclaration) {
|
||||||
// Skip using-declaration bindings. Their delegates will be among the implicit targets.
|
// 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()));
|
fAction.reportSymbolLookupFailure(new String(sourceName.toCharArray()));
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
} finally {
|
||||||
|
CPPSemantics.popLookupPoint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No enclosing name, check if we're in an include statement
|
// No enclosing name, check if we're in an include statement
|
||||||
|
|
Loading…
Add table
Reference in a new issue