mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Fix for 156504 by Andrew Ferguson, Overloaded functions/methods in PDOM
This commit is contained in:
parent
fe98dbbe57
commit
baa29bb0f5
4 changed files with 23 additions and 44 deletions
|
@ -14,17 +14,16 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public final class FindBindingsInBTree implements IBTreeVisitor {
|
||||
protected final PDOM pdom;
|
||||
protected final PDOMLinkage linkage;
|
||||
protected final char[] name;
|
||||
|
||||
|
||||
public int compare(int record) throws CoreException {
|
||||
PDOMNamedNode node = ((PDOMNamedNode)pdom.getLinkage(record).getNode(record));
|
||||
PDOMNamedNode node = ((PDOMNamedNode)linkage.getNode(record));
|
||||
return node.getDBName().compare(name);
|
||||
}
|
||||
|
||||
|
@ -37,8 +36,8 @@ public final class FindBindingsInBTree implements IBTreeVisitor {
|
|||
* @param pdom
|
||||
* @param name
|
||||
*/
|
||||
public FindBindingsInBTree(PDOM pdom, char[] name) {
|
||||
this(pdom, name, null);
|
||||
public FindBindingsInBTree(PDOMLinkage linkage, char[] name) {
|
||||
this(linkage, name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,8 +47,8 @@ public final class FindBindingsInBTree implements IBTreeVisitor {
|
|||
* @param name
|
||||
* @param desiredType
|
||||
*/
|
||||
public FindBindingsInBTree(PDOM pdom, char[] name, int desiredType) {
|
||||
this(pdom, name, new int[] { desiredType });
|
||||
public FindBindingsInBTree(PDOMLinkage linkage, char[] name, int desiredType) {
|
||||
this(linkage, name, new int[] { desiredType });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,17 +58,17 @@ public final class FindBindingsInBTree implements IBTreeVisitor {
|
|||
* @param name
|
||||
* @param desiredType
|
||||
*/
|
||||
public FindBindingsInBTree(PDOM pdom, char[] name, int[] desiredType) {
|
||||
this.pdom = pdom;
|
||||
public FindBindingsInBTree(PDOMLinkage linkage, char[] name, int[] desiredType) {
|
||||
this.name = name;
|
||||
this.desiredType = desiredType;
|
||||
this.linkage= linkage;
|
||||
}
|
||||
|
||||
public boolean visit(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return true;
|
||||
|
||||
PDOMBinding tBinding = pdom.getBinding(record);
|
||||
PDOMBinding tBinding = linkage.getPDOM().getBinding(record);
|
||||
if (!tBinding.hasName(name))
|
||||
// no more bindings with our desired name
|
||||
return false;
|
||||
|
|
|
@ -135,7 +135,9 @@ class PDOMCLinkage extends PDOMLinkage {
|
|||
} else if (binding instanceof ITypedef)
|
||||
pdomBinding = new PDOMCTypedef(pdom, parent, name, (ITypedef)binding);
|
||||
|
||||
parent.addChild(pdomBinding);
|
||||
if(pdomBinding!=null) {
|
||||
parent.addChild(pdomBinding);
|
||||
}
|
||||
}
|
||||
|
||||
if (pdomBinding != null)
|
||||
|
|
|
@ -112,13 +112,12 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
public PDOMBinding addName(IASTName name, PDOMFile file) throws CoreException {
|
||||
if (name == null || name instanceof ICPPASTQualifiedName)
|
||||
return null;
|
||||
|
||||
|
||||
// Check for null name
|
||||
char[] namechars = name.toCharArray();
|
||||
if (namechars == null || namechars.length == 0)
|
||||
return null;
|
||||
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
|
||||
if (binding == null || binding instanceof IProblemBinding)
|
||||
|
@ -144,32 +143,8 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
|
||||
if(!name.isReference()) {
|
||||
//because we got the implicit method off of an IASTName that is not a reference,
|
||||
//it is no longer completly implicit and it should be treated as a normal method.
|
||||
//it is no longer completly implicit and it should be treated as a normal method.
|
||||
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
|
||||
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
|
||||
if(!name.isReference()) {
|
||||
//because we got the implicit method off of an IASTName that is not a reference,
|
||||
//it is no longer completly implicit and it should be treated as a normal method.
|
||||
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
|
||||
}
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
pdomBinding = new PDOMCPPClassType(pdom, parent, name);
|
||||
} else if (binding instanceof ICPPNamespaceAlias) {
|
||||
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
|
||||
} else if (binding instanceof ICPPNamespace) {
|
||||
pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
|
||||
} else if (binding instanceof IEnumeration) {
|
||||
pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
|
||||
} else if (binding instanceof IEnumerator) {
|
||||
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
|
||||
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
|
||||
if (pdomEnumeration instanceof PDOMCPPEnumeration)
|
||||
pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
|
||||
(PDOMCPPEnumeration)pdomEnumeration);
|
||||
} else if (binding instanceof ITypedef) {
|
||||
pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
|
||||
}
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
|
||||
|
@ -190,7 +165,10 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
} else if (binding instanceof ITypedef) {
|
||||
pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
|
||||
}
|
||||
parent.addChild(pdomBinding);
|
||||
|
||||
if(pdomBinding!=null) {
|
||||
parent.addChild(pdomBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(DOMException e) {
|
||||
|
@ -296,7 +274,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private PDOMBinding _resolveBinding(IASTName name) throws CoreException, DOMException {
|
||||
// mstodo revisit
|
||||
IBinding origBinding = name.getBinding();
|
||||
|
|
|
@ -102,7 +102,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
try {
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(pdom, name.toCharArray());
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray());
|
||||
getIndex().accept(visitor);
|
||||
return visitor.getBinding();
|
||||
} catch (CoreException e) {
|
||||
|
@ -133,7 +133,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
return null;
|
||||
|
||||
// Look up the name
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(pdom, name.toCharArray(),
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(),
|
||||
new int[] {
|
||||
PDOMCPPLinkage.CPPCLASSTYPE,
|
||||
PDOMCPPLinkage.CPPNAMESPACE,
|
||||
|
@ -160,7 +160,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
getIndex().accept(feb);
|
||||
return feb.getResult();
|
||||
} else {
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(pdom, name.toCharArray(),
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(),
|
||||
(name.getParent() instanceof ICPPASTQualifiedName
|
||||
&& ((ICPPASTQualifiedName)name.getParent()).getLastName() != name)
|
||||
? PDOMCPPLinkage.CPPNAMESPACE : PDOMCPPLinkage.CPPVARIABLE);
|
||||
|
@ -171,7 +171,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
|||
: null;
|
||||
}
|
||||
} else if (parent instanceof IASTNamedTypeSpecifier) {
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(pdom, name.toCharArray(), PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(), PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
getIndex().accept(visitor);
|
||||
IBinding[] bindings = visitor.getBinding();
|
||||
return bindings.length > 0
|
||||
|
|
Loading…
Add table
Reference in a new issue