mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 381824: Storing dependent bindings.
This commit is contained in:
parent
fd2a9be64c
commit
5fb5d5b437
75 changed files with 1805 additions and 1560 deletions
|
@ -60,7 +60,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
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.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
|
@ -336,7 +335,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
|
||||
// the instantiation of A<T> has to be deferred.
|
||||
assertInstance(b0, ICPPUnknownBinding.class);
|
||||
final ICPPBinding parent = ((ICPPInternalUnknownScope) b0.getScope()).getScopeBinding();
|
||||
final IType parent = ((ICPPInternalUnknownScope) b0.getScope()).getScopeType();
|
||||
assertInstance(parent, ICPPDeferredClassInstance.class);
|
||||
assertSame(((ICPPDeferredClassInstance) parent).getSpecializedBinding(), A);
|
||||
|
||||
|
|
|
@ -1777,10 +1777,6 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
assertEquals(1, bases.length);
|
||||
IBinding inst = bases[0].getBaseClass();
|
||||
assertTrue(inst instanceof ICPPTemplateInstance);
|
||||
|
||||
IIndexName name= (IIndexName) bases[0].getBaseClassSpecifierName();
|
||||
IBinding inst2= fIndex.findBinding(name);
|
||||
assertEquals(inst, inst2);
|
||||
} finally {
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
|
|
|
@ -2034,4 +2034,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testSFINAE_b() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// struct CString {
|
||||
// template<template<class,class> class ListT, class UType, class Alloc, typename StringT>
|
||||
// void split(ListT<UType,Alloc>& out, const StringT& sep, bool keepEmptyElements = false, bool trimElements = true, bool emptyBefore = true) const;
|
||||
// };
|
||||
|
||||
// template<template<class,class> class ListT, class UType, class Alloc, class StringT>
|
||||
// void CString::split(ListT<UType,Alloc>& out, const StringT& sep, bool keepEmptyElements, bool trimElements, bool emptyBefore) const {
|
||||
// }
|
||||
public void testMemberOfTemplateTemplateParameter_Bug381824() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
||||
|
@ -727,8 +727,8 @@ public class ASTTypeUtil {
|
|||
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
appendArgumentList(((ICPPTemplateInstance) binding).getTemplateArguments(), normalize, result);
|
||||
} else if (binding instanceof ICPPUnknownClassInstance) {
|
||||
appendArgumentList(((ICPPUnknownClassInstance) binding).getArguments(), normalize, result);
|
||||
} else if (binding instanceof ICPPUnknownMemberClassInstance) {
|
||||
appendArgumentList(((ICPPUnknownMemberClassInstance) binding).getArguments(), normalize, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@ package org.eclipse.cdt.core.dom.ast.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
|
||||
/**
|
||||
* Represents the relationship between a class and one of its base classes.
|
||||
|
@ -35,11 +37,24 @@ public interface ICPPBase extends Cloneable {
|
|||
public IBinding getBaseClass();
|
||||
|
||||
/**
|
||||
* Returns the name that specifies the base class.
|
||||
* @since 4.0
|
||||
* The base class. Generally a ICPPClassType, but may be an {@link ICPPUnknownType}.
|
||||
* In the case of typedefs, the target type will be returned instead of the typedef itself.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public IType getBaseClassType();
|
||||
|
||||
/**
|
||||
* @deprecated don't use it, a base class may be specified without the use of a name.
|
||||
*/
|
||||
@Deprecated
|
||||
public IName getBaseClassSpecifierName();
|
||||
|
||||
/**
|
||||
* Returns the name of the class definition that originally declares the base.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public IName getClassDefinitionName();
|
||||
|
||||
/**
|
||||
* The visibility qualifier applied to the base class.
|
||||
*
|
||||
|
@ -59,8 +74,13 @@ public interface ICPPBase extends Cloneable {
|
|||
|
||||
/**
|
||||
* Used internally to change cloned bases.
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void setBaseClass(IBinding baseClass);
|
||||
|
||||
/**
|
||||
* Used internally to change cloned bases.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void setBaseClass(IType baseClass);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ public interface ITypeMarshalBuffer {
|
|||
final static byte PROBLEM_TYPE= 9;
|
||||
final static byte VALUE= 10;
|
||||
final static byte DEPENDENT_EXPRESSION_TYPE= 11;
|
||||
final static byte UNKNOWN_MEMBER= 12;
|
||||
final static byte UNKNOWN_MEMBER_CLASS_INSTANCE= 13;
|
||||
final static byte DEFERRED_CLASS_INSTANCE= 14;
|
||||
|
||||
final static byte
|
||||
EVAL_BINARY= 1,
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
|
@ -175,7 +176,9 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
|
|||
if (method instanceof ICPPMethod) {
|
||||
ICPPClassType cls= ((ICPPMethod) method).getClassOwner();
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(cls, fdef)) {
|
||||
result.put(base.getBaseClassSpecifierName().getSimpleID());
|
||||
IType baseType= base.getBaseClassType();
|
||||
if (baseType instanceof IBinding)
|
||||
result.put(((IBinding) baseType).getNameCharArray());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
|
|||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
|
@ -24,33 +25,34 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
||||
public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
||||
private ICPPASTBaseSpecifier base;
|
||||
private IBinding baseClass;
|
||||
private final ICPPASTBaseSpecifier base;
|
||||
private IType baseClass;
|
||||
|
||||
public CPPBaseClause(ICPPASTBaseSpecifier base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getBaseClass()
|
||||
*/
|
||||
@Override
|
||||
public IBinding getBaseClass() {
|
||||
IType type= getBaseClassType();
|
||||
type = getNestedType(type, TDEF);
|
||||
if (type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getBaseClassType() {
|
||||
if (baseClass == null) {
|
||||
IBinding b = base.getName().resolveBinding();
|
||||
if (b instanceof IProblemBinding) {
|
||||
if (b instanceof IProblemBinding || ! (b instanceof IType)) {
|
||||
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID());
|
||||
} else {
|
||||
IType t= null;
|
||||
if (b instanceof IType) {
|
||||
t= getNestedType((IType) b, TDEF);
|
||||
}
|
||||
if (t instanceof ICPPClassType || t instanceof ICPPTemplateParameter) {
|
||||
baseClass = (IBinding) t;
|
||||
} else {
|
||||
baseClass= (IType) b;
|
||||
IType check= getNestedType(baseClass, TDEF);
|
||||
if (!(check instanceof ICPPClassType || check instanceof ICPPUnknownType)) {
|
||||
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ISemanticProblem.BINDING_NO_CLASS);
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +88,12 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
|||
|
||||
@Override
|
||||
public void setBaseClass(IBinding cls) {
|
||||
if (cls instanceof IType)
|
||||
baseClass = (IType) cls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseClass(IType cls) {
|
||||
baseClass = cls;
|
||||
}
|
||||
|
||||
|
@ -94,7 +102,19 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
|||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getClassDefinitionName()
|
||||
*/
|
||||
@Override
|
||||
public IName getClassDefinitionName() {
|
||||
IASTNode parent = base.getParent();
|
||||
if (parent instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
return ((ICPPASTCompositeTypeSpecifier) parent).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase clone() {
|
||||
ICPPBase t = null;
|
||||
try {
|
||||
|
|
|
@ -15,21 +15,32 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
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.ICPPClassTemplate;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPDeferredClassInstance;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Represents a instantiation that cannot be performed because of dependent arguments or an unknown template.
|
||||
*/
|
||||
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
|
||||
public class CPPDeferredClassInstance extends CPPUnknownBinding implements ICPPDeferredClassInstance, ISerializableType {
|
||||
private final ICPPTemplateArgument[] fArguments;
|
||||
private final ICPPClassTemplate fClassTemplate;
|
||||
private final ICPPScope fLookupScope;
|
||||
|
@ -38,7 +49,7 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
ICPPScope lookupScope) {
|
||||
// With template template parameters the owner must not be calculated, it'd lead to an infinite loop.
|
||||
// Rather than that we override getOwner().
|
||||
super(null, template.getNameCharArray());
|
||||
super(template.getNameCharArray());
|
||||
fArguments= arguments;
|
||||
fClassTemplate= template;
|
||||
fLookupScope= lookupScope;
|
||||
|
@ -94,6 +105,71 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
return getClassTemplate().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return IField.EMPTY_FIELD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField findField(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return ICPPField.EMPTY_CPPFIELD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IScope getCompositeScope() {
|
||||
return asScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
return ICPPClassType.EMPTY_CLASS_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnonymous() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
|
@ -148,4 +224,25 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
public String toString() {
|
||||
return ASTTypeUtil.getType(this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
int firstByte= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE;
|
||||
buffer.putByte((byte) firstByte);
|
||||
buffer.marshalBinding(fClassTemplate);
|
||||
buffer.putShort((short) fArguments.length);
|
||||
for (ICPPTemplateArgument arg : fArguments) {
|
||||
buffer.marshalTemplateArgument(arg);
|
||||
}
|
||||
}
|
||||
|
||||
public static ICPPDeferredClassInstance unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
IBinding template= buffer.unmarshalBinding();
|
||||
int argcount= buffer.getShort() & 0xffff;
|
||||
ICPPTemplateArgument[] args = new ICPPTemplateArgument[argcount];
|
||||
for (int i = 0; i < argcount; i++) {
|
||||
args[i]= buffer.unmarshalTemplateArgument();
|
||||
}
|
||||
return new PDOMCPPDeferredClassInstance(fragment, (ICPPClassTemplate) template, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,20 +23,25 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
|||
|
||||
/**
|
||||
* Represents a reference to a (member) function (instance), which cannot be resolved because
|
||||
* it depends on a template parameter. A compiler would resolve it during instantiation.
|
||||
* an argument depends on a template parameter. A compiler would resolve it during instantiation.
|
||||
*/
|
||||
public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunction {
|
||||
private static final ICPPFunctionType FUNCTION_TYPE= new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
||||
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction {
|
||||
private static final ICPPFunctionType FUNCTION_TYPE=
|
||||
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
||||
|
||||
public static ICPPFunction createForSample(IFunction sample) throws DOMException {
|
||||
if (sample instanceof ICPPConstructor)
|
||||
return new CPPUnknownConstructor(((ICPPConstructor) sample).getClassOwner());
|
||||
|
||||
return new CPPUnknownFunction(sample.getOwner(), sample.getNameCharArray());
|
||||
final IBinding owner = sample.getOwner();
|
||||
return new CPPDeferredFunction(owner, sample.getNameCharArray());
|
||||
}
|
||||
|
||||
public CPPUnknownFunction(IBinding owner, char[] name) {
|
||||
super(owner, name);
|
||||
private final IBinding fOwner;
|
||||
|
||||
public CPPDeferredFunction(IBinding owner, char[] name) {
|
||||
super(name);
|
||||
fOwner= owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,4 +123,9 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio
|
|||
public boolean hasParameterPack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getOwner() {
|
||||
return fOwner;
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
IASTNode[] nodes = getDeclarations();
|
||||
if (nodes != null && nodes.length > 0)
|
||||
n = (IASTName) nodes[0];
|
||||
unknownScope = new CPPUnknownScope(this, n);
|
||||
unknownScope = new CPPUnknownTypeScope(this, n);
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
@ -232,11 +232,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnonymous() {
|
||||
return false;
|
||||
|
|
|
@ -48,7 +48,7 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
IASTNode[] nodes = getDeclarations();
|
||||
if (nodes != null && nodes.length > 0)
|
||||
n = (IASTName) nodes[0];
|
||||
unknownScope = new CPPUnknownScope(this, n);
|
||||
unknownScope = new CPPUnknownTypeScope(this, n);
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
@ -92,9 +92,4 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
|
||||
return getParameterID() == ((ICPPTemplateParameter) type).getParameterID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -29,16 +28,14 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
/**
|
||||
* Represents a binding that is unknown because it depends on template arguments.
|
||||
*/
|
||||
public class CPPUnknownBinding extends PlatformObject
|
||||
public abstract class CPPUnknownBinding extends PlatformObject
|
||||
implements ICPPUnknownBinding, ICPPInternalBinding, Cloneable {
|
||||
protected IBinding fOwner;
|
||||
private ICPPScope unknownScope;
|
||||
protected IASTName name;
|
||||
protected char[] name;
|
||||
|
||||
public CPPUnknownBinding(IBinding owner, char[] name) {
|
||||
public CPPUnknownBinding(char[] name) {
|
||||
super();
|
||||
this.name = new CPPASTName(name);
|
||||
fOwner= owner;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,12 +73,12 @@ public class CPPUnknownBinding extends PlatformObject
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name.toString();
|
||||
return new String(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNameCharArray() {
|
||||
return name.getSimpleID();
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,12 +99,16 @@ public class CPPUnknownBinding extends PlatformObject
|
|||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope = new CPPUnknownScope(this, name);
|
||||
}
|
||||
if (unknownScope == null && this instanceof ICPPUnknownType) {
|
||||
unknownScope = createScope();
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new CPPUnknownTypeScope((ICPPUnknownType) this, new CPPASTName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
|
@ -126,14 +127,4 @@ public class CPPUnknownBinding extends PlatformObject
|
|||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getOwner() {
|
||||
return fOwner;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,21 +12,24 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownMemberClassInstance;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Represents a partially instantiated C++ class template, declaration of which is not yet available.
|
||||
*
|
||||
* @author Sergey Prigogin
|
||||
*/
|
||||
public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnknownClassInstance {
|
||||
public class CPPUnknownClassInstance extends CPPUnknownMemberClass implements ICPPUnknownMemberClassInstance {
|
||||
private final ICPPTemplateArgument[] arguments;
|
||||
|
||||
public CPPUnknownClassInstance(ICPPUnknownBinding scopeBinding, char[] name, ICPPTemplateArgument[] arguments) {
|
||||
public CPPUnknownClassInstance(IType scopeBinding, char[] name, ICPPTemplateArgument[] arguments) {
|
||||
super(scopeBinding, name);
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
@ -50,8 +53,8 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnkn
|
|||
return type.isSameType(this);
|
||||
}
|
||||
|
||||
if (type instanceof ICPPUnknownClassInstance) {
|
||||
ICPPUnknownClassInstance rhs= (ICPPUnknownClassInstance) type;
|
||||
if (type instanceof ICPPUnknownMemberClassInstance) {
|
||||
ICPPUnknownMemberClassInstance rhs= (ICPPUnknownMemberClassInstance) type;
|
||||
if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) {
|
||||
ICPPTemplateArgument[] lhsArgs= getArguments();
|
||||
ICPPTemplateArgument[] rhsArgs= rhs.getArguments();
|
||||
|
@ -67,13 +70,36 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnkn
|
|||
return false;
|
||||
}
|
||||
}
|
||||
final IBinding lhsContainer = getOwner();
|
||||
final IBinding rhsContainer = rhs.getOwner();
|
||||
if (lhsContainer instanceof IType && rhsContainer instanceof IType) {
|
||||
return (((IType)lhsContainer).isSameType((IType) rhsContainer));
|
||||
final IType lhsContainer = getOwnerType();
|
||||
final IType rhsContainer = rhs.getOwnerType();
|
||||
if (lhsContainer != null && rhsContainer != null) {
|
||||
return (lhsContainer.isSameType(rhsContainer));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE;
|
||||
buffer.putByte((byte) firstByte);
|
||||
buffer.marshalType(getOwnerType());
|
||||
buffer.putCharArray(getNameCharArray());
|
||||
buffer.putShort((short) arguments.length);
|
||||
for (ICPPTemplateArgument arg : arguments) {
|
||||
buffer.marshalTemplateArgument(arg);
|
||||
}
|
||||
}
|
||||
|
||||
public static ICPPUnknownMemberClassInstance unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
IType owner= buffer.unmarshalType();
|
||||
char[] name = buffer.getCharArray();
|
||||
int argcount= buffer.getShort() & 0xffff;
|
||||
ICPPTemplateArgument[] args = new ICPPTemplateArgument[argcount];
|
||||
for (int i = 0; i < argcount; i++) {
|
||||
args[i]= buffer.unmarshalTemplateArgument();
|
||||
}
|
||||
return new PDOMCPPUnknownMemberClassInstance(fragment, owner, name, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
* Represents a reference to a constructor (instance), which cannot be resolved because
|
||||
* it depends on a template parameter. A compiler would resolve it during instantiation.
|
||||
*/
|
||||
public class CPPUnknownConstructor extends CPPUnknownFunction implements ICPPConstructor {
|
||||
public class CPPUnknownConstructor extends CPPDeferredFunction implements ICPPConstructor {
|
||||
|
||||
public CPPUnknownConstructor(ICPPClassType owner) {
|
||||
super(owner, owner.getNameCharArray());
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
||||
/**
|
||||
* Represents a reference to a field, which cannot be resolved because the owner is
|
||||
* unknown. A compiler would resolve it during instantiation.
|
||||
*/
|
||||
public class CPPUnknownField extends CPPUnknownMember implements ICPPField {
|
||||
public CPPUnknownField(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return v_public;
|
||||
}
|
||||
@Override
|
||||
public ICPPClassType getClassOwner() {
|
||||
IType owner = getOwnerType();
|
||||
if (owner instanceof ICPPClassType)
|
||||
return (ICPPClassType) owner;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompositeType getCompositeTypeOwner() {
|
||||
IType owner = getOwnerType();
|
||||
if (owner instanceof ICompositeType)
|
||||
return (ICompositeType) owner;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue getInitialValue() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownField;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownMethod;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Represents a binding that is unknown because it depends on template arguments.
|
||||
*/
|
||||
public class CPPUnknownMember extends CPPUnknownBinding implements ICPPUnknownMember, ISerializableType {
|
||||
protected IType fOwner;
|
||||
|
||||
protected CPPUnknownMember(IType owner, char[] name) {
|
||||
super(name);
|
||||
fOwner= owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getOwner() {
|
||||
if (fOwner instanceof IBinding)
|
||||
return (IBinding) fOwner;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getOwnerType() {
|
||||
return fOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER;
|
||||
if (this instanceof ICPPField) {
|
||||
firstByte |= ITypeMarshalBuffer.FLAG1;
|
||||
} else if (this instanceof ICPPMethod) {
|
||||
firstByte |= ITypeMarshalBuffer.FLAG2;
|
||||
}
|
||||
|
||||
buffer.putByte((byte) firstByte);
|
||||
buffer.marshalType(getOwnerType());
|
||||
buffer.putCharArray(getNameCharArray());
|
||||
}
|
||||
|
||||
public static IBinding unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
IType owner= buffer.unmarshalType();
|
||||
char[] name = buffer.getCharArray();
|
||||
if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
|
||||
return new PDOMCPPUnknownField(fragment, owner, name);
|
||||
} else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
|
||||
return new PDOMCPPUnknownMethod(fragment, owner, name);
|
||||
}
|
||||
return new PDOMCPPUnknownMemberClass(fragment, owner, name);
|
||||
}
|
||||
}
|
|
@ -29,13 +29,12 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
/**
|
||||
* Represents a C++ class, declaration of which is not yet available.
|
||||
*/
|
||||
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownClassType {
|
||||
public static CPPUnknownClass createUnnamedInstance() {
|
||||
return new CPPUnknownClass(null, CharArrayUtils.EMPTY);
|
||||
public class CPPUnknownMemberClass extends CPPUnknownMember implements ICPPUnknownMemberClass {
|
||||
public static CPPUnknownMemberClass createUnnamedInstance() {
|
||||
return new CPPUnknownMemberClass(null, CharArrayUtils.EMPTY);
|
||||
}
|
||||
|
||||
public CPPUnknownClass(IBinding binding, char[] name) {
|
||||
super(binding, name);
|
||||
public CPPUnknownMemberClass(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,15 +100,13 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPUnknownCla
|
|||
if (type instanceof ITypedef)
|
||||
return type.isSameType(this);
|
||||
|
||||
if (type instanceof ICPPUnknownClassType
|
||||
&& !(type instanceof ICPPUnknownClassInstance)
|
||||
&& !(type instanceof ICPPDeferredClassInstance)) {
|
||||
ICPPUnknownClassType rhs= (ICPPUnknownClassType) type;
|
||||
if (type instanceof ICPPUnknownMemberClass && !(type instanceof ICPPUnknownMemberClassInstance)) {
|
||||
ICPPUnknownMemberClass rhs= (ICPPUnknownMemberClass) type;
|
||||
if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) {
|
||||
final IBinding lhsContainer = getOwner();
|
||||
final IBinding rhsContainer = rhs.getOwner();
|
||||
if (lhsContainer instanceof IType && rhsContainer instanceof IType) {
|
||||
return ((IType) lhsContainer).isSameType((IType) rhsContainer);
|
||||
final IType lhsContainer = getOwnerType();
|
||||
final IType rhsContainer = rhs.getOwnerType();
|
||||
if (lhsContainer != null && rhsContainer != null) {
|
||||
return lhsContainer.isSameType(rhsContainer);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
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.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
||||
/**
|
||||
* Represents a reference to a method (instance), which cannot be resolved because the owner is
|
||||
* unknown. A compiler would resolve it during instantiation.
|
||||
*/
|
||||
public class CPPUnknownMethod extends CPPUnknownMember implements ICPPMethod {
|
||||
private static final ICPPFunctionType FUNCTION_TYPE=
|
||||
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
||||
|
||||
public CPPUnknownMethod(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getFunctionScope() {
|
||||
return asScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPParameter[] getParameters() {
|
||||
return ICPPParameter.EMPTY_CPPPARAMETER_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPFunctionType getType() {
|
||||
return FUNCTION_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuto() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtern() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegister() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takesVarArgs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoReturn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredArgumentCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameterPack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return v_public;
|
||||
}
|
||||
@Override
|
||||
public ICPPClassType getClassOwner() {
|
||||
IType owner = getOwnerType();
|
||||
if (owner instanceof ICPPClassType)
|
||||
return (ICPPClassType) owner;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestructor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImplicit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplicit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPureVirtual() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOverride() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* Models the scope represented by an unknown binding such (e.g.: template type parameter). Used within
|
||||
* the context of templates, only.
|
||||
* For safe usage in index bindings, all fields need to be final or used in a thread-safe manner otherwise.
|
||||
*/
|
||||
public class CPPUnknownScope extends CPPUnknownTypeScope implements ICPPInternalUnknownScope {
|
||||
/**
|
||||
* This field needs to be protected when used in PDOMCPPUnknownScope,
|
||||
* don't use it outside of {@link #getOrCreateBinding(IASTName, int)}
|
||||
*/
|
||||
private CharArrayObjectMap<IBinding[]> map;
|
||||
|
||||
public CPPUnknownScope(ICPPUnknownBinding binding, IASTName name) {
|
||||
super(name, binding);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addName(IASTName name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBinding getOrCreateBinding(final char[] name, int idx) {
|
||||
if (map == null)
|
||||
map = new CharArrayObjectMap<IBinding[]>(2);
|
||||
|
||||
IBinding[] o = map.get(name);
|
||||
if (o == null) {
|
||||
o = new IBinding[3];
|
||||
map.put(name, o);
|
||||
}
|
||||
|
||||
IBinding result= o[idx];
|
||||
if (result == null) {
|
||||
result= super.getOrCreateBinding(name, idx);
|
||||
o[idx]= result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBinding(IBinding binding) {
|
||||
// do nothing, this is part of template magic and not a normal scope
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateCache() {}
|
||||
|
||||
@Override
|
||||
public void removeNestedFromCache(IASTNode container) {}
|
||||
}
|
|
@ -21,28 +21,33 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* Models the scope represented by an unknown type (e.g.: typeof(template type parameter)). Used within
|
||||
* the context of templates, only.
|
||||
* For safe usage in index bindings, all fields need to be final or used in a thread-safe manner otherwise.
|
||||
*/
|
||||
public class CPPUnknownTypeScope implements ICPPScope {
|
||||
public class CPPUnknownTypeScope implements ICPPInternalUnknownScope {
|
||||
private final IASTName fName;
|
||||
private final ICPPBinding fScopeBinding;
|
||||
private final IType fScopeType;
|
||||
/**
|
||||
* This field needs to be protected when used in PDOMCPPUnknownScope,
|
||||
* don't use it outside of {@link #getOrCreateBinding(IASTName, int)}
|
||||
*/
|
||||
private CharArrayObjectMap<IBinding[]> map;
|
||||
|
||||
public CPPUnknownTypeScope(IASTName name, ICPPBinding scopeBinding) {
|
||||
public CPPUnknownTypeScope(IType scopeType, IASTName name) {
|
||||
fName= name;
|
||||
fScopeBinding= scopeBinding;
|
||||
fScopeType= scopeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,6 +55,7 @@ public class CPPUnknownTypeScope implements ICPPScope {
|
|||
return EScopeKind.eClassType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTNode getPhysicalNode() {
|
||||
return fName;
|
||||
}
|
||||
|
@ -59,9 +65,16 @@ public class CPPUnknownTypeScope implements ICPPScope {
|
|||
return fName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getScopeType() {
|
||||
return fScopeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getParent() throws DOMException {
|
||||
return fScopeBinding == null ? null : fScopeBinding.getScope();
|
||||
if (fScopeType instanceof IBinding)
|
||||
return ((IBinding) fScopeType).getScope();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,6 +119,7 @@ public class CPPUnknownTypeScope implements ICPPScope {
|
|||
} else if (parent instanceof ICPPASTUsingDeclaration) {
|
||||
ICPPASTUsingDeclaration ud= (ICPPASTUsingDeclaration) parent;
|
||||
type= ud.isTypename();
|
||||
function= true;
|
||||
}
|
||||
|
||||
if (!type && parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
||||
|
@ -120,22 +134,6 @@ public class CPPUnknownTypeScope implements ICPPScope {
|
|||
return result;
|
||||
}
|
||||
|
||||
protected IBinding getOrCreateBinding(final char[] name, int idx) {
|
||||
IBinding result= null;
|
||||
switch (idx) {
|
||||
case 0:
|
||||
result= new CPPUnknownClass(fScopeBinding, name);
|
||||
break;
|
||||
case 1:
|
||||
result= new CPPUnknownFunction(fScopeBinding, name);
|
||||
break;
|
||||
case 2:
|
||||
result= new CPPUnknownBinding(fScopeBinding, name);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override @Deprecated
|
||||
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) {
|
||||
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
|
||||
|
@ -149,8 +147,8 @@ public class CPPUnknownTypeScope implements ICPPScope {
|
|||
@Override
|
||||
public final IBinding[] getBindings(ScopeLookupData lookup) {
|
||||
if (lookup.isPrefixLookup()) {
|
||||
if (fScopeBinding instanceof ICPPDeferredClassInstance) {
|
||||
ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) fScopeBinding;
|
||||
if (fScopeType instanceof ICPPDeferredClassInstance) {
|
||||
ICPPDeferredClassInstance instance = (ICPPDeferredClassInstance) fScopeType;
|
||||
IScope scope = instance.getClassTemplate().getCompositeScope();
|
||||
if (scope != null) {
|
||||
return scope.getBindings(lookup);
|
||||
|
@ -167,12 +165,52 @@ public class CPPUnknownTypeScope implements ICPPScope {
|
|||
return new IBinding[] {getOrCreateBinding(lookup.getLookupKey(), 0)};
|
||||
}
|
||||
|
||||
public ICPPBinding getScopeBinding() {
|
||||
return fScopeBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fName.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addName(IASTName name) {
|
||||
}
|
||||
|
||||
protected IBinding getOrCreateBinding(final char[] name, int idx) {
|
||||
if (map == null)
|
||||
map = new CharArrayObjectMap<IBinding[]>(2);
|
||||
|
||||
IBinding[] o = map.get(name);
|
||||
if (o == null) {
|
||||
o = new IBinding[3];
|
||||
map.put(name, o);
|
||||
}
|
||||
|
||||
IBinding result= o[idx];
|
||||
if (result == null) {
|
||||
switch (idx) {
|
||||
case 0:
|
||||
result= new CPPUnknownMemberClass(fScopeType, name);
|
||||
break;
|
||||
case 1:
|
||||
result= new CPPUnknownMethod(fScopeType, name);
|
||||
break;
|
||||
case 2:
|
||||
result= new CPPUnknownField(fScopeType, name);
|
||||
break;
|
||||
}
|
||||
o[idx]= result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBinding(IBinding binding) {
|
||||
// do nothing, this is part of template magic and not a normal scope
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateCache() {}
|
||||
|
||||
@Override
|
||||
public void removeNestedFromCache(IASTNode container) {}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,13 +12,14 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* Interface for deferred class template instances.
|
||||
*/
|
||||
public interface ICPPDeferredClassInstance extends ICPPUnknownClassType, ICPPTemplateInstance {
|
||||
public interface ICPPDeferredClassInstance extends ICPPUnknownBinding, ICPPUnknownType, ICPPClassType, ICPPTemplateInstance {
|
||||
/**
|
||||
* Returns the class template for the deferred instantiation.
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* Scope corresponding to an unknown binding.
|
||||
|
@ -21,5 +21,5 @@ public interface ICPPInternalUnknownScope extends ICPPASTInternalScope {
|
|||
/**
|
||||
* @return Returns the binding corresponding to the scope.
|
||||
*/
|
||||
public abstract ICPPBinding getScopeBinding();
|
||||
public IType getScopeType();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
|
||||
|
@ -26,10 +25,4 @@ public interface ICPPUnknownBinding extends ICPPBinding {
|
|||
* @throws DOMException
|
||||
*/
|
||||
public ICPPScope asScope() throws DOMException;
|
||||
|
||||
/**
|
||||
* Returns a the name of the unknown binding that has to be searched in the parent scope.
|
||||
* The ast-node may not be rooted in an ast-tree. May be <code>null</code>.
|
||||
*/
|
||||
public IASTName getUnknownName();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* Represents the binding for a dependent name within a template declaration.
|
||||
*/
|
||||
public interface ICPPUnknownMember extends ICPPUnknownBinding {
|
||||
/**
|
||||
* For unknown bindings the owner may just be an unknown type that is not yet resolved to a binding.
|
||||
*/
|
||||
public IType getOwnerType();
|
||||
}
|
|
@ -19,5 +19,5 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
* This interface should be made public.
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface ICPPUnknownClassType extends ICPPUnknownBinding, ICPPUnknownType, ICPPClassType {
|
||||
public interface ICPPUnknownMemberClass extends ICPPUnknownMember, ICPPUnknownType, ICPPClassType {
|
||||
}
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
|||
* This interface should be made public.
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface ICPPUnknownClassInstance extends ICPPUnknownClassType {
|
||||
public interface ICPPUnknownMemberClassInstance extends ICPPUnknownMemberClass {
|
||||
/**
|
||||
* Returns the arguments of the instantiation
|
||||
*/
|
|
@ -255,7 +255,7 @@ class BaseClassLookup {
|
|||
if (nbase instanceof IProblemBinding)
|
||||
continue;
|
||||
|
||||
final IName nbaseName = nbase.getBaseClassSpecifierName();
|
||||
final IName nbaseName = nbase.getClassDefinitionName();
|
||||
int cmp= baseName == null ? 0 : CPPSemantics.compareByRelevance(data, baseName, nbaseName);
|
||||
if (cmp <= 0) {
|
||||
if (cmp < 0) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPTwoPhaseBinding;
|
||||
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ public class CPPFunctionSet implements ICPPTwoPhaseBinding {
|
|||
|
||||
public void setToUnknown() {
|
||||
if (fName != null) {
|
||||
fName.setBinding(new CPPUnknownFunction(null, fName.toCharArray()));
|
||||
fName.setBinding(new CPPDeferredFunction(null, fName.toCharArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,6 +190,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBuiltinParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespace;
|
||||
|
@ -197,10 +198,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNamespaceScope;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownConstructor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDirective;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
|
@ -212,7 +212,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalNamespaceScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeSelection;
|
||||
|
@ -447,12 +446,12 @@ public class CPPSemantics {
|
|||
final ASTNodeProperty namePropertyInParent = name.getPropertyInParent();
|
||||
if (binding == null && data.skippedScope != null) {
|
||||
if (data.hasFunctionArguments()) {
|
||||
binding= new CPPUnknownFunction(data.skippedScope, name.getSimpleID());
|
||||
binding= new CPPDeferredFunction(data.skippedScope, name.getSimpleID());
|
||||
} else {
|
||||
if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) {
|
||||
binding= new CPPUnknownClass(data.skippedScope, name.getSimpleID());
|
||||
binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID());
|
||||
} else {
|
||||
binding= new CPPUnknownBinding(data.skippedScope, name.getSimpleID());
|
||||
binding= new CPPUnknownMethod(data.skippedScope, name.getSimpleID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2388,7 +2387,7 @@ public class CPPSemantics {
|
|||
if (viableCount == 1)
|
||||
return fns[0];
|
||||
setTargetedFunctionsToUnknown(argTypes);
|
||||
return CPPUnknownFunction.createForSample(fns[0]);
|
||||
return CPPDeferredFunction.createForSample(fns[0]);
|
||||
}
|
||||
|
||||
IFunction[] ambiguousFunctions= null; // ambiguity, 2 functions are equally good
|
||||
|
@ -2448,7 +2447,7 @@ public class CPPSemantics {
|
|||
return null;
|
||||
|
||||
setTargetedFunctionsToUnknown(argTypes);
|
||||
return CPPUnknownFunction.createForSample(unknownFunction);
|
||||
return CPPDeferredFunction.createForSample(unknownFunction);
|
||||
}
|
||||
|
||||
if (ambiguousFunctions != null) {
|
||||
|
@ -3096,7 +3095,7 @@ public class CPPSemantics {
|
|||
type = SemanticUtil.getNestedType(((ICPPVariable) binding).getType(), TDEF | CVTYPE);
|
||||
if (!(type instanceof ICPPClassType))
|
||||
return null;
|
||||
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownClassType || type instanceof ISemanticProblem)
|
||||
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
|
||||
return null;
|
||||
|
||||
final ICPPClassType classType = (ICPPClassType) type;
|
||||
|
@ -3676,9 +3675,8 @@ public class CPPSemantics {
|
|||
}
|
||||
|
||||
protected static IBinding resolveUnknownName(IScope scope, ICPPUnknownBinding unknown, IASTNode point) {
|
||||
final IASTName unknownName = unknown.getUnknownName();
|
||||
LookupData data = unknownName.getTranslationUnit() != null ?
|
||||
new LookupData(unknownName) : new LookupData(unknownName.getSimpleID(), null, point);
|
||||
final char[] unknownName = unknown.getNameCharArray();
|
||||
LookupData data = new LookupData(unknownName, null, point);
|
||||
data.setIgnorePointOfDeclaration(true);
|
||||
data.typesOnly= unknown instanceof IType;
|
||||
|
||||
|
@ -3701,7 +3699,7 @@ public class CPPSemantics {
|
|||
}
|
||||
// 4: Normal post processing is not possible, because the name is not rooted in AST
|
||||
if (binding == null)
|
||||
binding = new ProblemBinding(unknownName, point, IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
binding = new ProblemBinding(new CPPASTName(unknownName), point, IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.eclipse.cdt.core.dom.ast.IArrayType;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
|
@ -102,6 +101,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization;
|
||||
|
@ -112,6 +112,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorInstance;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization;
|
||||
|
@ -131,10 +132,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTemplateParameter
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclarationSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalTemplateDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
@ -143,8 +143,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMember;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
|
||||
|
@ -649,13 +650,11 @@ public class CPPTemplates {
|
|||
template= template.getOwner();
|
||||
}
|
||||
|
||||
if (template instanceof ICPPUnknownClassType) {
|
||||
IBinding owner= template.getOwner();
|
||||
if (owner instanceof ICPPUnknownBinding) {
|
||||
ICPPTemplateArgument[] args= createTemplateArgumentArray(id);
|
||||
args= SemanticUtil.getSimplifiedArguments(args);
|
||||
return new CPPUnknownClassInstance((ICPPUnknownBinding) template.getOwner(), id.getSimpleID(), args);
|
||||
}
|
||||
if (template instanceof ICPPUnknownMemberClass) {
|
||||
IType owner= ((ICPPUnknownMemberClass)template).getOwnerType();
|
||||
ICPPTemplateArgument[] args= createTemplateArgumentArray(id);
|
||||
args= SemanticUtil.getSimplifiedArguments(args);
|
||||
return new CPPUnknownClassInstance(owner, id.getSimpleID(), args);
|
||||
}
|
||||
|
||||
if (!(template instanceof ICPPClassTemplate) || template instanceof ICPPClassTemplatePartialSpecialization)
|
||||
|
@ -1143,29 +1142,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
if (type instanceof ICPPTemplateParameter) {
|
||||
final ICPPTemplateParameter tpar = (ICPPTemplateParameter) type;
|
||||
ICPPTemplateArgument arg= null;
|
||||
if (tpar.isParameterPack()) {
|
||||
if (packOffset >= 0) {
|
||||
ICPPTemplateArgument[] args = tpMap.getPackExpansion(tpar);
|
||||
if (args != null) {
|
||||
if (packOffset >= args.length) {
|
||||
return new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TYPE,
|
||||
tpar.getNameCharArray());
|
||||
}
|
||||
arg= args[packOffset];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
arg= tpMap.getArgument(tpar);
|
||||
}
|
||||
|
||||
if (arg != null) {
|
||||
IType t= arg.getTypeValue();
|
||||
if (t != null)
|
||||
return t;
|
||||
}
|
||||
return type;
|
||||
return resolveTemplateTypeParameter((ICPPTemplateParameter) type, tpMap, packOffset, point);
|
||||
}
|
||||
|
||||
if (type instanceof ICPPUnknownBinding) {
|
||||
|
@ -1266,6 +1243,32 @@ public class CPPTemplates {
|
|||
}
|
||||
}
|
||||
|
||||
public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) {
|
||||
ICPPTemplateArgument arg= null;
|
||||
if (tpar.isParameterPack()) {
|
||||
if (packOffset >= 0) {
|
||||
ICPPTemplateArgument[] args = tpMap.getPackExpansion(tpar);
|
||||
if (args != null) {
|
||||
if (packOffset >= args.length) {
|
||||
return new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TYPE,
|
||||
tpar.getNameCharArray());
|
||||
}
|
||||
arg= args[packOffset];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
arg= tpMap.getArgument(tpar);
|
||||
}
|
||||
|
||||
if (arg != null) {
|
||||
IType t= arg.getTypeValue();
|
||||
if (t != null)
|
||||
return t;
|
||||
}
|
||||
return (IType) tpar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given name corresponds to a template declaration and returns the AST node
|
||||
* for it. This works for the name of a template-definition and also for a name needed to
|
||||
|
@ -1700,11 +1703,11 @@ public class CPPTemplates {
|
|||
ICPPFunctionTemplate template= (ICPPFunctionTemplate) func;
|
||||
try {
|
||||
if (containsDependentType(fnArgs))
|
||||
return new ICPPFunction[] {CPPUnknownFunction.createForSample(template)};
|
||||
return new ICPPFunction[] {CPPDeferredFunction.createForSample(template)};
|
||||
|
||||
if (requireTemplate) {
|
||||
if (hasDependentArgument(tmplArgs))
|
||||
return new ICPPFunction[] {CPPUnknownFunction.createForSample(template)};
|
||||
return new ICPPFunction[] {CPPDeferredFunction.createForSample(template)};
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return NO_FUNCTIONS;
|
||||
|
@ -1776,7 +1779,7 @@ public class CPPTemplates {
|
|||
if (!checkedForDependentType) {
|
||||
try {
|
||||
if (isDependentType(conversionType)) {
|
||||
inst= CPPUnknownFunction.createForSample(template);
|
||||
inst= CPPDeferredFunction.createForSample(template);
|
||||
done= true;
|
||||
}
|
||||
checkedForDependentType= true;
|
||||
|
@ -1840,7 +1843,7 @@ public class CPPTemplates {
|
|||
ICPPTemplateArgument[] args, IASTNode point) {
|
||||
try {
|
||||
if (target != null && isDependentType(target)) {
|
||||
return CPPUnknownFunction.createForSample(template);
|
||||
return CPPDeferredFunction.createForSample(template);
|
||||
}
|
||||
|
||||
if (template instanceof ICPPConstructor || args == null)
|
||||
|
@ -2412,47 +2415,57 @@ public class CPPTemplates {
|
|||
if (unknown instanceof ICPPDeferredClassInstance) {
|
||||
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, packOffset, within, point);
|
||||
}
|
||||
if (unknown instanceof ICPPUnknownMember) {
|
||||
return resolveUnknownMember((ICPPUnknownMember) unknown, tpMap, packOffset, within, point);
|
||||
}
|
||||
if (unknown instanceof ICPPTemplateParameter && unknown instanceof IType) {
|
||||
IType type= resolveTemplateTypeParameter((ICPPTemplateParameter) unknown, tpMap, packOffset, point);
|
||||
if (type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
}
|
||||
return unknown;
|
||||
}
|
||||
|
||||
final IBinding owner= unknown.getOwner();
|
||||
if (!(owner instanceof ICPPTemplateTypeParameter || owner instanceof ICPPUnknownClassType))
|
||||
private static IBinding resolveUnknownMember(ICPPUnknownMember unknown, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) throws DOMException {
|
||||
final IType ot0= unknown.getOwnerType();
|
||||
if (ot0 == null)
|
||||
return unknown;
|
||||
|
||||
IBinding result = unknown;
|
||||
IType t = CPPTemplates.instantiateType((IType) owner, tpMap, packOffset, within, point);
|
||||
if (t != null) {
|
||||
t = SemanticUtil.getUltimateType(t, false);
|
||||
if (t instanceof ICPPUnknownBinding) {
|
||||
if (unknown instanceof ICPPUnknownClassInstance) {
|
||||
ICPPUnknownClassInstance ucli= (ICPPUnknownClassInstance) unknown;
|
||||
final ICPPTemplateArgument[] arguments = ucli.getArguments();
|
||||
ICPPTemplateArgument[] newArgs = CPPTemplates.instantiateArguments(arguments, tpMap, packOffset, within, point);
|
||||
if (!t.equals(owner) && newArgs != arguments) {
|
||||
newArgs= SemanticUtil.getSimplifiedArguments(newArgs);
|
||||
result= new CPPUnknownClassInstance((ICPPUnknownBinding) t, ucli.getNameCharArray(), newArgs);
|
||||
IType ot1 = CPPTemplates.instantiateType(ot0, tpMap, packOffset, within, point);
|
||||
if (ot1 != null) {
|
||||
ot1 = SemanticUtil.getUltimateType(ot1, false);
|
||||
if (ot1 instanceof ICPPUnknownType) {
|
||||
if (unknown instanceof ICPPUnknownMemberClassInstance) {
|
||||
ICPPUnknownMemberClassInstance ucli= (ICPPUnknownMemberClassInstance) unknown;
|
||||
ICPPTemplateArgument[] args0 = ucli.getArguments();
|
||||
ICPPTemplateArgument[] args1 = CPPTemplates.instantiateArguments(args0, tpMap, packOffset, within, point);
|
||||
if (args0 != args1 || !ot1.isSameType(ot0)) {
|
||||
args1= SemanticUtil.getSimplifiedArguments(args1);
|
||||
result= new CPPUnknownClassInstance(ot1, ucli.getNameCharArray(), args1);
|
||||
}
|
||||
} else if (!t.equals(owner)) {
|
||||
if (unknown instanceof ICPPUnknownClassType) {
|
||||
result= new CPPUnknownClass((ICPPUnknownBinding) t, unknown.getNameCharArray());
|
||||
} else if (unknown instanceof IFunction) {
|
||||
result= new CPPUnknownClass((ICPPUnknownBinding) t, unknown.getNameCharArray());
|
||||
} else if (!ot1.isSameType(ot0)) {
|
||||
if (unknown instanceof ICPPUnknownMemberClass) {
|
||||
result= new CPPUnknownMemberClass(ot1, unknown.getNameCharArray());
|
||||
} else {
|
||||
result= new CPPUnknownBinding((ICPPUnknownBinding) t, unknown.getNameCharArray());
|
||||
result= new CPPUnknownMethod(ot1, unknown.getNameCharArray());
|
||||
}
|
||||
}
|
||||
} else if (t instanceof ICPPClassType) {
|
||||
IScope s = ((ICPPClassType) t).getCompositeScope();
|
||||
} else if (ot1 instanceof ICPPClassType) {
|
||||
IScope s = ((ICPPClassType) ot1).getCompositeScope();
|
||||
if (s != null) {
|
||||
result= CPPSemantics.resolveUnknownName(s, unknown, point);
|
||||
if (unknown instanceof ICPPUnknownClassInstance && result instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateArgument[] newArgs = CPPTemplates.instantiateArguments(
|
||||
((ICPPUnknownClassInstance) unknown).getArguments(), tpMap, packOffset, within, point);
|
||||
if (unknown instanceof ICPPUnknownMemberClassInstance && result instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateArgument[] args1 = CPPTemplates.instantiateArguments(
|
||||
((ICPPUnknownMemberClassInstance) unknown).getArguments(), tpMap, packOffset, within, point);
|
||||
if (result instanceof ICPPClassTemplate) {
|
||||
result = instantiate((ICPPClassTemplate) result, newArgs, point);
|
||||
result = instantiate((ICPPClassTemplate) result, args1, point);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (t != owner) {
|
||||
return new ProblemBinding(unknown.getUnknownName(), point, IProblemBinding.SEMANTIC_BAD_SCOPE);
|
||||
} else if (ot1 != ot0) {
|
||||
return new ProblemBinding(new CPPASTName(unknown.getNameCharArray()), point, IProblemBinding.SEMANTIC_BAD_SCOPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,8 +236,6 @@ public class CPPVisitor extends ASTQueries {
|
|||
return new HashSet<IASTDeclSpecifier>();
|
||||
}
|
||||
};
|
||||
private static final ICPPScope UNKNOWN_TYPE_SCOPE = new CPPUnknownTypeScope(new CPPASTName("<unknown type>".toCharArray()), null); //$NON-NLS-1$
|
||||
|
||||
public static IBinding createBinding(IASTName name) {
|
||||
IASTNode parent = name.getParent();
|
||||
IBinding binding = null;
|
||||
|
@ -1227,7 +1225,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
} else if (type instanceof ICPPUnknownBinding) {
|
||||
return ((ICPPUnknownBinding) type).asScope();
|
||||
} else if (type instanceof ICPPUnknownType) {
|
||||
return UNKNOWN_TYPE_SCOPE;
|
||||
return new CPPUnknownTypeScope(type, null);
|
||||
} else {
|
||||
return new CPPScope.CPPScopeProblem(name, ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
@ -194,7 +194,7 @@ public class EvalMemberAccess extends CPPEvaluation {
|
|||
}
|
||||
|
||||
if (CPPTemplates.isDependentType(type))
|
||||
return returnUnnamed ? CPPUnknownClass.createUnnamedInstance() : null;
|
||||
return returnUnnamed ? CPPUnknownMemberClass.createUnnamedInstance() : null;
|
||||
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public interface IIndexCPPBindingConstants {
|
|||
int CPP_FRIEND_DECLARATION = IIndexBindingConstants.LAST_CONSTANT + 45;
|
||||
int CPP_TEMPLATE_TEMPLATE_PARAMETER= IIndexBindingConstants.LAST_CONSTANT + 46;
|
||||
int CPP_CLASS_TEMPLATE_PARTIAL_SPEC_SPEC = IIndexBindingConstants.LAST_CONSTANT + 47;
|
||||
int CPP_UNKNOWN_BINDING = IIndexBindingConstants.LAST_CONSTANT + 48;
|
||||
int CPP_UNKNOWN_FIELD = IIndexBindingConstants.LAST_CONSTANT + 48;
|
||||
int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49;
|
||||
int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public interface IIndexFragmentBinding extends IIndexBinding {
|
|||
IIndexFragmentBinding getOwner();
|
||||
|
||||
/**
|
||||
* Returns a unique id for the binding within the fragment
|
||||
* Returns a unique id for the binding within the fragment, or <code>null</code> for unknown bindings.
|
||||
* @since 5.1
|
||||
*/
|
||||
long getBindingID();
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -60,8 +60,8 @@ public class IndexCPPSignatureUtil {
|
|||
if (binding instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateInstance inst = (ICPPTemplateInstance) binding;
|
||||
buffer.append(getTemplateArgString(inst.getTemplateArguments(), true));
|
||||
} else if (binding instanceof ICPPUnknownClassInstance) {
|
||||
ICPPUnknownClassInstance inst = (ICPPUnknownClassInstance) binding;
|
||||
} else if (binding instanceof ICPPUnknownMemberClassInstance) {
|
||||
ICPPUnknownMemberClassInstance inst = (ICPPUnknownMemberClassInstance) binding;
|
||||
buffer.append(getTemplateArgString(inst.getArguments(), true));
|
||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
ICPPClassTemplatePartialSpecialization partial = (ICPPClassTemplatePartialSpecialization) binding;
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public abstract class AbstractCompositeFactory implements ICompositesFactory {
|
||||
protected IIndex index;
|
||||
private Comparator<IIndexFragmentBinding> fragmentComparator;
|
||||
private final Comparator<IIndexFragmentBinding> fragmentComparator;
|
||||
|
||||
public AbstractCompositeFactory(IIndex index) {
|
||||
this.index= index;
|
||||
|
@ -135,7 +135,7 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
|
|||
}
|
||||
|
||||
private static class FragmentBindingComparator implements Comparator<IIndexFragmentBinding> {
|
||||
private IIndexFragmentBindingComparator[] comparators;
|
||||
private final IIndexFragmentBindingComparator[] comparators;
|
||||
|
||||
FragmentBindingComparator(IIndexFragmentBindingComparator[] comparators) {
|
||||
this.comparators= comparators;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -67,10 +66,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMember;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinaryTypeId;
|
||||
|
@ -129,11 +128,6 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
}
|
||||
return new CompositeCPPNamespaceScope(this, namespaces);
|
||||
}
|
||||
if (rscope instanceof ICPPInternalUnknownScope) {
|
||||
ICPPInternalUnknownScope uscope= (ICPPInternalUnknownScope) rscope;
|
||||
final ICPPBinding binding = uscope.getScopeBinding();
|
||||
return new CompositeCPPUnknownScope((CompositeCPPBinding) getCompositeBinding((IIndexFragmentBinding) binding), (IASTName) uscope.getPhysicalNode());
|
||||
}
|
||||
throw new CompositingNotImplementedError(rscope.getClass().getName());
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
|
@ -334,7 +328,12 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
ICPPTemplateArgument[] c = e.getTemplateArgs();
|
||||
|
||||
ICPPEvaluation a2 = getCompositeEvaluation(a);
|
||||
IIndexBinding b2 = getCompositeBinding((IIndexFragmentBinding) b);
|
||||
IBinding b2= b;
|
||||
if (b instanceof IIndexFragmentBinding) {
|
||||
b2 = getCompositeBinding((IIndexFragmentBinding) b);
|
||||
} else if (b instanceof IType) {
|
||||
b2 = (IBinding) getCompositeType((IType) b);
|
||||
}
|
||||
ICPPTemplateArgument[] c2 = TemplateInstanceUtil.convert(this, c);
|
||||
|
||||
if (a != a2 || b != b2 || c != c2)
|
||||
|
@ -464,7 +463,13 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof ICPPSpecialization) {
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredClassInstance) {
|
||||
return new CompositeCPPDeferredClassInstance(this, (ICPPDeferredClassInstance) findOneBinding(binding));
|
||||
ICPPDeferredClassInstance def= (ICPPDeferredClassInstance) binding;
|
||||
ICPPClassTemplate t0= def.getClassTemplate();
|
||||
ICPPTemplateArgument[] args0= def.getTemplateArguments();
|
||||
|
||||
ICPPClassTemplate t= (ICPPClassTemplate) getCompositeType(t0);
|
||||
ICPPTemplateArgument[] args = TemplateInstanceUtil.convert(this, args0);
|
||||
return new CompositeCPPDeferredClassInstance(t, args);
|
||||
} else {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
return new CompositeCPPClassInstance(this, (ICPPClassType) findOneBinding(binding));
|
||||
|
@ -545,13 +550,24 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof ICPPVariable) {
|
||||
result = new CompositeCPPVariable(this, (ICPPVariable) binding);
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
if (binding instanceof ICPPUnknownClassInstance) {
|
||||
result = new CompositeCPPUnknownClassInstance(this, (ICPPUnknownClassInstance) binding);
|
||||
} else if (binding instanceof ICPPUnknownClassType) {
|
||||
result = new CompositeCPPUnknownClassType(this, (ICPPUnknownClassType) binding);
|
||||
} else {
|
||||
result= new CompositeCPPUnknownBinding(this, (ICPPUnknownBinding) binding);
|
||||
if (binding instanceof ICPPUnknownMember) {
|
||||
ICPPUnknownMember def= (ICPPUnknownMember) binding;
|
||||
IType b= getCompositeType(def.getOwnerType());
|
||||
if (binding instanceof ICPPUnknownMemberClass) {
|
||||
if (binding instanceof ICPPUnknownMemberClassInstance) {
|
||||
ICPPTemplateArgument[] args0= ((ICPPUnknownMemberClassInstance) binding).getArguments();
|
||||
ICPPTemplateArgument[] args = TemplateInstanceUtil.convert(this, args0);
|
||||
return new CompositeCPPUnknownMemberClassInstance(b, def.getNameCharArray(), args);
|
||||
} else {
|
||||
return new CompositeCPPUnknownMemberClass(b, def.getNameCharArray());
|
||||
}
|
||||
} else if (binding instanceof ICPPField) {
|
||||
return new CompositeCPPUnknownField(b, def.getNameCharArray());
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
return new CompositeCPPUnknownMethod(b, def.getNameCharArray());
|
||||
}
|
||||
}
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
ICPPClassType def = (ICPPClassType) findOneBinding(binding);
|
||||
result = def == null ? null : new CompositeCPPClassType(this, def);
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
|
@ -51,9 +54,9 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
}
|
||||
|
||||
private class CPPBaseDelegate implements ICPPBase {
|
||||
private ICPPBase base;
|
||||
private IBinding baseClass;
|
||||
private boolean writable;
|
||||
private final ICPPBase base;
|
||||
private IType baseClass;
|
||||
private final boolean writable;
|
||||
|
||||
CPPBaseDelegate(ICPPBase b) {
|
||||
this(b, false);
|
||||
|
@ -66,18 +69,31 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
|
||||
@Override
|
||||
public IBinding getBaseClass() {
|
||||
if (baseClass != null) {
|
||||
return baseClass;
|
||||
} else {
|
||||
return cf.getCompositeBinding((IIndexFragmentBinding) base.getBaseClass());
|
||||
}
|
||||
IType type= getBaseClassType();
|
||||
type = getNestedType(type, TDEF);
|
||||
if (type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getBaseClassType() {
|
||||
if (baseClass == null) {
|
||||
baseClass= cf.getCompositeType(base.getBaseClassType());
|
||||
}
|
||||
return baseClass;
|
||||
}
|
||||
|
||||
@Override @Deprecated
|
||||
public IName getBaseClassSpecifierName() {
|
||||
return base.getBaseClassSpecifierName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IName getClassDefinitionName() {
|
||||
return base.getClassDefinitionName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return base.getVisibility();
|
||||
|
@ -90,6 +106,15 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
|
||||
@Override
|
||||
public void setBaseClass(IBinding binding) {
|
||||
if (writable && binding instanceof IType) {
|
||||
baseClass= (IType) binding;
|
||||
} else {
|
||||
base.setBaseClass(binding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseClass(IType binding) {
|
||||
if (writable) {
|
||||
baseClass= binding;
|
||||
} else {
|
||||
|
|
|
@ -1,102 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType implements ICPPDeferredClassInstance {
|
||||
|
||||
private ICPPScope unknownScope;
|
||||
|
||||
public CompositeCPPDeferredClassInstance(ICompositesFactory cf, ICPPDeferredClassInstance rbinding) {
|
||||
super(cf, rbinding);
|
||||
public class CompositeCPPDeferredClassInstance extends CPPDeferredClassInstance implements IIndexBinding {
|
||||
public CompositeCPPDeferredClassInstance(ICPPClassTemplate template, ICPPTemplateArgument[] args) {
|
||||
super(template, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
ICPPTemplateDefinition preresult= ((ICPPTemplateInstance)rbinding).getTemplateDefinition();
|
||||
return (ICPPTemplateDefinition) cf.getCompositeBinding((IIndexFragmentBinding)preresult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return TemplateInstanceUtil.getTemplateParameterMap(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getSpecializedBinding() {
|
||||
return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return ((ICPPDeferredClassInstance) rbinding).getUnknownName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope getCompositeScope() {
|
||||
return asScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassTemplate getClassTemplate() {
|
||||
return (ICPPClassTemplate) cf.getCompositeBinding((IIndexFragmentBinding) ((ICPPDeferredClassInstance) rbinding).getClassTemplate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplicitSpecialization() {
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return TemplateInstanceUtil.getArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||
public IIndexBinding getOwner() {
|
||||
return (IIndexBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new CompositeCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -82,16 +81,11 @@ public class CompositeCPPTemplateTemplateParameter extends CompositeCPPBinding
|
|||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
unknownScope= new CompositeCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
try {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
@ -72,16 +71,11 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
|||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
unknownScope= new CompositeCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
try {
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCPPUnknownBinding extends CompositeCPPBinding implements ICPPUnknownBinding {
|
||||
public CompositeCPPUnknownBinding(ICompositesFactory cf, ICPPUnknownBinding rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return ((ICPPUnknownBinding) rbinding).getUnknownName();
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
/**
|
||||
* @author Sergey Prigogin
|
||||
*/
|
||||
class CompositeCPPUnknownClassInstance extends CompositeCPPUnknownClassType
|
||||
implements ICPPUnknownClassInstance {
|
||||
|
||||
public CompositeCPPUnknownClassInstance(ICompositesFactory cf,
|
||||
ICPPUnknownClassInstance rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument[] getArguments() {
|
||||
ICPPTemplateArgument[] arguments = ((ICPPUnknownClassInstance) rbinding).getArguments();
|
||||
return TemplateInstanceUtil.convert(cf, arguments);
|
||||
}
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
||||
class CompositeCPPUnknownClassType extends CompositeCPPUnknownBinding implements ICPPUnknownClassType, IIndexType {
|
||||
private ICPPScope unknownScope;
|
||||
|
||||
public CompositeCPPUnknownClassType(ICompositesFactory cf, ICPPUnknownClassType rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField findField(String name) {
|
||||
IField preResult = ((ICPPClassType) rbinding).findField(name);
|
||||
return (IField) cf.getCompositeBinding((IIndexFragmentBinding)preResult);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
||||
*/
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||
*/
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return IField.EMPTY_FIELD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
||||
*/
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return ICPPField.EMPTY_CPPFIELD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
||||
*/
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
||||
*/
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
||||
*/
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
|
||||
*/
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
||||
*/
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
ICPPClassType[] result = ((ICPPClassType) rbinding).getNestedClasses();
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getCompositeScope() {
|
||||
return new CompositeCPPClassScope(cf, rbinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKey() {
|
||||
return ((ICPPClassType) rbinding).getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
return ((ICPPClassType) rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnonymous() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownField;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CompositeCPPUnknownField extends CPPUnknownField implements IIndexBinding {
|
||||
public CompositeCPPUnknownField(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CompositeCPPUnknownMemberClass extends CPPUnknownMemberClass implements IIndexBinding {
|
||||
public CompositeCPPUnknownMemberClass(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexBinding getOwner() {
|
||||
return (IIndexBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new CompositeCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CompositeCPPUnknownMemberClassInstance extends CPPUnknownClassInstance implements IIndexBinding {
|
||||
public CompositeCPPUnknownMemberClassInstance(IType owner, char[] name, ICPPTemplateArgument[] arguments) {
|
||||
super(owner, name, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexBinding getOwner() {
|
||||
return (IIndexBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new CompositeCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMethod;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CompositeCPPUnknownMethod extends CPPUnknownMethod implements IIndexBinding {
|
||||
public CompositeCPPUnknownMethod(IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,18 +10,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
|
||||
public class CompositeCPPUnknownScope extends CPPUnknownScope implements IIndexScope {
|
||||
private CompositeCPPBinding fBinding;
|
||||
public class CompositeCPPUnknownScope extends CPPUnknownTypeScope implements IIndexScope {
|
||||
|
||||
public CompositeCPPUnknownScope(CompositeCPPBinding binding, IASTName name) {
|
||||
super((ICPPUnknownBinding) binding, name);
|
||||
fBinding= binding;
|
||||
public CompositeCPPUnknownScope(IIndexBinding binding, IASTName name) {
|
||||
super((IType) binding, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,11 +31,15 @@ public class CompositeCPPUnknownScope extends CPPUnknownScope implements IIndexS
|
|||
|
||||
@Override
|
||||
public IIndexScope getParent() {
|
||||
return fBinding.getScope();
|
||||
try {
|
||||
return (IIndexScope) super.getParent();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeCPPBinding getScopeBinding() {
|
||||
return fBinding;
|
||||
public IIndexBinding getScopeBinding() {
|
||||
return (IIndexBinding) super.getScopeType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ class CompositeCPPUsingDeclaration extends CompositeCPPBinding implements ICPPUs
|
|||
IBinding[] delegates = ((ICPPUsingDeclaration) rbinding).getDelegates();
|
||||
IBinding[] composites = new IBinding[delegates.length];
|
||||
int j = 0;
|
||||
for (int i = 0; i < delegates.length; i++) {
|
||||
IBinding binding = delegates[i];
|
||||
for (IBinding binding : delegates) {
|
||||
if (binding instanceof IIndexFragmentBinding) {
|
||||
composites[j++] = cf.getCompositeBinding((IIndexFragmentBinding) binding);
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* #125.0# - Indexes for unresolved includes and files indexed with I/O errors. <<CDT 8.1>>
|
||||
* 126.0 - Dependent expressions, bug 299911.
|
||||
* 127.0 - Explicit virtual overrides, bug 380623.
|
||||
* 128.0 - Merged index affecting changes from the master branch.
|
||||
* 128.0 - Merged several index affecting changes from the master branch.
|
||||
*/
|
||||
private static final int MIN_SUPPORTED_VERSION= version(128, 0);
|
||||
private static final int MAX_SUPPORTED_VERSION= version(128, Short.MAX_VALUE);
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMFileSet implements IIndexFragmentFileSet {
|
||||
private HashSet<Long> fFileIDs= new HashSet<Long>();
|
||||
private final HashSet<Long> fFileIDs= new HashSet<Long>();
|
||||
|
||||
@Override
|
||||
public void add(IIndexFragmentFile fragFile) {
|
||||
|
@ -36,8 +36,11 @@ public class PDOMFileSet implements IIndexFragmentFileSet {
|
|||
|
||||
@Override
|
||||
public boolean containsFileOfLocalBinding(IIndexFragmentBinding fb) throws CoreException {
|
||||
PDOMBinding pdomBinding= (PDOMBinding) fb;
|
||||
return fFileIDs.contains(pdomBinding.getLocalToFileRec());
|
||||
if (fb instanceof PDOMBinding) {
|
||||
PDOMBinding pdomBinding= (PDOMBinding) fb;
|
||||
return fFileIDs.contains(pdomBinding.getLocalToFileRec());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -106,11 +106,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
return null;
|
||||
}
|
||||
|
||||
IType type= fLinkage.unmarshalType(this);
|
||||
if (type == null || type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
|
||||
throw unmarshallingError();
|
||||
return fLinkage.unmarshalBinding(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -102,7 +102,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
|||
return hasDeclaration != 0;
|
||||
}
|
||||
|
||||
public void addDeclaration(PDOMName name) throws CoreException {
|
||||
public final void addDeclaration(PDOMName name) throws CoreException {
|
||||
PDOMName first = getFirstDeclaration();
|
||||
if (first != null) {
|
||||
first.setPrevInBinding(name);
|
||||
|
@ -111,7 +111,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
|||
setFirstDeclaration(name);
|
||||
}
|
||||
|
||||
public void addDefinition(PDOMName name) throws CoreException {
|
||||
public final void addDefinition(PDOMName name) throws CoreException {
|
||||
PDOMName first = getFirstDefinition();
|
||||
if (first != null) {
|
||||
first.setPrevInBinding(name);
|
||||
|
@ -120,7 +120,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
|||
setFirstDefinition(name);
|
||||
}
|
||||
|
||||
public void addReference(PDOMName name) throws CoreException {
|
||||
public final void addReference(PDOMName name) throws CoreException {
|
||||
PDOMName first = getFirstReference();
|
||||
if (first != null) {
|
||||
first.setPrevInBinding(name);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
|
@ -39,6 +40,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayMap;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -386,15 +388,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
return getLinkageName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Usually bindings are added on behalf of a name, only. For unknown values or using declarations
|
||||
* we need to add further bindings.
|
||||
* @throws CoreException
|
||||
*/
|
||||
public PDOMBinding addPotentiallyUnknownBinding(IBinding binding) throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of global bindings for the given name.
|
||||
* @throws CoreException
|
||||
|
@ -432,6 +425,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
|
||||
public abstract PDOMBinding addTypeBinding(IBinding type) throws CoreException;
|
||||
public abstract IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException;
|
||||
public abstract IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException;
|
||||
public abstract ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer typeMarshalBuffer) throws CoreException;
|
||||
|
||||
public void storeType(long offset, IType type) throws CoreException {
|
||||
|
@ -497,6 +491,69 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
return new TypeMarshalBuffer(this, data).unmarshalType();
|
||||
}
|
||||
|
||||
public void storeBinding(long offset, IBinding binding) throws CoreException {
|
||||
final Database db= getDB();
|
||||
deleteBinding(db, offset);
|
||||
storeBinding(db, offset, binding);
|
||||
}
|
||||
|
||||
private void storeBinding(Database db, long offset, IBinding binding) throws CoreException {
|
||||
if (binding != null) {
|
||||
TypeMarshalBuffer bc= new TypeMarshalBuffer(this);
|
||||
bc.marshalBinding(binding);
|
||||
int len= bc.getPosition();
|
||||
if (len > 0) {
|
||||
if (len <= Database.TYPE_SIZE) {
|
||||
db.putBytes(offset, bc.getBuffer(), len);
|
||||
} else if (len <= Database.MAX_MALLOC_SIZE-2){
|
||||
long ptr= db.malloc(len+2);
|
||||
db.putShort(ptr, (short) len);
|
||||
db.putBytes(ptr+2, bc.getBuffer(), len);
|
||||
db.putByte(offset, TypeMarshalBuffer.INDIRECT_TYPE);
|
||||
db.putRecPtr(offset+2, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteBinding(Database db, long offset) throws CoreException {
|
||||
byte firstByte= db.getByte(offset);
|
||||
if (firstByte == TypeMarshalBuffer.INDIRECT_TYPE) {
|
||||
long ptr= db.getRecPtr(offset+2);
|
||||
clearBinding(db, offset);
|
||||
db.free(ptr);
|
||||
} else {
|
||||
clearBinding(db, offset);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearBinding(Database db, long offset) throws CoreException {
|
||||
db.clearBytes(offset, Database.TYPE_SIZE);
|
||||
}
|
||||
|
||||
public IBinding loadBinding(long offset) throws CoreException {
|
||||
final Database db= getDB();
|
||||
final byte firstByte= db.getByte(offset);
|
||||
byte[] data= null;
|
||||
switch(firstByte) {
|
||||
case TypeMarshalBuffer.INDIRECT_TYPE:
|
||||
long ptr= db.getRecPtr(offset+2);
|
||||
int len= db.getShort(ptr) & 0xffff;
|
||||
data= new byte[len];
|
||||
db.getBytes(ptr+2, data);
|
||||
break;
|
||||
case TypeMarshalBuffer.UNSTORABLE_TYPE:
|
||||
return new ProblemBinding(null, ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
case TypeMarshalBuffer.NULL_TYPE:
|
||||
return null;
|
||||
default:
|
||||
data= new byte[Database.TYPE_SIZE];
|
||||
db.getBytes(offset, data);
|
||||
break;
|
||||
}
|
||||
return new TypeMarshalBuffer(this, data).unmarshalBinding();
|
||||
}
|
||||
|
||||
public void storeTemplateArgument(long offset, ICPPTemplateArgument arg) throws CoreException {
|
||||
final Database db= getDB();
|
||||
deleteArgument(db, offset);
|
||||
|
|
|
@ -325,6 +325,10 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
|||
return addBinding(type, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a binding, first byte=" + buffer.getByte())); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
|
|
|
@ -11,13 +11,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -26,32 +31,31 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*/
|
||||
class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
|
||||
private static final int BASECLASS_SPECIFIER = 0;
|
||||
private static final int NEXTBASE = 4;
|
||||
private static final int FLAGS = 8;
|
||||
static final int CLASS_DEFINITION = 0;
|
||||
private static final int BASECLASS_TYPE = CLASS_DEFINITION + Database.PTR_SIZE;
|
||||
private static final int NEXTBASE = BASECLASS_TYPE + Database.TYPE_SIZE;
|
||||
private static final int FLAGS = NEXTBASE + Database.PTR_SIZE;
|
||||
|
||||
protected static final int RECORD_SIZE = 9;
|
||||
protected static final int RECORD_SIZE = FLAGS + 1;
|
||||
|
||||
private final PDOMLinkage linkage;
|
||||
private final long record;
|
||||
|
||||
private PDOMBinding fCachedBaseClass;
|
||||
private IType fCachedBaseClass;
|
||||
|
||||
public PDOMCPPBase(PDOMLinkage linkage, long record) {
|
||||
this.linkage = linkage;
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
public PDOMCPPBase(PDOMLinkage linkage, PDOMName baseClassSpec, boolean isVirtual, int visibility)
|
||||
throws CoreException {
|
||||
public PDOMCPPBase(PDOMLinkage linkage, ICPPBase base, PDOMName classDefName) throws CoreException {
|
||||
Database db = linkage.getDB();
|
||||
this.linkage = linkage;
|
||||
Database db = getDB();
|
||||
this.record = db.malloc(RECORD_SIZE);
|
||||
db.putRecPtr(record + CLASS_DEFINITION, classDefName.getRecord());
|
||||
linkage.storeType(record+BASECLASS_TYPE, base.getBaseClassType());
|
||||
|
||||
long baserec = baseClassSpec != null ? baseClassSpec.getRecord() : 0;
|
||||
db.putRecPtr(record + BASECLASS_SPECIFIER, baserec);
|
||||
|
||||
byte flags = (byte)(visibility | (isVirtual ? 4 : 0));
|
||||
byte flags = (byte)(base.getVisibility() | (base.isVirtual() ? 4 : 0));
|
||||
db.putByte(record + FLAGS, flags);
|
||||
}
|
||||
|
||||
|
@ -79,8 +83,13 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
|
|||
|
||||
@Override
|
||||
public PDOMName getBaseClassSpecifierName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PDOMName getClassDefinitionName() {
|
||||
try {
|
||||
long rec = getDB().getRecPtr(record + BASECLASS_SPECIFIER);
|
||||
long rec = getDB().getRecPtr(record + CLASS_DEFINITION);
|
||||
if (rec != 0) {
|
||||
return new PDOMName(linkage, rec);
|
||||
}
|
||||
|
@ -91,22 +100,23 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBinding getBaseClass() {
|
||||
if (fCachedBaseClass != null)
|
||||
return fCachedBaseClass;
|
||||
|
||||
try {
|
||||
PDOMName name= getBaseClassSpecifierName();
|
||||
if (name != null) {
|
||||
PDOMBinding b = name.getBinding();
|
||||
while (b instanceof PDOMCPPTypedef && ((PDOMCPPTypedef) b).getType() instanceof PDOMBinding) {
|
||||
b = (PDOMBinding) ((PDOMCPPTypedef) b).getType();
|
||||
}
|
||||
return fCachedBaseClass= b;
|
||||
public IType getBaseClassType() {
|
||||
if (fCachedBaseClass == null) {
|
||||
try {
|
||||
fCachedBaseClass= linkage.loadType(record + BASECLASS_TYPE);
|
||||
} catch (CoreException e) {
|
||||
fCachedBaseClass= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return fCachedBaseClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getBaseClass() {
|
||||
IType type= getBaseClassType();
|
||||
type = getNestedType(type, TDEF);
|
||||
if (type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -139,6 +149,10 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
|
|||
public void setBaseClass(IBinding binding) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@Override
|
||||
public void setBaseClass(IType binding) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase clone() {
|
||||
|
@ -146,23 +160,37 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
|
|||
}
|
||||
|
||||
private static class PDOMCPPBaseClone implements ICPPBase, ICPPInternalBase {
|
||||
private ICPPBase base;
|
||||
private IBinding baseClass = null;
|
||||
private final ICPPBase base;
|
||||
private IType baseClass = null;
|
||||
|
||||
public PDOMCPPBaseClone(ICPPBase base) {
|
||||
this.base = base;
|
||||
}
|
||||
@Override
|
||||
public IBinding getBaseClass() {
|
||||
IType type= getBaseClassType();
|
||||
type = getNestedType(type, TDEF);
|
||||
if (type instanceof IBinding)
|
||||
return (IBinding) type;
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IType getBaseClassType() {
|
||||
if (baseClass == null) {
|
||||
return base.getBaseClass();
|
||||
baseClass= base.getBaseClassType();
|
||||
}
|
||||
return baseClass;
|
||||
}
|
||||
@Override
|
||||
|
||||
@Override @Deprecated
|
||||
public IName getBaseClassSpecifierName() {
|
||||
return base.getBaseClassSpecifierName();
|
||||
}
|
||||
@Override
|
||||
public IName getClassDefinitionName() {
|
||||
return base.getClassDefinitionName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
return base.getVisibility();
|
||||
|
@ -173,6 +201,11 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
|
|||
}
|
||||
@Override
|
||||
public void setBaseClass(IBinding binding) {
|
||||
if (binding instanceof IType)
|
||||
baseClass = (IType) binding;
|
||||
}
|
||||
@Override
|
||||
public void setBaseClass(IType binding) {
|
||||
baseClass = binding;
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -188,33 +188,47 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
getDB().putRecPtr(record + FIRST_BASE, rec);
|
||||
}
|
||||
|
||||
public void addBase(PDOMCPPBase base) throws CoreException {
|
||||
getPDOM().removeCachedResult(record + PDOMCPPLinkage.CACHE_BASES);
|
||||
public void addBases(PDOMName classDefName, ICPPBase[] bases) throws CoreException {
|
||||
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
|
||||
final PDOMLinkage linkage = getLinkage();
|
||||
PDOMCPPBase firstBase = getFirstBase();
|
||||
base.setNextBase(firstBase);
|
||||
setFirstBase(base);
|
||||
for (ICPPBase base : bases) {
|
||||
PDOMCPPBase nextBase= new PDOMCPPBase(linkage, base, classDefName);
|
||||
nextBase.setNextBase(firstBase);
|
||||
firstBase= nextBase;
|
||||
}
|
||||
setFirstBase(firstBase);
|
||||
}
|
||||
|
||||
public void removeBase(PDOMName pdomName) throws CoreException {
|
||||
getPDOM().removeCachedResult(record + PDOMCPPLinkage.CACHE_BASES);
|
||||
public void removeBases(PDOMName classDefName) throws CoreException {
|
||||
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
|
||||
PDOMCPPBase base= getFirstBase();
|
||||
PDOMCPPBase predecessor= null;
|
||||
long nameRec= pdomName.getRecord();
|
||||
long nameRec= classDefName.getRecord();
|
||||
boolean deleted= false;
|
||||
while (base != null) {
|
||||
PDOMName name = base.getBaseClassSpecifierName();
|
||||
if (name != null && name.getRecord() == nameRec) {
|
||||
break;
|
||||
PDOMCPPBase nextBase = base.getNextBase();
|
||||
long classDefRec= getDB().getRecPtr(base.getRecord() + PDOMCPPBase.CLASS_DEFINITION);
|
||||
if (classDefRec == nameRec) {
|
||||
deleted= true;
|
||||
base.delete();
|
||||
} else if (deleted) {
|
||||
deleted= false;
|
||||
if (predecessor == null) {
|
||||
setFirstBase(base);
|
||||
} else {
|
||||
predecessor.setNextBase(base);
|
||||
}
|
||||
predecessor= base;
|
||||
}
|
||||
predecessor= base;
|
||||
base= base.getNextBase();
|
||||
base= nextBase;
|
||||
}
|
||||
if (base != null) {
|
||||
if (predecessor != null) {
|
||||
predecessor.setNextBase(base.getNextBase());
|
||||
if (deleted) {
|
||||
if (predecessor == null) {
|
||||
setFirstBase(null);
|
||||
} else {
|
||||
setFirstBase(base.getNextBase());
|
||||
predecessor.setNextBase(null);
|
||||
}
|
||||
base.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,34 +142,47 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
|||
getDB().putRecPtr(record + FIRSTBASE, rec);
|
||||
}
|
||||
|
||||
public void addBase(PDOMCPPBase base) throws CoreException {
|
||||
public void addBases(PDOMName classDefName, ICPPBase[] bases) throws CoreException {
|
||||
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
|
||||
final PDOMLinkage linkage = getLinkage();
|
||||
PDOMCPPBase firstBase = getFirstBase();
|
||||
base.setNextBase(firstBase);
|
||||
setFirstBase(base);
|
||||
for (ICPPBase base : bases) {
|
||||
PDOMCPPBase nextBase= new PDOMCPPBase(linkage, base, classDefName);
|
||||
nextBase.setNextBase(firstBase);
|
||||
firstBase= nextBase;
|
||||
}
|
||||
setFirstBase(firstBase);
|
||||
}
|
||||
|
||||
public void removeBase(PDOMName pdomName) throws CoreException {
|
||||
public void removeBases(PDOMName classDefName) throws CoreException {
|
||||
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
|
||||
|
||||
PDOMCPPBase base= getFirstBase();
|
||||
PDOMCPPBase predecessor= null;
|
||||
long nameRec= pdomName.getRecord();
|
||||
long nameRec= classDefName.getRecord();
|
||||
boolean deleted= false;
|
||||
while (base != null) {
|
||||
PDOMName name = base.getBaseClassSpecifierName();
|
||||
if (name != null && name.getRecord() == nameRec) {
|
||||
break;
|
||||
PDOMCPPBase nextBase = base.getNextBase();
|
||||
long classDefRec= getDB().getRecPtr(base.getRecord() + PDOMCPPBase.CLASS_DEFINITION);
|
||||
if (classDefRec == nameRec) {
|
||||
deleted= true;
|
||||
base.delete();
|
||||
} else if (deleted) {
|
||||
deleted= false;
|
||||
if (predecessor == null) {
|
||||
setFirstBase(base);
|
||||
} else {
|
||||
predecessor.setNextBase(base);
|
||||
}
|
||||
predecessor= base;
|
||||
}
|
||||
predecessor= base;
|
||||
base= base.getNextBase();
|
||||
base= nextBase;
|
||||
}
|
||||
if (base != null) {
|
||||
if (predecessor != null) {
|
||||
predecessor.setNextBase(base.getNextBase());
|
||||
if (deleted) {
|
||||
if (predecessor == null) {
|
||||
setFirstBase(null);
|
||||
} else {
|
||||
setFirstBase(base.getNextBase());
|
||||
predecessor.setNextBase(null);
|
||||
}
|
||||
base.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,253 +1,88 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2012 QNX Software Systems and others.
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Deferred class instances collect information about an instantiation until it can be
|
||||
* carried out.
|
||||
*/
|
||||
class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization
|
||||
implements ICPPDeferredClassInstance, IPDOMMemberOwner, IIndexType {
|
||||
private static final int MEMBERLIST = PDOMCPPSpecialization.RECORD_SIZE + 0;
|
||||
private static final int ARGUMENTS = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPDeferredClassInstance record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8;
|
||||
public class PDOMCPPDeferredClassInstance extends CPPDeferredClassInstance implements IIndexFragmentBinding {
|
||||
private final IIndexFragment fFragment;
|
||||
|
||||
private PDOMCPPUnknownScope unknownScope; // No need for volatile, PDOMCPPUnknownScope protects its fields.
|
||||
|
||||
public PDOMCPPDeferredClassInstance(PDOMLinkage linkage, PDOMNode parent,
|
||||
ICPPDeferredClassInstance classType, PDOMBinding instantiated) throws CoreException {
|
||||
super(linkage, parent, classType, instantiated);
|
||||
|
||||
final ICPPTemplateArgument[] args= classType.getTemplateArguments();
|
||||
final long argListRec= PDOMCPPArgumentList.putArguments(this, args);
|
||||
getDB().putRecPtr(record + ARGUMENTS, argListRec);
|
||||
}
|
||||
|
||||
public PDOMCPPDeferredClassInstance(PDOMLinkage linkage, long bindingRecord) {
|
||||
super(linkage, bindingRecord);
|
||||
public PDOMCPPDeferredClassInstance(IIndexFragment frag, ICPPClassTemplate template, ICPPTemplateArgument[] args) {
|
||||
super(template, args);
|
||||
fFragment= frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragment getFragment() {
|
||||
return fFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefinition() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaration() throws CoreException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBindingConstant() {
|
||||
return IIndexCPPBindingConstants.CPP_DEFERRED_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplicitSpecialization() {
|
||||
return false;
|
||||
public long getBindingID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getCompositeScope() {
|
||||
return asScope();
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof ITypedef) {
|
||||
return type.isSameType(this);
|
||||
}
|
||||
if (type instanceof PDOMNode) {
|
||||
PDOMNode node = (PDOMNode) type;
|
||||
if (node.getPDOM() == getPDOM()) {
|
||||
return node.getRecord() == getRecord();
|
||||
}
|
||||
}
|
||||
|
||||
ICPPClassTemplate classTemplate = getClassTemplate();
|
||||
|
||||
if (type instanceof ICPPDeferredClassInstance) {
|
||||
final ICPPDeferredClassInstance rhs = (ICPPDeferredClassInstance) type;
|
||||
if (!classTemplate.isSameType((IType) rhs.getSpecializedBinding()))
|
||||
return false;
|
||||
|
||||
return CPPTemplates.haveSameArguments(this, rhs);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassTemplate getClassTemplate() {
|
||||
return (ICPPClassTemplate) getSpecializedBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
|
||||
list.addMember(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
super.accept(visitor);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return IField.EMPTY_FIELD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField findField(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return ICPPField.EMPTY_CPPFIELD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
return ICPPClassType.EMPTY_CLASS_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKey(){
|
||||
return getClassTemplate().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new PDOMCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateDefinition getTemplateDefinition() {
|
||||
return (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return getClassTemplate().isFinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS);
|
||||
return PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnonymous() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
ICPPTemplateParameter[] params = getClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args = getTemplateArguments();
|
||||
int size = Math.min(args.length, params.length);
|
||||
CPPTemplateParameterMap map = new CPPTemplateParameterMap(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
map.put(params[i], args[i]);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new PDOMCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
|
@ -40,7 +41,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
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.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ICPPClassTemplatePartialSpecializationSpecialization;
|
||||
|
@ -76,17 +79,18 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinaryTypeId;
|
||||
|
@ -261,11 +265,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return pdomBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PDOMBinding addPotentiallyUnknownBinding(IBinding binding) throws CoreException {
|
||||
return addBinding(binding, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or returns existing binding for the given one. If <code>fromName</code> is not <code>null</code>
|
||||
* then an existing binding is updated with the properties of the name.
|
||||
|
@ -352,6 +351,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
// template parameters are created directly by their owners.
|
||||
if (binding instanceof ICPPTemplateParameter)
|
||||
return null;
|
||||
if (binding instanceof ICPPUnknownBinding)
|
||||
return null;
|
||||
|
||||
if (binding instanceof ICPPSpecialization) {
|
||||
IBinding specialized = ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||
|
@ -367,15 +368,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else if (binding instanceof ICPPClassTemplate) {
|
||||
pdomBinding= new PDOMCPPClassTemplate(this, parent, (ICPPClassTemplate) binding);
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
if (binding instanceof ICPPUnknownClassInstance) {
|
||||
pdomBinding= new PDOMCPPUnknownClassInstance(this, parent, (ICPPUnknownClassInstance) binding);
|
||||
} else if (binding instanceof ICPPUnknownClassType) {
|
||||
pdomBinding= new PDOMCPPUnknownClassType(this, parent, (ICPPUnknownClassType) binding);
|
||||
} else {
|
||||
pdomBinding= new PDOMCPPClassType(this, parent, (ICPPClassType) binding);
|
||||
}
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
pdomBinding= new PDOMCPPUnknownBinding(this, parent, (ICPPUnknownBinding) binding);
|
||||
pdomBinding= new PDOMCPPClassType(this, parent, (ICPPClassType) binding);
|
||||
} else if (binding instanceof ICPPVariable) {
|
||||
ICPPVariable var= (ICPPVariable) binding;
|
||||
pdomBinding = new PDOMCPPVariable(this, parent, var);
|
||||
|
@ -443,11 +436,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
private PDOMBinding createSpecialization(PDOMNode parent, PDOMBinding orig, IBinding special)
|
||||
throws CoreException, DOMException {
|
||||
PDOMBinding result= null;
|
||||
if (special instanceof ICPPDeferredClassInstance) {
|
||||
if (orig instanceof ICPPClassTemplate) {
|
||||
result= new PDOMCPPDeferredClassInstance(this, parent, (ICPPDeferredClassInstance) special, orig);
|
||||
}
|
||||
} else if (special instanceof ICPPTemplateInstance) {
|
||||
if (special instanceof ICPPTemplateInstance) {
|
||||
if (special instanceof ICPPConstructor && orig instanceof ICPPConstructor) {
|
||||
result= new PDOMCPPConstructorInstance(this, parent, (ICPPConstructor) special, orig);
|
||||
} else if (special instanceof ICPPMethod && orig instanceof ICPPMethod) {
|
||||
|
@ -527,7 +516,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (binding instanceof ICPPSpecialization) {
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredClassInstance) {
|
||||
return CPP_DEFERRED_CLASS_INSTANCE;
|
||||
return 0;
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
return CPP_CONSTRUCTOR_INSTANCE;
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
|
@ -594,11 +583,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else if (binding instanceof ICPPFunction) {
|
||||
return CPPFUNCTION;
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
if (binding instanceof ICPPUnknownClassInstance) {
|
||||
return CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
} else if (binding instanceof ICPPUnknownClassType) {
|
||||
return CPP_UNKNOWN_CLASS_TYPE;
|
||||
}
|
||||
return 0;
|
||||
} else if (binding instanceof ICPPClassTemplate) {
|
||||
// this must be before class type
|
||||
return CPP_CLASS_TEMPLATE;
|
||||
|
@ -812,14 +797,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return new PDOMCPPConstructorInstance(this, record);
|
||||
case CPP_CLASS_INSTANCE:
|
||||
return new PDOMCPPClassInstance(this, record);
|
||||
case CPP_DEFERRED_CLASS_INSTANCE:
|
||||
return new PDOMCPPDeferredClassInstance(this, record);
|
||||
case CPP_UNKNOWN_BINDING:
|
||||
return new PDOMCPPUnknownBinding(this, record);
|
||||
case CPP_UNKNOWN_CLASS_TYPE:
|
||||
return new PDOMCPPUnknownClassType(this, record);
|
||||
case CPP_UNKNOWN_CLASS_INSTANCE:
|
||||
return new PDOMCPPUnknownClassInstance(this, record);
|
||||
case CPP_TEMPLATE_TYPE_PARAMETER:
|
||||
return new PDOMCPPTemplateTypeParameter(this, record);
|
||||
case CPP_TEMPLATE_TEMPLATE_PARAMETER:
|
||||
|
@ -869,24 +846,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
parentNode = parentNode.getParent();
|
||||
}
|
||||
if (parentNode instanceof ICPPASTBaseSpecifier) {
|
||||
PDOMName derivedClassName= (PDOMName) pdomName.getEnclosingDefinition();
|
||||
if (derivedClassName != null) {
|
||||
ICPPASTBaseSpecifier baseNode= (ICPPASTBaseSpecifier) parentNode;
|
||||
PDOMBinding derivedClassBinding= derivedClassName.getBinding();
|
||||
if (derivedClassBinding instanceof PDOMCPPClassType) {
|
||||
PDOMCPPClassType ownerClass = (PDOMCPPClassType) derivedClassBinding;
|
||||
PDOMCPPBase pdomBase = new PDOMCPPBase(this, pdomName, baseNode.isVirtual(),
|
||||
baseNode.getVisibility());
|
||||
ownerClass.addBase(pdomBase);
|
||||
pdomName.setIsBaseSpecifier();
|
||||
} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
|
||||
PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization) derivedClassBinding;
|
||||
PDOMCPPBase pdomBase = new PDOMCPPBase(this, pdomName, baseNode.isVirtual(),
|
||||
baseNode.getVisibility());
|
||||
ownerClass.addBase(pdomBase);
|
||||
pdomName.setIsBaseSpecifier();
|
||||
}
|
||||
}
|
||||
pdomName.setIsBaseSpecifier();
|
||||
} else if (parentNode instanceof ICPPASTUsingDirective) {
|
||||
IASTNode parent= name.getParent();
|
||||
if (parent instanceof ICPPASTQualifiedName) {
|
||||
|
@ -899,8 +859,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
IASTNode node= ASTInternal.getPhysicalNodeOfScope(container);
|
||||
if (node instanceof IASTTranslationUnit) {
|
||||
doit= true;
|
||||
}
|
||||
else if (node instanceof ICPPASTNamespaceDefinition) {
|
||||
} else if (node instanceof ICPPASTNamespaceDefinition) {
|
||||
ICPPASTNamespaceDefinition nsDef= (ICPPASTNamespaceDefinition) node;
|
||||
IASTName nsContainerName= nsDef.getName();
|
||||
if (nsContainerName != null) {
|
||||
|
@ -950,6 +909,24 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (nsdef.isInline()) {
|
||||
pdomName.setIsInlineNamespace();
|
||||
}
|
||||
} else if (parentNode instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
IBinding classBinding = name.resolveBinding();
|
||||
if (classBinding instanceof ICPPClassType) {
|
||||
ICPPBase[] bases;
|
||||
if (classBinding instanceof ICPPClassSpecialization) {
|
||||
bases= ((ICPPClassSpecialization) classBinding).getBases(name);
|
||||
} else {
|
||||
bases= ((ICPPClassType) classBinding).getBases();
|
||||
}
|
||||
if (bases.length > 0) {
|
||||
PDOMBinding pdomBinding = pdomName.getBinding();
|
||||
if (pdomBinding instanceof PDOMCPPClassType) {
|
||||
((PDOMCPPClassType) pdomBinding).addBases(pdomName, bases);
|
||||
} else if (pdomBinding instanceof PDOMCPPClassSpecialization) {
|
||||
((PDOMCPPClassSpecialization) pdomBinding).addBases(pdomName, bases);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -972,20 +949,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
@Override
|
||||
public void onDeleteName(PDOMName pdomName) throws CoreException {
|
||||
super.onDeleteName(pdomName);
|
||||
|
||||
if (pdomName.isBaseSpecifier()) {
|
||||
PDOMName derivedClassName= (PDOMName) pdomName.getEnclosingDefinition();
|
||||
if (derivedClassName != null) {
|
||||
PDOMBinding derivedClassBinding= derivedClassName.getBinding();
|
||||
if (derivedClassBinding instanceof PDOMCPPClassType) {
|
||||
PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
|
||||
ownerClass.removeBase(pdomName);
|
||||
} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
|
||||
PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding;
|
||||
ownerClass.removeBase(pdomName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pdomName.isFriendSpecifier()) {
|
||||
PDOMName enclClassName = (PDOMName) pdomName.getEnclosingDefinition();
|
||||
if (enclClassName != null) {
|
||||
|
@ -995,6 +958,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
ownerClass.removeFriend(pdomName);
|
||||
}
|
||||
}
|
||||
} else if (pdomName.isDefinition()) {
|
||||
PDOMBinding binding = pdomName.getBinding();
|
||||
if (binding instanceof PDOMCPPClassType) {
|
||||
((PDOMCPPClassType) binding).removeBases(pdomName);
|
||||
} else if (binding instanceof PDOMCPPClassSpecialization) {
|
||||
((PDOMCPPClassSpecialization) binding).removeBases(pdomName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1065,6 +1035,30 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return CPPPointerToMemberType.unmarshal(firstByte, buffer);
|
||||
case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE:
|
||||
return TypeOfDependentExpression.unmarshal(firstByte, buffer);
|
||||
case ITypeMarshalBuffer.UNKNOWN_MEMBER:
|
||||
IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer);
|
||||
if (binding instanceof IType)
|
||||
return (IType) binding;
|
||||
break;
|
||||
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
|
||||
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
|
||||
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
|
||||
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer);
|
||||
}
|
||||
|
||||
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
int firstByte= buffer.getByte();
|
||||
switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
|
||||
case ITypeMarshalBuffer.UNKNOWN_MEMBER:
|
||||
return CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer);
|
||||
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
|
||||
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
|
||||
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
|
||||
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer);
|
||||
}
|
||||
|
||||
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -186,11 +185,6 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
|
|||
return fUnknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(ICPPTemplateParameter param) {
|
||||
try {
|
||||
|
|
|
@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
@ -171,11 +170,6 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
return fUnknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(ICPPTemplateParameter param) {
|
||||
try {
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Models unknown bindings. The class is directly used for objects (variables, functions, ...) and
|
||||
* serves as a base for unknown types.
|
||||
*/
|
||||
class PDOMCPPUnknownBinding extends PDOMCPPBinding implements ICPPUnknownBinding {
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE;
|
||||
|
||||
public PDOMCPPUnknownBinding(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownBinding binding) throws CoreException {
|
||||
super(linkage, parent, binding.getNameCharArray());
|
||||
}
|
||||
|
||||
public PDOMCPPUnknownBinding(PDOMLinkage linkage, long bindingRecord) {
|
||||
super(linkage, bindingRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_BINDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayHaveChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2011 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Sergey Prigogin
|
||||
*/
|
||||
class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICPPUnknownClassInstance, IPDOMOverloader {
|
||||
private static final int ARGUMENTS = PDOMCPPUnknownClassType.RECORD_SIZE + 0;
|
||||
private static final int SIGNATURE_HASH = ARGUMENTS + 4;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = SIGNATURE_HASH + 4;
|
||||
|
||||
// Cached values.
|
||||
private volatile ICPPTemplateArgument[] arguments;
|
||||
|
||||
public PDOMCPPUnknownClassInstance(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownClassInstance classInstance)
|
||||
throws CoreException {
|
||||
super(linkage, parent, classInstance);
|
||||
|
||||
final ICPPTemplateArgument[] args= classInstance.getArguments();
|
||||
long rec= PDOMCPPArgumentList.putArguments(this, args);
|
||||
final Database db = getDB();
|
||||
db.putRecPtr(record + ARGUMENTS, rec);
|
||||
try {
|
||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(classInstance);
|
||||
db.putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public PDOMCPPUnknownClassInstance(PDOMLinkage linkage, long bindingRecord) {
|
||||
super(linkage, bindingRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSignatureHash() throws CoreException {
|
||||
return getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument[] getArguments() {
|
||||
if (arguments == null) {
|
||||
try {
|
||||
final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS);
|
||||
arguments= PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
arguments= ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof ITypedef) {
|
||||
return type.isSameType(this);
|
||||
}
|
||||
|
||||
if (type instanceof PDOMNode) {
|
||||
PDOMNode node= (PDOMNode) type;
|
||||
// Different PDOM bindings may result in equal types if a parent
|
||||
// turns out to be a template parameter.
|
||||
if (node.getPDOM() == getPDOM() && node.getRecord() == getRecord()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof ICPPUnknownClassInstance) {
|
||||
ICPPUnknownClassInstance rhs= (ICPPUnknownClassInstance) type;
|
||||
if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) {
|
||||
ICPPTemplateArgument[] lhsArgs= getArguments();
|
||||
ICPPTemplateArgument[] rhsArgs= rhs.getArguments();
|
||||
if (lhsArgs != rhsArgs) {
|
||||
if (lhsArgs == null || rhsArgs == null)
|
||||
return false;
|
||||
|
||||
if (lhsArgs.length != rhsArgs.length)
|
||||
return false;
|
||||
|
||||
for (int i= 0; i < lhsArgs.length; i++) {
|
||||
if (!lhsArgs[i].isSameValue(rhsArgs[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final IBinding lhsContainer= getOwner();
|
||||
final IBinding rhsContainer= rhs.getOwner();
|
||||
if (lhsContainer instanceof IType && rhsContainer instanceof IType) {
|
||||
return (((IType) lhsContainer).isSameType((IType) rhsContainer));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,294 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2012 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
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.ICPPClassScope;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Sergey Prigogin
|
||||
*/
|
||||
class PDOMCPPUnknownClassType extends PDOMCPPUnknownBinding
|
||||
implements ICPPClassScope, ICPPUnknownClassType, IPDOMMemberOwner, IIndexType, IIndexScope {
|
||||
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 0; // byte
|
||||
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPUnknownBinding.RECORD_SIZE + 8;
|
||||
|
||||
private PDOMCPPUnknownScope unknownScope; // No need for volatile, PDOMCPPUnknownScope protects its fields
|
||||
|
||||
public PDOMCPPUnknownClassType(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownClassType classType) throws CoreException {
|
||||
super(linkage, parent, classType);
|
||||
|
||||
setKind(classType);
|
||||
// Linked list is initialized by storage being zero'd by malloc
|
||||
}
|
||||
|
||||
public PDOMCPPUnknownClassType(PDOMLinkage linkage, long bindingRecord) {
|
||||
super(linkage, bindingRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EScopeKind getKind() {
|
||||
return EScopeKind.eClassType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||
if (newBinding instanceof ICPPClassType) {
|
||||
ICPPClassType ct= (ICPPClassType) newBinding;
|
||||
setKind(ct);
|
||||
super.update(linkage, newBinding);
|
||||
}
|
||||
}
|
||||
|
||||
private void setKind(ICPPClassType ct) throws CoreException {
|
||||
getDB().putByte(record + KEY, (byte) ct.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
|
||||
list.addMember(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
super.accept(visitor);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getCompositeScope() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPScope asScope() {
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new PDOMCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexBinding getScopeBinding() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType getClassType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated @Override
|
||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getBindings(ScopeLookupData lookup) {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] find(String name) {
|
||||
return CPPSemantics.findBindings(this, name, false);
|
||||
}
|
||||
|
||||
// Not implemented
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField findField(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayHaveChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
||||
*/
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||
*/
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return IField.EMPTY_FIELD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
||||
*/
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return ICPPField.EMPTY_CPPFIELD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
||||
*/
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
||||
*/
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
||||
*/
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
|
||||
*/
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
||||
*/
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
||||
*/
|
||||
@Override
|
||||
public int getKey() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IType#isSameType(IType)
|
||||
*/
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof ITypedef) {
|
||||
return type.isSameType(this);
|
||||
}
|
||||
|
||||
if (type instanceof PDOMNode) {
|
||||
PDOMNode node= (PDOMNode) type;
|
||||
// Different PDOM bindings may result in equal types if a parent
|
||||
// turns out to be a template parameter.
|
||||
if (node.getPDOM() == getPDOM() && node.getRecord() == getRecord()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof ICPPUnknownClassType
|
||||
&& !(type instanceof ICPPUnknownClassInstance)
|
||||
&& !(type instanceof ICPPDeferredClassInstance)) {
|
||||
ICPPUnknownClassType rhs= (ICPPUnknownClassType) type;
|
||||
if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) {
|
||||
final IBinding lhsContainer = getOwner();
|
||||
final IBinding rhsContainer = rhs.getOwner();
|
||||
if (lhsContainer instanceof IType && rhsContainer instanceof IType) {
|
||||
return ((IType)lhsContainer).isSameType((IType) rhsContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
return ICPPClassType.EMPTY_CLASS_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnonymous() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownField;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPUnknownField extends CPPUnknownField implements IIndexFragmentBinding {
|
||||
private final IIndexFragment fFragment;
|
||||
|
||||
public PDOMCPPUnknownField(IIndexFragment frag, IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
fFragment= frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragment getFragment() {
|
||||
return fFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefinition() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaration() throws CoreException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBindingConstant() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_FIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBindingID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMemberClass;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPUnknownMemberClass extends CPPUnknownMemberClass implements IIndexFragmentBinding {
|
||||
private final IIndexFragment fFragment;
|
||||
|
||||
public PDOMCPPUnknownMemberClass(IIndexFragment frag, IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
fFragment= frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragment getFragment() {
|
||||
return fFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefinition() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaration() throws CoreException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBindingConstant() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBindingID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new PDOMCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPUnknownMemberClassInstance extends CPPUnknownClassInstance implements IIndexFragmentBinding {
|
||||
private final IIndexFragment fFragment;
|
||||
|
||||
public PDOMCPPUnknownMemberClassInstance(IIndexFragment frag, IType owner, char[] name, ICPPTemplateArgument[] arguments) {
|
||||
super(owner, name, arguments);
|
||||
fFragment= frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragment getFragment() {
|
||||
return fFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefinition() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaration() throws CoreException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBindingConstant() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBindingID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CPPUnknownTypeScope createScope() {
|
||||
return new PDOMCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMethod;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPUnknownMethod extends CPPUnknownMethod implements IIndexFragmentBinding {
|
||||
private final IIndexFragment fFragment;
|
||||
|
||||
public PDOMCPPUnknownMethod(IIndexFragment frag, IType owner, char[] name) {
|
||||
super(owner, name);
|
||||
fFragment= frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileLocal() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFile getLocalToFile() throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragment getFragment() {
|
||||
return fFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefinition() throws CoreException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaration() throws CoreException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBindingConstant() {
|
||||
return IIndexCPPBindingConstants.CPP_UNKNOWN_METHOD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBindingID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexFragmentBinding getOwner() {
|
||||
return (IIndexFragmentBinding) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndexScope getScope() {
|
||||
try {
|
||||
return (IIndexScope) super.getScope();
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,15 +13,16 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownTypeScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
|
||||
public class PDOMCPPUnknownScope extends CPPUnknownScope implements IIndexScope {
|
||||
public class PDOMCPPUnknownScope extends CPPUnknownTypeScope implements IIndexScope {
|
||||
|
||||
public PDOMCPPUnknownScope(PDOMCPPBinding binding, IASTName name) {
|
||||
super((ICPPUnknownBinding) binding, name);
|
||||
public PDOMCPPUnknownScope(IIndexFragmentBinding binding, IASTName name) {
|
||||
super((IType) binding, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,8 +36,8 @@ public class PDOMCPPUnknownScope extends CPPUnknownScope implements IIndexScope
|
|||
}
|
||||
|
||||
@Override
|
||||
public PDOMCPPBinding getScopeBinding() {
|
||||
return (PDOMCPPBinding) super.getScopeBinding();
|
||||
public IIndexFragmentBinding getScopeBinding() {
|
||||
return (IIndexFragmentBinding) super.getScopeType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,16 +11,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -33,14 +29,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @see ICPPUsingDeclaration
|
||||
*/
|
||||
class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclaration {
|
||||
private static final int TARGET_BINDING = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int TARGET_BINDING = PDOMCPPBinding.RECORD_SIZE;
|
||||
// Using declarations for functions may have multiple delegates. We model such case
|
||||
// by creating a chain of PDOMCPPUsingDeclaration objects linked by NEXT_DELEGATE field.
|
||||
|
||||
private static final int NEXT_DELEGATE = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
private static final int NEXT_DELEGATE = TARGET_BINDING + Database.TYPE_SIZE;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
protected static final int RECORD_SIZE = NEXT_DELEGATE + Database.PTR_SIZE;
|
||||
|
||||
private volatile IBinding[] delegates;
|
||||
|
||||
|
@ -50,17 +46,15 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
|
|||
|
||||
final Database db = getDB();
|
||||
final char[] name = using.getNameCharArray();
|
||||
Set<PDOMBinding> targets= new LinkedHashSet<PDOMBinding>();
|
||||
PDOMCPPUsingDeclaration last= null;
|
||||
for (IBinding delegate : using.getDelegates()) {
|
||||
PDOMBinding target = getLinkage().addPotentiallyUnknownBinding(delegate);
|
||||
if (target != null && targets.add(target)) {
|
||||
if (delegate != null) {
|
||||
if (last == null) {
|
||||
setTargetBinding(linkage, target);
|
||||
setTargetBinding(linkage, delegate);
|
||||
last= this;
|
||||
} else {
|
||||
PDOMCPPUsingDeclaration next= new PDOMCPPUsingDeclaration(linkage, parent, name);
|
||||
next.setTargetBinding(linkage, target);
|
||||
next.setTargetBinding(linkage, delegate);
|
||||
db.putRecPtr(last.getRecord() + NEXT_DELEGATE, next.record);
|
||||
last= next;
|
||||
}
|
||||
|
@ -76,8 +70,8 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
|
|||
super(linkage, parent, name);
|
||||
}
|
||||
|
||||
private void setTargetBinding(PDOMLinkage linkage, PDOMBinding delegate) throws CoreException {
|
||||
getDB().putRecPtr(record + TARGET_BINDING, delegate != null ? delegate.getRecord() : 0);
|
||||
private void setTargetBinding(PDOMLinkage linkage, IBinding delegate) throws CoreException {
|
||||
getLinkage().storeBinding(record + TARGET_BINDING, delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,8 +112,7 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
|
|||
|
||||
private IBinding getBinding() {
|
||||
try {
|
||||
return (IBinding) getLinkage().getNode(
|
||||
getPDOM().getDB().getRecPtr(record + TARGET_BINDING));
|
||||
return getLinkage().loadBinding(record + TARGET_BINDING);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
|||
String header= content[0].toString();
|
||||
String source = content[1].toString();
|
||||
IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
|
||||
waitUntilFileIsIndexed(fIndex, headerFile);
|
||||
IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
|
||||
waitUntilFileIsIndexed(fIndex, sourceFile);
|
||||
|
||||
|
|
|
@ -164,15 +164,17 @@ class THGraph {
|
|||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
IName name= base.getBaseClassSpecifierName();
|
||||
IBinding basecl= name != null ? index.findBinding(name) : base.getBaseClass();
|
||||
ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl);
|
||||
for (ICElementHandle baseElem : baseElems) {
|
||||
THGraphNode baseGraphNode= addNode(baseElem);
|
||||
addMembers(index, baseGraphNode, basecl);
|
||||
addEdge(graphNode, baseGraphNode);
|
||||
if (handled.add(baseElem)) {
|
||||
stack.add(baseElem);
|
||||
IType baseType= base.getBaseClassType();
|
||||
if (baseType instanceof IBinding) {
|
||||
final IBinding baseBinding = (IBinding) baseType;
|
||||
ICElementHandle[] baseElems= IndexUI.findRepresentative(index, baseBinding);
|
||||
for (ICElementHandle baseElem : baseElems) {
|
||||
THGraphNode baseGraphNode= addNode(baseElem);
|
||||
addMembers(index, baseGraphNode, baseBinding);
|
||||
addEdge(graphNode, baseGraphNode);
|
||||
if (handled.add(baseElem)) {
|
||||
stack.add(baseElem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue