1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Added isGloballyQualified method to avoid PDOMNotImplementedError.

This commit is contained in:
Sergey Prigogin 2008-04-19 19:34:57 +00:00
parent 4109b34df6
commit 4619d45eef

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@ -51,7 +52,6 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Bryan Wilkinson * @author Bryan Wilkinson
*
*/ */
class PDOMCPPClassInstance extends PDOMCPPInstance implements class PDOMCPPClassInstance extends PDOMCPPInstance implements
ICPPClassType, ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope { ICPPClassType, ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
@ -120,30 +120,31 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
} }
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
if( type instanceof PDOMNode ) { if (type instanceof PDOMNode) {
PDOMNode node = (PDOMNode) type; PDOMNode node = (PDOMNode) type;
if (node.getPDOM() == getPDOM() && node.getRecord() == getRecord()) { if (node.getPDOM() == getPDOM() && node.getRecord() == getRecord()) {
return true; return true;
} }
} }
if( type instanceof ITypedef ) if (type instanceof ITypedef)
return ((ITypedef)type).isSameType( this ); return ((ITypedef)type).isSameType(this);
if( type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType ) if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType)
return type.isSameType( this ); //the CPPDeferredClassInstance has some fuzziness return type.isSameType(this); //the CPPDeferredClassInstance has some fuzziness
if( type instanceof ICPPTemplateInstance ){ if (type instanceof ICPPTemplateInstance) {
ICPPClassType ct1= (ICPPClassType) getSpecializedBinding(); ICPPClassType ct1= (ICPPClassType) getSpecializedBinding();
ICPPClassType ct2= (ICPPClassType) ((ICPPTemplateInstance)type).getTemplateDefinition(); ICPPClassType ct2= (ICPPClassType) ((ICPPTemplateInstance)type).getTemplateDefinition();
if(!ct1.isSameType(ct2)) if (!ct1.isSameType(ct2))
return false; return false;
ObjectMap m1 = getArgumentMap(), m2 = ((ICPPTemplateInstance)type).getArgumentMap(); ObjectMap m1 = getArgumentMap();
if( m1 == null || m2 == null || m1.size() != m2.size()) ObjectMap m2 = ((ICPPTemplateInstance) type).getArgumentMap();
if (m1 == null || m2 == null || m1.size() != m2.size())
return false; return false;
for( int i = 0; i < m1.size(); i++ ){ for (int i = 0; i < m1.size(); i++) {
IType t1 = (IType) m1.getAt( i ); IType t1 = (IType) m1.getAt(i);
IType t2 = (IType) m2.getAt( i ); IType t2 = (IType) m2.getAt(i);
if( t1 == null || ! t1.isSameType( t2 ) ) if (t1 == null || !t1.isSameType(t2))
return false; return false;
} }
return true; return true;
@ -165,6 +166,11 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
} }
@Override
public boolean isGloballyQualified() throws DOMException {
return ((ICPPBinding) getSpecializedBinding()).isGloballyQualified();
}
//ICPPClassType unimplemented //ICPPClassType unimplemented
public IField findField(String name) throws DOMException { fail(); return null; } public IField findField(String name) throws DOMException { fail(); return null; }
public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; } public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; }
@ -211,8 +217,7 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
result[i] = specialization; result[i] = specialization;
} else { } else {
result[i] = CPPTemplates.createSpecialization( result[i] = CPPTemplates.createSpecialization(
PDOMCPPClassInstance.this, (IBinding) specMap PDOMCPPClassInstance.this, (IBinding) specMap.keyAt(i), getArgumentMap());
.keyAt(i), getArgumentMap());
} }
} }
return result; return result;
@ -220,7 +225,7 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
} }
public IBinding[] find(String name) throws DOMException { public IBinding[] find(String name) throws DOMException {
return CPPSemantics.findBindings( this, name, false ); return CPPSemantics.findBindings(this, name, false);
} }
@Override @Override
@ -228,14 +233,14 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
throws DOMException { throws DOMException {
try { try {
if (getDBName().equals(name.toCharArray())) { if (getDBName().equals(name.toCharArray())) {
if (!CPPClassScope.isConstructorReference(name)){ if (!CPPClassScope.isConstructorReference(name)) {
//9.2 ... The class-name is also inserted into the scope of the class itself //9.2 ... The class-name is also inserted into the scope of the class itself
return this; return this;
} }
} }
IBinding[] specialized = ((ICPPClassType) getTemplateDefinition()) IScope scope = ((ICPPClassType) getTemplateDefinition()).getCompositeScope();
.getCompositeScope().getBindings(name, resolve, false); IBinding[] specialized = scope.getBindings(name, resolve, false);
SpecializationFinder visitor = new SpecializationFinder(specialized); SpecializationFinder visitor = new SpecializationFinder(specialized);
accept(visitor); accept(visitor);
return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations()); return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations());
@ -246,7 +251,8 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
} }
@Override @Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
throws DOMException {
IBinding[] result = null; IBinding[] result = null;
try { try {
if ((!prefixLookup && getDBName().compare(name.toCharArray(), true) == 0) if ((!prefixLookup && getDBName().compare(name.toCharArray(), true) == 0)
@ -256,8 +262,8 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, this); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, this);
} }
IBinding[] specialized = ((ICPPClassType) getTemplateDefinition()) IScope scope = ((ICPPClassType) getTemplateDefinition()).getCompositeScope();
.getCompositeScope().getBindings(name, resolve, prefixLookup); IBinding[] specialized = scope.getBindings(name, resolve, prefixLookup);
SpecializationFinder visitor = new SpecializationFinder(specialized); SpecializationFinder visitor = new SpecializationFinder(specialized);
accept(visitor); accept(visitor);
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getSpecializations()); result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getSpecializations());