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
|
// Only used when writing to database, which is single-threaded
|
||||||
private final LinkedList<Runnable> postProcesses = new LinkedList<Runnable>();
|
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) {
|
public PDOMCPPLinkage(PDOM pdom, long record) {
|
||||||
super(pdom, record);
|
super(pdom, record);
|
||||||
}
|
}
|
||||||
|
@ -416,28 +423,36 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
|
|
||||||
PDOMBinding pdomBinding = addBinding(binding, name);
|
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;
|
||||||
|
|
||||||
// Some nodes schedule some of their initialization to be done
|
PDOMBinding pdomBinding = addBinding(binding, name);
|
||||||
// after the binding has been added to the PDOM, to avoid
|
|
||||||
// infinite recursion. We run those post-processes now.
|
|
||||||
// Note that we need to run it before addImplicitMethods() is
|
|
||||||
// called, since addImplicitMethods() expects the binding to
|
|
||||||
// be fully initialized.
|
|
||||||
handlePostProcesses();
|
|
||||||
|
|
||||||
if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) {
|
// Some nodes schedule some of their initialization to be done
|
||||||
if (binding instanceof ICPPClassType && name.isDefinition()) {
|
// after the binding has been added to the PDOM, to avoid
|
||||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, name);
|
// infinite recursion. We run those post-processes now.
|
||||||
|
// Note that we need to run it before addImplicitMethods() is
|
||||||
|
// called, since addImplicitMethods() expects the binding to
|
||||||
|
// be fully initialized.
|
||||||
|
handlePostProcesses();
|
||||||
|
|
||||||
|
if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) {
|
||||||
|
if (binding instanceof ICPPClassType && name.isDefinition()) {
|
||||||
|
addImplicitMethods(pdomBinding, (ICPPClassType) binding, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some of the nodes created during addImplicitMethods() can
|
||||||
|
// also schedule post-processes, so we need to run through
|
||||||
|
// them again.
|
||||||
|
handlePostProcesses();
|
||||||
|
|
||||||
|
return pdomBinding;
|
||||||
|
} finally {
|
||||||
|
pointOfInstantiation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some of the nodes created during addImplicitMethods() can
|
|
||||||
// also schedule post-processes, so we need to run through
|
|
||||||
// them again.
|
|
||||||
handlePostProcesses();
|
|
||||||
|
|
||||||
return pdomBinding;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -445,6 +460,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
* then an existing binding is updated with the properties of the name.
|
* then an existing binding is updated with the properties of the name.
|
||||||
*/
|
*/
|
||||||
private PDOMBinding addBinding(IBinding inputBinding, IASTName fromName) throws CoreException {
|
private PDOMBinding addBinding(IBinding inputBinding, IASTName fromName) throws CoreException {
|
||||||
|
IASTNode point = fromName != null ? fromName : pointOfInstantiation;
|
||||||
|
|
||||||
if (inputBinding instanceof CompositeIndexBinding) {
|
if (inputBinding instanceof CompositeIndexBinding) {
|
||||||
inputBinding= ((CompositeIndexBinding) inputBinding).getRawBinding();
|
inputBinding= ((CompositeIndexBinding) inputBinding).getRawBinding();
|
||||||
}
|
}
|
||||||
|
@ -468,11 +485,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
|
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
|
||||||
if (pdomBinding == null) {
|
if (pdomBinding == null) {
|
||||||
try {
|
try {
|
||||||
pdomBinding = createBinding(parent, binding, fileLocalRec[0], fromName);
|
pdomBinding = createBinding(parent, binding, fileLocalRec[0], point);
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
getPDOM().putCachedResult(inputBinding, pdomBinding);
|
getPDOM().putCachedResult(inputBinding, pdomBinding);
|
||||||
if (inputBinding instanceof CPPClosureType) {
|
if (inputBinding instanceof CPPClosureType) {
|
||||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
|
addImplicitMethods(pdomBinding, (ICPPClassType) binding, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronize the tags associated with the persistent binding to match
|
// 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 {
|
public void onCreateName(PDOMFile file, IASTName name, PDOMName pdomName) throws CoreException {
|
||||||
super.onCreateName(file, name, pdomName);
|
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();
|
IASTNode parentNode= name.getParent();
|
||||||
if (parentNode instanceof ICPPASTQualifiedName) {
|
if (parentNode instanceof ICPPASTQualifiedName) {
|
||||||
if (name != ((ICPPASTQualifiedName) parentNode).getLastName())
|
if (name != ((ICPPASTQualifiedName) parentNode).getLastName())
|
||||||
|
|
Loading…
Add table
Reference in a new issue