1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Use isSameType instead of equals when looking up template type parameters in an argument map.

This commit is contained in:
Sergey Prigogin 2008-04-07 06:29:05 +00:00
parent 1a2abe7d43
commit edb7610220
5 changed files with 110 additions and 110 deletions

View file

@ -112,7 +112,12 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
} }
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) { public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
return null; ICPPSpecialization instance = getInstance(arguments);
if (instance == null) {
instance = new CPPDeferredClassInstance(this, argMap, arguments);
addSpecialization(arguments, instance);
}
return instance;
} }
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) { public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {

View file

@ -8,9 +8,6 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
/*
* Created on Apr 13, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
@ -31,8 +28,8 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
*/ */
public class CPPTemplateTypeParameter extends CPPTemplateParameter implements public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
ICPPTemplateTypeParameter, IType, ICPPInternalUnknown { ICPPTemplateTypeParameter, IType, ICPPInternalUnknown {
private ICPPScope unknownScope = null; private ICPPScope unknownScope = null;
/** /**
* @param name * @param name
*/ */
@ -41,49 +38,47 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
} }
public ICPPScope getUnknownScope() { public ICPPScope getUnknownScope() {
if( unknownScope == null ) { if (unknownScope == null) {
IASTName n = null; IASTName n = null;
IASTNode[] nodes = getDeclarations(); IASTNode[] nodes = getDeclarations();
if( nodes != null && nodes.length > 0 ) if (nodes != null && nodes.length > 0)
n = (IASTName) nodes[0]; n = (IASTName) nodes[0];
unknownScope = new CPPUnknownScope( this, n ); unknownScope = new CPPUnknownScope(this, n);
} }
return unknownScope; return unknownScope;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter#getDefault() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter#getDefault()
*/ */
public IType getDefault() { public IType getDefault() {
IASTNode [] nds = getDeclarations(); IASTNode[] nds = getDeclarations();
if( nds == null || nds.length == 0 ) if (nds == null || nds.length == 0)
return null; return null;
IASTName name = (IASTName) nds[0]; IASTName name = (IASTName) nds[0];
ICPPASTSimpleTypeTemplateParameter simple = (ICPPASTSimpleTypeTemplateParameter) name.getParent(); ICPPASTSimpleTypeTemplateParameter simple = (ICPPASTSimpleTypeTemplateParameter) name.getParent();
IASTTypeId typeId = simple.getDefaultType(); IASTTypeId typeId = simple.getDefaultType();
if( typeId != null ) if (typeId != null)
return CPPVisitor.createType( typeId ); return CPPVisitor.createType(typeId);
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/ */
public boolean isSameType( IType type ) { public boolean isSameType(IType type) {
if( type == this ) if (type == this)
return true; return true;
if( type instanceof ITypedef || type instanceof IIndexType ) if (type instanceof ITypedef || type instanceof IIndexType)
return type.isSameType( this ); return type.isSameType(this);
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/ */
public IBinding resolveUnknown( ObjectMap argMap ) { public IBinding resolveUnknown(ObjectMap argMap) {
// TODO Auto-generated method stub // Cannot do resolution here since the result is not necessarily a binding.
return null; return null;
} }
} }

View file

@ -21,9 +21,11 @@ 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.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
@ -132,8 +134,10 @@ public abstract class CPPUnknownBinding extends PlatformObject
*/ */
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException { public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this; IBinding result = this;
IType t = (IType) argMap.get(scopeBinding); IType t = null;
if (t == null && scopeBinding instanceof ICPPInternalUnknownClassType) { if (scopeBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) scopeBinding, argMap);
} else if (scopeBinding instanceof ICPPInternalUnknownClassType) {
IBinding binding = ((ICPPInternalUnknownClassType) scopeBinding).resolveUnknown(argMap); IBinding binding = ((ICPPInternalUnknownClassType) scopeBinding).resolveUnknown(argMap);
if (binding instanceof IType) { if (binding instanceof IType) {
t = (IType) binding; t = (IType) binding;

View file

@ -735,8 +735,18 @@ public class CPPTemplates {
} else { } else {
newType = type; newType = type;
} }
} else if (type instanceof ICPPTemplateParameter && argMap.containsKey(type)) { } else if (type instanceof ICPPTemplateParameter) {
newType = (IType) argMap.get(type); IType t = (IType) argMap.get(type);
if (t == null) {
for (int i = 0; i < argMap.size(); i++) {
if (type.isSameType((IType) argMap.keyAt(i))) {
newType = (IType) argMap.getAt(i);
break;
}
}
} else {
newType = t;
}
} else if (type instanceof ICPPInternalDeferredClassInstance) { } else if (type instanceof ICPPInternalDeferredClassInstance) {
newType = ((ICPPInternalDeferredClassInstance) type).instantiate(argMap); newType = ((ICPPInternalDeferredClassInstance) type).instantiate(argMap);
} else if (type instanceof ICPPInternalUnknown) { } else if (type instanceof ICPPInternalUnknown) {

View file

@ -34,36 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope; 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.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.*;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
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.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
@ -71,6 +42,7 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
@ -120,7 +92,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
// Binding types // Binding types
private class ConfigureTemplate implements Runnable { private class ConfigureTemplate implements Runnable {
ICPPTemplateDefinition template; ICPPTemplateDefinition template;
@ -150,7 +121,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMCPPClassTemplatePartialSpecialization partial; PDOMCPPClassTemplatePartialSpecialization partial;
ICPPClassTemplatePartialSpecialization binding; ICPPClassTemplatePartialSpecialization binding;
public ConfigurePartialSpecialization(PDOMCPPClassTemplatePartialSpecialization partial, ICPPClassTemplatePartialSpecialization binding) { public ConfigurePartialSpecialization(PDOMCPPClassTemplatePartialSpecialization partial,
ICPPClassTemplatePartialSpecialization binding) {
this.partial = partial; this.partial = partial;
this.binding = binding; this.binding = binding;
} }
@ -300,7 +272,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding(); IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
if (specialized == null || specialized instanceof ProblemBinding) return null; if (specialized == null || specialized instanceof ProblemBinding) return null;
PDOMBinding pdomSpecialized = addBinding(specialized, null); PDOMBinding pdomSpecialized = addBinding(specialized, null);
if (pdomSpecialized == null) return null; if (pdomSpecialized == null)
return null;
if (binding instanceof ICPPDeferredTemplateInstance) { if (binding instanceof ICPPDeferredTemplateInstance) {
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) { if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
@ -324,7 +297,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding = new PDOMCPPClassInstance(pdom, parent, pdomBinding = new PDOMCPPClassInstance(pdom, parent,
(ICPPClassType) binding, pdomSpecialized); (ICPPClassType) binding, pdomSpecialized);
} }
} else if (binding instanceof ICPPClassTemplatePartialSpecialization && pdomSpecialized instanceof PDOMCPPClassTemplate) { } else if (binding instanceof ICPPClassTemplatePartialSpecialization &&
pdomSpecialized instanceof PDOMCPPClassTemplate) {
pdomBinding = new PDOMCPPClassTemplatePartialSpecialization( pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
pdom, parent, (ICPPClassTemplatePartialSpecialization) binding, pdom, parent, (ICPPClassTemplatePartialSpecialization) binding,
(PDOMCPPClassTemplate) pdomSpecialized); (PDOMCPPClassTemplate) pdomSpecialized);
@ -460,10 +434,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMBinding pdomBinding= adaptBinding(method); PDOMBinding pdomBinding= adaptBinding(method);
if (pdomBinding == null) { if (pdomBinding == null) {
addBinding(type, method); addBinding(type, method);
} else { } else if (!pdomBinding.hasDefinition()) {
if (!pdomBinding.hasDefinition()) { pdomBinding.update(this, method);
pdomBinding.update(this, method);
}
} }
} }
} }
@ -476,90 +448,97 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
public int getBindingType(IBinding binding) { public int getBindingType(IBinding binding) {
if (binding instanceof ICPPSpecialization) { if (binding instanceof ICPPSpecialization) {
if (binding instanceof ICPPDeferredTemplateInstance) { if (binding instanceof ICPPDeferredTemplateInstance) {
if (binding instanceof ICPPFunction) if (binding instanceof ICPPFunction) {
return CPP_DEFERRED_FUNCTION_INSTANCE; return CPP_DEFERRED_FUNCTION_INSTANCE;
if (binding instanceof ICPPClassType) } else if (binding instanceof ICPPClassType) {
return CPP_DEFERRED_CLASS_INSTANCE; return CPP_DEFERRED_CLASS_INSTANCE;
}
} else if (binding instanceof ICPPTemplateInstance) { } else if (binding instanceof ICPPTemplateInstance) {
if (binding instanceof ICPPConstructor) if (binding instanceof ICPPConstructor) {
return CPP_CONSTRUCTOR_INSTANCE; return CPP_CONSTRUCTOR_INSTANCE;
if (binding instanceof ICPPMethod) } else if (binding instanceof ICPPMethod) {
return CPP_METHOD_INSTANCE; return CPP_METHOD_INSTANCE;
else if (binding instanceof ICPPFunction) } else if (binding instanceof ICPPFunction) {
return CPP_FUNCTION_INSTANCE; return CPP_FUNCTION_INSTANCE;
else if (binding instanceof ICPPClassType) } else if (binding instanceof ICPPClassType) {
return CPP_CLASS_INSTANCE; return CPP_CLASS_INSTANCE;
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) }
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
return CPP_CLASS_TEMPLATE_PARTIAL_SPEC; return CPP_CLASS_TEMPLATE_PARTIAL_SPEC;
else if (binding instanceof ICPPField) } else if (binding instanceof ICPPField) {
return CPP_FIELD_SPECIALIZATION; return CPP_FIELD_SPECIALIZATION;
else if (binding instanceof ICPPFunctionTemplate) { } else if (binding instanceof ICPPFunctionTemplate) {
if (binding instanceof ICPPConstructor) if (binding instanceof ICPPConstructor) {
return CPP_CONSTRUCTOR_TEMPLATE_SPECIALIZATION; return CPP_CONSTRUCTOR_TEMPLATE_SPECIALIZATION;
else if (binding instanceof ICPPMethod) } else if (binding instanceof ICPPMethod) {
return CPP_METHOD_TEMPLATE_SPECIALIZATION; return CPP_METHOD_TEMPLATE_SPECIALIZATION;
else if (binding instanceof ICPPFunction) } else if (binding instanceof ICPPFunction) {
return CPP_FUNCTION_TEMPLATE_SPECIALIZATION; return CPP_FUNCTION_TEMPLATE_SPECIALIZATION;
} else if (binding instanceof ICPPConstructor) }
} else if (binding instanceof ICPPConstructor) {
return CPP_CONSTRUCTOR_SPECIALIZATION; return CPP_CONSTRUCTOR_SPECIALIZATION;
else if (binding instanceof ICPPMethod) } else if (binding instanceof ICPPMethod) {
return CPP_METHOD_SPECIALIZATION; return CPP_METHOD_SPECIALIZATION;
else if (binding instanceof ICPPFunction) } else if (binding instanceof ICPPFunction) {
return CPP_FUNCTION_SPECIALIZATION; return CPP_FUNCTION_SPECIALIZATION;
else if (binding instanceof ICPPClassTemplate) } else if (binding instanceof ICPPClassTemplate) {
return CPP_CLASS_TEMPLATE_SPECIALIZATION; return CPP_CLASS_TEMPLATE_SPECIALIZATION;
else if (binding instanceof ICPPClassType) } else if (binding instanceof ICPPClassType) {
return CPP_CLASS_SPECIALIZATION; return CPP_CLASS_SPECIALIZATION;
else if (binding instanceof ITypedef) } else if (binding instanceof ITypedef) {
return CPP_TYPEDEF_SPECIALIZATION; return CPP_TYPEDEF_SPECIALIZATION;
}
} else if (binding instanceof ICPPTemplateParameter) { } else if (binding instanceof ICPPTemplateParameter) {
if (binding instanceof ICPPTemplateTypeParameter) if (binding instanceof ICPPTemplateTypeParameter) {
return CPP_TEMPLATE_TYPE_PARAMETER; return CPP_TEMPLATE_TYPE_PARAMETER;
}
// TODO other template parameter types // TODO other template parameter types
// else if (binding instanceof ICPPTemplateTemplateParameter) // else if (binding instanceof ICPPTemplateTemplateParameter)
// return CPP_TEMPLATE_TEMPLATE_PARAMETER; // return CPP_TEMPLATE_TEMPLATE_PARAMETER;
// else if (binding instanceof ICPPTemplateNonTypeParameter) // else if (binding instanceof ICPPTemplateNonTypeParameter)
// return CPP_TEMPLATE_NON_TYPE_PARAMETER; // return CPP_TEMPLATE_NON_TYPE_PARAMETER;
} else if (binding instanceof ICPPField) } else if (binding instanceof ICPPField) {
// this must be before variables // this must be before variables
return CPPFIELD; return CPPFIELD;
else if (binding instanceof ICPPVariable) } else if (binding instanceof ICPPVariable) {
return CPPVARIABLE; return CPPVARIABLE;
else if (binding instanceof ICPPFunctionTemplate) { } else if (binding instanceof ICPPFunctionTemplate) {
// this must be before functions // this must be before functions
if (binding instanceof ICPPConstructor) if (binding instanceof ICPPConstructor) {
return CPP_CONSTRUCTOR_TEMPLATE; return CPP_CONSTRUCTOR_TEMPLATE;
else if (binding instanceof ICPPMethod) } else if (binding instanceof ICPPMethod) {
return CPP_METHOD_TEMPLATE; return CPP_METHOD_TEMPLATE;
else if (binding instanceof ICPPFunction) } else if (binding instanceof ICPPFunction) {
return CPP_FUNCTION_TEMPLATE; return CPP_FUNCTION_TEMPLATE;
} else if (binding instanceof ICPPConstructor) }
} else if (binding instanceof ICPPConstructor) {
// before methods // before methods
return CPP_CONSTRUCTOR; return CPP_CONSTRUCTOR;
else if (binding instanceof ICPPMethod) } else if (binding instanceof ICPPMethod) {
// this must be before functions // this must be before functions
return CPPMETHOD; return CPPMETHOD;
else if (binding instanceof ICPPFunctionType) } else if (binding instanceof ICPPFunctionType) {
return CPP_FUNCTION_TYPE; return CPP_FUNCTION_TYPE;
else if (binding instanceof ICPPFunction) } else if (binding instanceof ICPPFunction) {
return CPPFUNCTION; return CPPFUNCTION;
else if (binding instanceof ICPPClassTemplate) } else if (binding instanceof ICPPClassTemplate) {
// this must be before class type // this must be before class type
return CPP_CLASS_TEMPLATE; return CPP_CLASS_TEMPLATE;
else if (binding instanceof ICPPClassType) } else if (binding instanceof ICPPClassType) {
return CPPCLASSTYPE; return CPPCLASSTYPE;
else if (binding instanceof ICPPNamespaceAlias) } else if (binding instanceof ICPPNamespaceAlias) {
return CPPNAMESPACEALIAS; return CPPNAMESPACEALIAS;
else if (binding instanceof ICPPNamespace) } else if (binding instanceof ICPPNamespace) {
return CPPNAMESPACE; return CPPNAMESPACE;
else if (binding instanceof ICPPUsingDeclaration) } else if (binding instanceof ICPPUsingDeclaration) {
return CPP_USING_DECLARATION; return CPP_USING_DECLARATION;
else if (binding instanceof IEnumeration) } else if (binding instanceof IEnumeration) {
return CPPENUMERATION; return CPPENUMERATION;
else if (binding instanceof IEnumerator) } else if (binding instanceof IEnumerator) {
return CPPENUMERATOR; return CPPENUMERATOR;
else if (binding instanceof ITypedef) } else if (binding instanceof ITypedef) {
return CPPTYPEDEF; return CPPTYPEDEF;
}
return 0; return 0;
} }
@ -576,7 +555,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
if (parent instanceof PDOMCPPNamespace) { if (parent instanceof PDOMCPPNamespace) {
int localToFileRec= getLocalToFileRec(parent, binding); int localToFileRec= getLocalToFileRec(parent, binding);
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding, localToFileRec); return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding,
localToFileRec);
} }
if (parent instanceof IPDOMMemberOwner) { if (parent instanceof IPDOMMemberOwner) {
int localToFileRec= getLocalToFileRec(parent, binding); int localToFileRec= getLocalToFileRec(parent, binding);
@ -610,6 +590,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (ib.isFileLocal()) { if (ib.isFileLocal()) {
return null; return null;
} }
if (scope == null && binding instanceof ICPPInternalUnknownClassType) {
return adaptBinding(((PDOMBinding) binding).getParentBinding());
}
// in an index the null scope represents global scope. // in an index the null scope represents global scope.
if (scope == null) { if (scope == null) {
return this; return this;
@ -633,7 +616,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
// the scope is from the ast // the scope is from the ast
if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) { if (scope instanceof ICPPTemplateScope &&
!(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
scope = scope.getParent(); scope = scope.getParent();
if (scope == null) { if (scope == null) {
return null; return null;
@ -867,12 +851,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMBinding derivedClassBinding= derivedClassName.getBinding(); PDOMBinding derivedClassBinding= derivedClassName.getBinding();
if (derivedClassBinding instanceof PDOMCPPClassType) { if (derivedClassBinding instanceof PDOMCPPClassType) {
PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding; PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility()); PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(),
baseNode.getVisibility());
ownerClass.addBase(pdomBase); ownerClass.addBase(pdomBase);
pdomName.setIsBaseSpecifier(true); pdomName.setIsBaseSpecifier(true);
} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) { } else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding; PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding;
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility()); PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(),
baseNode.getVisibility());
ownerClass.addBase(pdomBase); ownerClass.addBase(pdomBase);
pdomName.setIsBaseSpecifier(true); pdomName.setIsBaseSpecifier(true);
} }
@ -901,7 +887,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
if (doit) { if (doit) {
int rec= file.getFirstUsingDirectiveRec(); int rec= file.getFirstUsingDirectiveRec();
PDOMCPPUsingDirective ud= new PDOMCPPUsingDirective(this, rec, containerNS, pdomName.getBinding()); PDOMCPPUsingDirective ud= new PDOMCPPUsingDirective(this, rec, containerNS,
pdomName.getBinding());
file.setFirstUsingDirectiveRec(ud.getRecord()); file.setFirstUsingDirectiveRec(ud.getRecord());
} }
} catch (DOMException e) { } catch (DOMException e) {
@ -910,7 +897,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage#getUsingDirectives() * @see org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage#getUsingDirectives()
*/ */