mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 486909 - Ensure a point of instantiation is available in PDOM code where needed
Change-Id: I59074559db3a4421ab8b0fe2fee200dd5157a81d
This commit is contained in:
parent
766f66c0ab
commit
8329a08ae1
1 changed files with 48 additions and 22 deletions
|
@ -164,6 +164,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
// Only used when writing to database, which is single-threaded
|
||||
private final LinkedList<Runnable> postProcesses = new LinkedList<Runnable>();
|
||||
|
||||
// The point of instantiation for name lookups.
|
||||
// This is set by onCreateName() and the top-level addBinding() call for
|
||||
// their duration, and picked up by nested addBinding() calls. This avoids
|
||||
// having to pass it around to every function that is called between
|
||||
// (which is a lot of functions).
|
||||
private IASTName pointOfInstantiation = null;
|
||||
|
||||
public PDOMCPPLinkage(PDOM pdom, long record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
@ -416,6 +423,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
|
||||
IBinding binding = name.resolveBinding();
|
||||
|
||||
try {
|
||||
// For the duration of this call, record the name being added
|
||||
// to the index as the point of instantiation for name lookups.
|
||||
pointOfInstantiation = name;
|
||||
|
||||
PDOMBinding pdomBinding = addBinding(binding, name);
|
||||
|
||||
// Some nodes schedule some of their initialization to be done
|
||||
|
@ -438,6 +450,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
handlePostProcesses();
|
||||
|
||||
return pdomBinding;
|
||||
} finally {
|
||||
pointOfInstantiation = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -445,6 +460,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
* then an existing binding is updated with the properties of the name.
|
||||
*/
|
||||
private PDOMBinding addBinding(IBinding inputBinding, IASTName fromName) throws CoreException {
|
||||
IASTNode point = fromName != null ? fromName : pointOfInstantiation;
|
||||
|
||||
if (inputBinding instanceof CompositeIndexBinding) {
|
||||
inputBinding= ((CompositeIndexBinding) inputBinding).getRawBinding();
|
||||
}
|
||||
|
@ -468,11 +485,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
|
||||
if (pdomBinding == null) {
|
||||
try {
|
||||
pdomBinding = createBinding(parent, binding, fileLocalRec[0], fromName);
|
||||
pdomBinding = createBinding(parent, binding, fileLocalRec[0], point);
|
||||
if (pdomBinding != null) {
|
||||
getPDOM().putCachedResult(inputBinding, pdomBinding);
|
||||
if (inputBinding instanceof CPPClosureType) {
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, point);
|
||||
}
|
||||
|
||||
// Synchronize the tags associated with the persistent binding to match
|
||||
|
@ -1166,6 +1183,15 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
public void onCreateName(PDOMFile file, IASTName name, PDOMName pdomName) throws CoreException {
|
||||
super.onCreateName(file, name, pdomName);
|
||||
|
||||
try {
|
||||
pointOfInstantiation = name;
|
||||
onCreateNameHelper(file, name, pdomName);
|
||||
} finally {
|
||||
pointOfInstantiation = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void onCreateNameHelper(PDOMFile file, IASTName name, PDOMName pdomName) throws CoreException {
|
||||
IASTNode parentNode= name.getParent();
|
||||
if (parentNode instanceof ICPPASTQualifiedName) {
|
||||
if (name != ((ICPPASTQualifiedName) parentNode).getLastName())
|
||||
|
|
Loading…
Add table
Reference in a new issue