mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 17:25:38 +02:00
214646: apply fix
This commit is contained in:
parent
1bd375a30e
commit
8a24d5717e
9 changed files with 962 additions and 1091 deletions
|
@ -9,6 +9,7 @@
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Created on Mar 11, 2005
|
* Created on Mar 11, 2005
|
||||||
|
@ -52,6 +53,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
@ -2142,4 +2144,42 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class A {};
|
||||||
|
//
|
||||||
|
// template <class T> class C {
|
||||||
|
// public:
|
||||||
|
// inline C(T& aRef) {}
|
||||||
|
// inline operator T&() {}
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void foo(A a) {}
|
||||||
|
// void bar(C<const A> ca) {}
|
||||||
|
//
|
||||||
|
// void main2() {
|
||||||
|
// const A a= *new A();
|
||||||
|
// const C<const A> ca= *new C<const A>(*new A());
|
||||||
|
//
|
||||||
|
// foo(a);
|
||||||
|
// bar(ca);
|
||||||
|
// }
|
||||||
|
public void testBug214646() throws Exception {
|
||||||
|
BindingAssertionHelper bh= new BindingAssertionHelper(getContents(1)[0].toString(), true);
|
||||||
|
|
||||||
|
IBinding b0= bh.assertNonProblem("foo(a)", 3);
|
||||||
|
IBinding b1= bh.assertNonProblem("bar(ca)", 3);
|
||||||
|
|
||||||
|
assertInstance(b0, ICPPFunction.class);
|
||||||
|
assertInstance(b1, ICPPFunction.class);
|
||||||
|
|
||||||
|
ICPPFunction f0= (ICPPFunction) b0, f1= (ICPPFunction) b1;
|
||||||
|
assertEquals(1, f0.getParameters().length);
|
||||||
|
assertEquals(1, f1.getParameters().length);
|
||||||
|
|
||||||
|
assertInstance(f0.getParameters()[0].getType(), ICPPClassType.class);
|
||||||
|
assertFalse(f0 instanceof ICPPTemplateInstance);
|
||||||
|
assertFalse(f0 instanceof ICPPTemplateDefinition);
|
||||||
|
assertInstance(f1.getParameters()[0].getType(), ICPPClassType.class);
|
||||||
|
assertInstance(f1.getParameters()[0].getType(), ICPPTemplateInstance.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Mar 28, 2005
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
@ -32,12 +30,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPPInternalBinding {
|
public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPPInternalClassType {
|
||||||
private CPPClassSpecializationScope instanceScope;
|
private CPPClassSpecializationScope instanceScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,6 +207,15 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
||||||
return ICPPClassType.EMPTY_CLASS_ARRAY;
|
return ICPPClassType.EMPTY_CLASS_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getConversionOperators() throws DOMException {
|
||||||
|
IScope scope = getCompositeScope();
|
||||||
|
if (scope instanceof CPPClassSpecializationScope) {
|
||||||
|
if (ASTInternal.isFullyCached(scope))
|
||||||
|
return ((CPPClassSpecializationScope)scope).getConversionOperators();
|
||||||
|
}
|
||||||
|
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj instanceof ICPPClassType ? isSameType((ICPPClassType)obj) : false;
|
return obj instanceof ICPPClassType ? isSameType((ICPPClassType)obj) : false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ class ImplicitsAnalysis {
|
||||||
ICPPASTFunctionDeclarator dcltor= ctors[i];
|
ICPPASTFunctionDeclarator dcltor= ctors[i];
|
||||||
IASTParameterDeclaration [] ps = dcltor.getParameters();
|
IASTParameterDeclaration [] ps = dcltor.getParameters();
|
||||||
if( ps.length >= 1 ){
|
if( ps.length >= 1 ){
|
||||||
if(paramHasTypeReferenceToTheAssociatedClassType(ps[0])) {
|
if(paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) {
|
||||||
// and all remaining arguments have initialisers
|
// and all remaining arguments have initialisers
|
||||||
for(int j=1; j<ps.length; j++) {
|
for(int j=1; j<ps.length; j++) {
|
||||||
if( ps[j].getDeclarator().getInitializer() == null ) {
|
if( ps[j].getDeclarator().getInitializer() == null ) {
|
||||||
|
@ -429,7 +429,7 @@ class ImplicitsAnalysis {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor( ICPPASTCompositeTypeSpecifier compSpec, boolean constructor ) {
|
private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor( ICPPASTCompositeTypeSpecifier compSpec, boolean constructor ) {
|
||||||
List result= new ArrayList();
|
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
|
||||||
IASTDeclaration [] members = compSpec.getMembers();
|
IASTDeclaration [] members = compSpec.getMembers();
|
||||||
char [] name = compSpec.getName().toCharArray();
|
char [] name = compSpec.getName().toCharArray();
|
||||||
IASTDeclarator dcltor = null;
|
IASTDeclarator dcltor = null;
|
||||||
|
@ -466,13 +466,13 @@ class ImplicitsAnalysis {
|
||||||
if(!nameEquals)
|
if(!nameEquals)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result.add(dcltor);
|
result.add((ICPPASTFunctionDeclarator) dcltor);
|
||||||
}
|
}
|
||||||
return (ICPPASTFunctionDeclarator[]) result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
|
return result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators( ICPPASTCompositeTypeSpecifier compSpec ) {
|
private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators( ICPPASTCompositeTypeSpecifier compSpec ) {
|
||||||
List result= new ArrayList();
|
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
|
||||||
IASTDeclaration [] members = compSpec.getMembers();
|
IASTDeclaration [] members = compSpec.getMembers();
|
||||||
IASTDeclarator dcltor = null;
|
IASTDeclarator dcltor = null;
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for( int i = 0; i < members.length; i++ ){
|
||||||
|
@ -491,22 +491,31 @@ class ImplicitsAnalysis {
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTParameterDeclaration [] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters();
|
IASTParameterDeclaration [] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters();
|
||||||
if( ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0]) )
|
if(ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0], null))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result.add(dcltor);
|
result.add((ICPPASTFunctionDeclarator)dcltor);
|
||||||
}
|
}
|
||||||
return (ICPPASTFunctionDeclarator[]) result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
|
return result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec) {
|
/**
|
||||||
|
* @param compSpec the name the parameter must have in order to match, or null for any name
|
||||||
|
* @param dec
|
||||||
|
* @return whether the specified parameter is a reference to the associated class type, and
|
||||||
|
* (optionally) if it has the specified name
|
||||||
|
*/
|
||||||
|
private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) {
|
||||||
boolean result= false;
|
boolean result= false;
|
||||||
IASTDeclarator pdtor= dec.getDeclarator();
|
IASTDeclarator pdtor= dec.getDeclarator();
|
||||||
if(pdtor.getPointerOperators().length==1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) {
|
if(pdtor.getPointerOperators().length==1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) {
|
||||||
if(dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
|
if(dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
|
||||||
|
ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier();
|
||||||
|
if(name==null || name.equals(nts.getName().getRawSignature())) {
|
||||||
result= true;
|
result= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Mar 28, 2005
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
|
@ -145,7 +142,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs);
|
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ICPPMethod[] getConversionOperators() {
|
protected ICPPMethod[] getConversionOperators() throws DOMException {
|
||||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
|
|
||||||
if (!(specialized instanceof ICPPInternalClassType)) {
|
if (!(specialized instanceof ICPPInternalClassType)) {
|
||||||
|
|
|
@ -9,23 +9,19 @@
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Mar 31, 2005
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
@ -35,9 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
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.ICPPBase;
|
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.ICPPClassTemplate;
|
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.ICPPClassTemplatePartialSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
@ -47,20 +41,16 @@ 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.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType.CPPClassTypeProblem;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPClassTemplate extends CPPTemplateDefinition implements
|
public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTemplate {
|
ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTemplate, ICPPInternalClassTypeMixinHost {
|
||||||
|
|
||||||
public static class CPPClassTemplateDelegate extends CPPClassType.CPPClassTypeDelegate implements ICPPClassTemplate, ICPPInternalClassTemplate {
|
public static class CPPClassTemplateDelegate extends CPPClassType.CPPClassTypeDelegate implements ICPPClassTemplate, ICPPInternalClassTemplate {
|
||||||
public CPPClassTemplateDelegate( IASTName name, ICPPClassType cls ) {
|
public CPPClassTemplateDelegate( IASTName name, ICPPClassType cls ) {
|
||||||
|
@ -94,7 +84,6 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private ICPPClassTemplatePartialSpecialization [] partialSpecializations = null;
|
|
||||||
|
|
||||||
private class FindDefinitionAction extends CPPASTVisitor {
|
private class FindDefinitionAction extends CPPASTVisitor {
|
||||||
private char [] nameArray = CPPClassTemplate.this.getNameCharArray();
|
private char [] nameArray = CPPClassTemplate.this.getNameCharArray();
|
||||||
|
@ -137,7 +126,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public int visit( IASTDeclaration declaration ){
|
public int visit( IASTDeclaration declaration ){
|
||||||
if(declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration )
|
if(declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
@ -146,11 +135,13 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
public int visit( IASTDeclarator declarator ) { return PROCESS_SKIP; }
|
public int visit( IASTDeclarator declarator ) { return PROCESS_SKIP; }
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param decl
|
private ICPPClassTemplatePartialSpecialization [] partialSpecializations = null;
|
||||||
*/
|
private ClassTypeMixin mixin;
|
||||||
|
|
||||||
public CPPClassTemplate(IASTName name) {
|
public CPPClassTemplate(IASTName name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
this.mixin= new ClassTypeMixin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance( IType [] arguments ){
|
public ICPPSpecialization deferredInstance( IType [] arguments ){
|
||||||
|
@ -162,7 +153,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForDefinition(){
|
public void checkForDefinition(){
|
||||||
FindDefinitionAction action = new FindDefinitionAction();
|
FindDefinitionAction action = new FindDefinitionAction();
|
||||||
IASTNode node = CPPVisitor.getContainingBlockItem( declarations[0] ).getParent();
|
IASTNode node = CPPVisitor.getContainingBlockItem( declarations[0] ).getParent();
|
||||||
while( node instanceof ICPPASTTemplateDeclaration )
|
while( node instanceof ICPPASTTemplateDeclaration )
|
||||||
|
@ -182,7 +173,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append( ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec );
|
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append( ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){
|
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){
|
||||||
if( definition != null ){
|
if( definition != null ){
|
||||||
IASTNode node = definition.getParent();
|
IASTNode node = definition.getParent();
|
||||||
if( node instanceof ICPPASTQualifiedName )
|
if( node instanceof ICPPASTQualifiedName )
|
||||||
|
@ -192,250 +183,23 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param templateParameter
|
public IScope getCompositeScope() {
|
||||||
* @return
|
if (definition == null) {
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
|
||||||
*/
|
|
||||||
public ICPPBase [] getBases() {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
checkForDefinition();
|
||||||
if( definition == null ){
|
}
|
||||||
IASTName node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
if (definition != null) {
|
||||||
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
IASTNode parent = definition.getParent();
|
||||||
|
while (parent instanceof IASTName)
|
||||||
|
parent = parent.getParent();
|
||||||
|
if (parent instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
|
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier)parent;
|
||||||
|
return compSpec.getScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ICPPASTBaseSpecifier [] bases = getCompositeTypeSpecifier().getBaseSpecifiers();
|
return null;
|
||||||
if( bases.length == 0 )
|
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
|
||||||
|
|
||||||
ICPPBase [] bindings = new ICPPBase[ bases.length ];
|
|
||||||
for( int i = 0; i < bases.length; i++ ){
|
|
||||||
bindings[i] = new CPPBaseClause( bases[i] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
|
||||||
*/
|
|
||||||
public IField[] getFields() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new IField [] { new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IField[] fields = getDeclaredFields();
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
fields = (IField[]) ArrayUtil.addAll( IField.class, fields, ((ICPPClassType)b).getFields() );
|
|
||||||
}
|
|
||||||
return (IField[]) ArrayUtil.trim( IField.class, fields );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
|
|
||||||
*/
|
|
||||||
public IField findField(String name) throws DOMException {
|
|
||||||
IBinding [] bindings = CPPSemantics.findBindings( getCompositeScope(), name, true );
|
|
||||||
IField field = null;
|
|
||||||
for ( int i = 0; i < bindings.length; i++ ) {
|
|
||||||
if( bindings[i] instanceof IField ){
|
|
||||||
if( field == null )
|
|
||||||
field = (IField) bindings[i];
|
|
||||||
else {
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
|
||||||
*/
|
|
||||||
public ICPPField[] getDeclaredFields() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPField[] { new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
ICPPField [] result = null;
|
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
if( decls[i] instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators();
|
|
||||||
for ( int j = 0; j < dtors.length; j++ ) {
|
|
||||||
binding = dtors[j].getName().resolveBinding();
|
|
||||||
if( binding instanceof ICPPField )
|
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, binding );
|
|
||||||
}
|
|
||||||
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
|
||||||
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
|
||||||
binding = n.resolveBinding();
|
|
||||||
if( binding instanceof ICPPUsingDeclaration ){
|
|
||||||
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
|
||||||
for ( int j = 0; j < bs.length; j++ ) {
|
|
||||||
if( bs[j] instanceof ICPPField )
|
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, bs[j] );
|
|
||||||
}
|
|
||||||
} else if( binding instanceof ICPPField ) {
|
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPField[]) ArrayUtil.trim( ICPPField.class, result );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getMethods() throws DOMException {
|
|
||||||
ObjectSet set = new ObjectSet(4);
|
|
||||||
set.addAll( getDeclaredMethods() );
|
|
||||||
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
|
|
||||||
set.addAll( scope.getImplicitMethods() );
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
set.addAll( ((ICPPClassType)b).getMethods() );
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) set.keyArray( ICPPMethod.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPMethod [] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICPPMethod[] methods = getDeclaredMethods();
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
methods = (ICPPMethod[]) ArrayUtil.addAll( ICPPMethod.class, methods, ((ICPPClassType)b).getAllDeclaredMethods() );
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, methods );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPMethod[] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
ICPPMethod [] result = null;
|
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
IASTDeclaration decl = decls[i];
|
|
||||||
while( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
|
||||||
for ( int j = 0; j < dtors.length; j++ ) {
|
|
||||||
binding = dtors[j].getName().resolveBinding();
|
|
||||||
if( binding instanceof ICPPMethod)
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
} else if( decl instanceof IASTFunctionDefinition ){
|
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
|
||||||
dtor = CPPVisitor.getMostNestedDeclarator( dtor );
|
|
||||||
binding = dtor.getName().resolveBinding();
|
|
||||||
if( binding instanceof ICPPMethod ){
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
} else if( decl instanceof ICPPASTUsingDeclaration ){
|
|
||||||
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
|
||||||
binding = n.resolveBinding();
|
|
||||||
if( binding instanceof ICPPUsingDeclaration ){
|
|
||||||
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
|
||||||
for ( int j = 0; j < bs.length; j++ ) {
|
|
||||||
if( bs[j] instanceof ICPPMethod )
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, bs[j] );
|
|
||||||
}
|
|
||||||
} else if( binding instanceof ICPPMethod ) {
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
|
|
||||||
*/
|
|
||||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPConstructor [] { new CPPConstructor.CPPConstructorProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
|
|
||||||
if( ASTInternal.isFullyCached(scope))
|
|
||||||
return ((CPPClassScope)scope).getConstructors( true );
|
|
||||||
|
|
||||||
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for( int i = 0; i < members.length; i++ ){
|
|
||||||
IASTDeclaration decl = members[i];
|
|
||||||
if( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
|
||||||
for( int j = 0; j < dtors.length; j++ ){
|
|
||||||
if( dtors[j] == null ) break;
|
|
||||||
ASTInternal.addName(scope, dtors[j].getName() );
|
|
||||||
}
|
|
||||||
} else if( decl instanceof IASTFunctionDefinition ){
|
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
|
||||||
ASTInternal.addName(scope, dtor.getName() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((CPPClassScope)scope).getConstructors( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
|
||||||
*/
|
|
||||||
public IBinding[] getFriends() {
|
|
||||||
//TODO
|
|
||||||
return IBinding.EMPTY_BINDING_ARRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
|
||||||
*/
|
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
if( definition != null ) {
|
if( definition != null ) {
|
||||||
ICPPASTCompositeTypeSpecifier cts= getCompositeTypeSpecifier();
|
ICPPASTCompositeTypeSpecifier cts= getCompositeTypeSpecifier();
|
||||||
|
@ -458,27 +222,71 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
return ICPPASTElaboratedTypeSpecifier.k_class;
|
return ICPPASTElaboratedTypeSpecifier.k_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
|
||||||
*/
|
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
|
||||||
public IScope getCompositeScope() {
|
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim( ICPPClassTemplatePartialSpecialization.class, partialSpecializations );
|
||||||
if( definition == null )
|
return partialSpecializations;
|
||||||
checkForDefinition();
|
}
|
||||||
if( definition != null ) {
|
|
||||||
IASTNode parent = definition.getParent();
|
public ICPPDelegate createDelegate( IASTName name ) {
|
||||||
while (parent instanceof IASTName)
|
return new CPPClassTemplateDelegate( name, this );
|
||||||
parent = parent.getParent();
|
}
|
||||||
if (parent instanceof ICPPASTCompositeTypeSpecifier) {
|
|
||||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier)parent;
|
/* */
|
||||||
return compSpec.getScope();
|
|
||||||
}
|
public boolean isSameType( IType type ) {
|
||||||
}
|
if (type == this)
|
||||||
return null;
|
return true;
|
||||||
|
if (type instanceof ITypedef || type instanceof IIndexType || type instanceof ICPPDelegate)
|
||||||
|
return type.isSameType(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPBase [] getBases() {
|
||||||
|
return mixin.getBases();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField[] getFields() throws DOMException {
|
||||||
|
return mixin.getFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||||
|
return mixin.getDeclaredFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getConversionOperators() throws DOMException {
|
||||||
|
return mixin.getConversionOperators();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getMethods() throws DOMException {
|
||||||
|
return mixin.getMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||||
|
return mixin.getAllDeclaredMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||||
|
return mixin.getDeclaredMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||||
|
return mixin.getConstructors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getFriends() {
|
||||||
|
return mixin.getFriends();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType[] getNestedClasses() {
|
||||||
|
return mixin.getNestedClasses();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField findField(String name) throws DOMException {
|
||||||
|
return mixin.findField(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#clone()
|
|
||||||
*/
|
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
try {
|
try {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
|
@ -486,66 +294,4 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassType#getConversionOperators()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getConversionOperators() {
|
|
||||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
|
||||||
*/
|
|
||||||
public boolean isSameType( IType type ) {
|
|
||||||
if( type == this )
|
|
||||||
return true;
|
|
||||||
if( type instanceof ITypedef || type instanceof IIndexType)
|
|
||||||
return type.isSameType( this );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
|
|
||||||
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim( ICPPClassTemplatePartialSpecialization.class, partialSpecializations );
|
|
||||||
return partialSpecializations;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
|
||||||
*/
|
|
||||||
public ICPPDelegate createDelegate( IASTName name ) {
|
|
||||||
return new CPPClassTemplateDelegate( name, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPClassType[] getNestedClasses() {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPClassType[] { new CPPClassTypeProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
ICPPClassType [] result = null;
|
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
IASTDeclaration decl = decls[i];
|
|
||||||
while( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
|
||||||
if( declSpec instanceof ICPPASTCompositeTypeSpecifier ){
|
|
||||||
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
|
||||||
} else if( declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
|
||||||
((IASTSimpleDeclaration)decl).getDeclarators().length == 0 )
|
|
||||||
{
|
|
||||||
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
|
||||||
}
|
|
||||||
if( binding instanceof ICPPClassType )
|
|
||||||
result = (ICPPClassType[])ArrayUtil.append( ICPPClassType.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPClassType[]) ArrayUtil.trim( ICPPClassType.class, result );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Nov 29, 2004
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
|
@ -29,19 +26,15 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
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.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
|
@ -51,23 +44,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPInternalClassType {
|
public class CPPClassType extends PlatformObject implements ICPPInternalClassTypeMixinHost, ICPPClassType, ICPPInternalClassType {
|
||||||
public static class CPPClassTypeDelegate extends CPPDelegate implements ICPPClassType, ICPPInternalClassType {
|
public static class CPPClassTypeDelegate extends CPPDelegate implements ICPPClassType, ICPPInternalClassType {
|
||||||
public CPPClassTypeDelegate( IASTName name, ICPPClassType cls ){
|
public CPPClassTypeDelegate( IASTName name, ICPPClassType cls ){
|
||||||
super( name, cls );
|
super( name, cls );
|
||||||
|
@ -113,7 +103,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
public ICPPMethod[] getConversionOperators() {
|
public ICPPMethod[] getConversionOperators() throws DOMException {
|
||||||
IBinding binding = getBinding();
|
IBinding binding = getBinding();
|
||||||
if( binding instanceof ICPPInternalClassType )
|
if( binding instanceof ICPPInternalClassType )
|
||||||
return ((ICPPInternalClassType)binding).getConversionOperators();
|
return ((ICPPInternalClassType)binding).getConversionOperators();
|
||||||
|
@ -184,43 +174,6 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName definition;
|
|
||||||
private IASTName [] declarations;
|
|
||||||
private boolean checked = false;
|
|
||||||
private ICPPClassType typeInIndex;
|
|
||||||
public CPPClassType( IASTName name, IBinding indexBinding ){
|
|
||||||
if( name instanceof ICPPASTQualifiedName ){
|
|
||||||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
|
||||||
name = ns[ ns.length - 1 ];
|
|
||||||
}
|
|
||||||
IASTNode parent = name.getParent();
|
|
||||||
while( parent instanceof IASTName )
|
|
||||||
parent = parent.getParent();
|
|
||||||
|
|
||||||
if( parent instanceof IASTCompositeTypeSpecifier )
|
|
||||||
definition = name;
|
|
||||||
else
|
|
||||||
declarations = new IASTName[] { name };
|
|
||||||
name.setBinding( this );
|
|
||||||
if (indexBinding instanceof ICPPClassType && indexBinding instanceof IIndexBinding) {
|
|
||||||
typeInIndex= (ICPPClassType) indexBinding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
|
||||||
*/
|
|
||||||
public IASTNode[] getDeclarations() {
|
|
||||||
return declarations;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
|
||||||
*/
|
|
||||||
public IASTNode getDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class FindDefinitionAction extends CPPASTVisitor {
|
private class FindDefinitionAction extends CPPASTVisitor {
|
||||||
private char [] nameArray = CPPClassType.this.getNameCharArray();
|
private char [] nameArray = CPPClassType.this.getNameCharArray();
|
||||||
public IASTName result = null;
|
public IASTName result = null;
|
||||||
|
@ -263,7 +216,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
}
|
}
|
||||||
|
|
||||||
public int visit( IASTDeclaration declaration ){
|
public int visit( IASTDeclaration declaration ){
|
||||||
if( declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration )
|
if(declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +226,41 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
public int visit( IASTDeclarator declarator ) { return PROCESS_SKIP; }
|
public int visit( IASTDeclarator declarator ) { return PROCESS_SKIP; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForDefinition(){
|
private IASTName definition;
|
||||||
|
private IASTName [] declarations;
|
||||||
|
private boolean checked = false;
|
||||||
|
private ICPPClassType typeInIndex;
|
||||||
|
private ClassTypeMixin mixin;
|
||||||
|
|
||||||
|
public CPPClassType( IASTName name, IBinding indexBinding ){
|
||||||
|
if( name instanceof ICPPASTQualifiedName ){
|
||||||
|
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||||
|
name = ns[ ns.length - 1 ];
|
||||||
|
}
|
||||||
|
IASTNode parent = name.getParent();
|
||||||
|
while( parent instanceof IASTName )
|
||||||
|
parent = parent.getParent();
|
||||||
|
|
||||||
|
if( parent instanceof IASTCompositeTypeSpecifier )
|
||||||
|
definition = name;
|
||||||
|
else
|
||||||
|
declarations = new IASTName[] { name };
|
||||||
|
name.setBinding( this );
|
||||||
|
if (indexBinding instanceof ICPPClassType && indexBinding instanceof IIndexBinding) {
|
||||||
|
typeInIndex= (ICPPClassType) indexBinding;
|
||||||
|
}
|
||||||
|
mixin= new ClassTypeMixin(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTNode[] getDeclarations() {
|
||||||
|
return declarations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTNode getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkForDefinition(){
|
||||||
if( !checked ) {
|
if( !checked ) {
|
||||||
FindDefinitionAction action = new FindDefinitionAction();
|
FindDefinitionAction action = new FindDefinitionAction();
|
||||||
IASTNode node = CPPVisitor.getContainingBlockItem( getPhysicalNode() ).getParent();
|
IASTNode node = CPPVisitor.getContainingBlockItem( getPhysicalNode() ).getParent();
|
||||||
|
@ -294,7 +281,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){
|
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){
|
||||||
if( definition != null ){
|
if( definition != null ){
|
||||||
IASTNode node = definition;
|
IASTNode node = definition;
|
||||||
while( node instanceof IASTName )
|
while( node instanceof IASTName )
|
||||||
|
@ -304,6 +291,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPASTElaboratedTypeSpecifier getElaboratedTypeSpecifier() {
|
private ICPPASTElaboratedTypeSpecifier getElaboratedTypeSpecifier() {
|
||||||
if( declarations != null ){
|
if( declarations != null ){
|
||||||
IASTNode node = declarations[0];
|
IASTNode node = declarations[0];
|
||||||
|
@ -314,64 +302,15 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
|
||||||
*/
|
|
||||||
public IField[] getFields() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new IField [] { new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IField[] fields = getDeclaredFields();
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
fields = (IField[]) ArrayUtil.addAll( IField.class, fields, ((ICPPClassType)b).getFields() );
|
|
||||||
}
|
|
||||||
return (IField[]) ArrayUtil.trim( IField.class, fields );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
|
|
||||||
*/
|
|
||||||
public IField findField(String name) throws DOMException {
|
|
||||||
IBinding [] bindings = CPPSemantics.findBindings( getCompositeScope(), name, true );
|
|
||||||
IField field = null;
|
|
||||||
for ( int i = 0; i < bindings.length; i++ ) {
|
|
||||||
if( bindings[i] instanceof IField ){
|
|
||||||
if( field == null )
|
|
||||||
field = (IField) bindings[i];
|
|
||||||
else {
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return ( definition != null ) ? definition.toString() : declarations[0].toString();
|
return ( definition != null ) ? definition.toString() : declarations[0].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
|
||||||
*/
|
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return ( definition != null ) ? definition.toCharArray() : declarations[0].toCharArray();
|
return ( definition != null ) ? definition.toCharArray() : declarations[0].toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
IASTName name = definition != null ? definition : declarations[0];
|
IASTName name = definition != null ? definition : declarations[0];
|
||||||
|
|
||||||
|
@ -393,9 +332,6 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
|
||||||
*/
|
|
||||||
public IScope getCompositeScope() {
|
public IScope getCompositeScope() {
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
checkForDefinition();
|
checkForDefinition();
|
||||||
|
@ -414,16 +350,10 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
|
||||||
*/
|
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
return (definition != null ) ? (IASTNode) definition : declarations[0];
|
return (definition != null ) ? (IASTNode) definition : declarations[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
|
||||||
*/
|
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
if( definition != null )
|
if( definition != null )
|
||||||
return getCompositeTypeSpecifier().getKey();
|
return getCompositeTypeSpecifier().getKey();
|
||||||
|
@ -435,6 +365,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
if( node instanceof ICPPASTCompositeTypeSpecifier )
|
if( node instanceof ICPPASTCompositeTypeSpecifier )
|
||||||
definition = ((ICPPASTCompositeTypeSpecifier)node).getName();
|
definition = ((ICPPASTCompositeTypeSpecifier)node).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDeclaration( IASTNode node ) {
|
public void addDeclaration( IASTNode node ) {
|
||||||
if( !(node instanceof ICPPASTElaboratedTypeSpecifier) )
|
if( !(node instanceof ICPPASTElaboratedTypeSpecifier) )
|
||||||
return;
|
return;
|
||||||
|
@ -462,318 +393,14 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
ArrayUtil.remove(declarations, node);
|
ArrayUtil.remove(declarations, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
|
||||||
*/
|
|
||||||
public ICPPBase [] getBases() {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTName node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ICPPASTBaseSpecifier [] bases = getCompositeTypeSpecifier().getBaseSpecifiers();
|
|
||||||
if( bases.length == 0 )
|
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
|
||||||
|
|
||||||
ICPPBase [] bindings = new ICPPBase[ bases.length ];
|
|
||||||
for( int i = 0; i < bases.length; i++ ){
|
|
||||||
bindings[i] = new CPPBaseClause( bases[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
return bindings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
|
||||||
*/
|
|
||||||
public ICPPField[] getDeclaredFields() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPField[] { new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
ICPPField [] result = null;
|
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
if( decls[i] instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators();
|
|
||||||
for ( int j = 0; j < dtors.length; j++ ) {
|
|
||||||
binding = dtors[j].getName().resolveBinding();
|
|
||||||
if( binding instanceof ICPPField )
|
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, binding );
|
|
||||||
}
|
|
||||||
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
|
||||||
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
|
||||||
binding = n.resolveBinding();
|
|
||||||
if( binding instanceof ICPPUsingDeclaration ){
|
|
||||||
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
|
||||||
for ( int j = 0; j < bs.length; j++ ) {
|
|
||||||
if( bs[j] instanceof ICPPField )
|
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, bs[j] );
|
|
||||||
}
|
|
||||||
} else if( binding instanceof ICPPField ) {
|
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPField[]) ArrayUtil.trim( ICPPField.class, result );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPMethod[] getConversionOperators() {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPMethod[] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
ICPPMethod [] result = null;
|
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
IASTName name = null;
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
if( decls[i] instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators();
|
|
||||||
for ( int j = 0; j < dtors.length; j++ ) {
|
|
||||||
name = CPPVisitor.getMostNestedDeclarator( dtors[j] ).getName();
|
|
||||||
if( name instanceof ICPPASTConversionName ){
|
|
||||||
binding = name.resolveBinding();
|
|
||||||
if( binding instanceof ICPPMethod)
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if( decls[i] instanceof IASTFunctionDefinition ){
|
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decls[i]).getDeclarator();
|
|
||||||
name = CPPVisitor.getMostNestedDeclarator( dtor ).getName();
|
|
||||||
if( name instanceof ICPPASTConversionName ){
|
|
||||||
binding = name.resolveBinding();
|
|
||||||
if( binding instanceof ICPPMethod ){
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
ICPPClassType cls = null;
|
|
||||||
try {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
cls = (ICPPClassType) b;
|
|
||||||
} catch (DOMException e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if( cls instanceof ICPPInternalClassType )
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.addAll( ICPPMethod.class, result, ((ICPPInternalClassType)cls).getConversionOperators() );
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getMethods() throws DOMException {
|
|
||||||
ObjectSet set = new ObjectSet(4);
|
|
||||||
ICPPMethod [] ms = getDeclaredMethods();
|
|
||||||
set.addAll( ms );
|
|
||||||
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
|
|
||||||
set.addAll( scope.getImplicitMethods() );
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
set.addAll( ((ICPPClassType)b).getMethods() );
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) set.keyArray( ICPPMethod.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPMethod [] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICPPMethod[] methods = getDeclaredMethods();
|
|
||||||
ICPPBase [] bases = getBases();
|
|
||||||
for ( int i = 0; i < bases.length; i++ ) {
|
|
||||||
IBinding b = bases[i].getBaseClass();
|
|
||||||
if( b instanceof ICPPClassType )
|
|
||||||
methods = (ICPPMethod[]) ArrayUtil.addAll( ICPPMethod.class, methods, ((ICPPClassType)b).getAllDeclaredMethods() );
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, methods );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
|
||||||
*/
|
|
||||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPMethod[] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IBinding binding = null;
|
|
||||||
ICPPMethod [] result = null;
|
|
||||||
|
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
IASTDeclaration decl = decls[i];
|
|
||||||
while( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
|
||||||
for ( int j = 0; j < dtors.length; j++ ) {
|
|
||||||
binding = dtors[j].getName().resolveBinding();
|
|
||||||
if( binding instanceof ICPPMethod)
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
} else if( decl instanceof IASTFunctionDefinition ){
|
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
|
||||||
dtor = CPPVisitor.getMostNestedDeclarator( dtor );
|
|
||||||
binding = dtor.getName().resolveBinding();
|
|
||||||
if( binding instanceof ICPPMethod ){
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
} else if( decl instanceof ICPPASTUsingDeclaration ){
|
|
||||||
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
|
||||||
binding = n.resolveBinding();
|
|
||||||
if( binding instanceof ICPPUsingDeclaration ){
|
|
||||||
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
|
||||||
for ( int j = 0; j < bs.length; j++ ) {
|
|
||||||
if( bs[j] instanceof ICPPMethod )
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, bs[j] );
|
|
||||||
}
|
|
||||||
} else if( binding instanceof ICPPMethod ) {
|
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object clone(){
|
|
||||||
IType t = null;
|
|
||||||
try {
|
|
||||||
t = (IType) super.clone();
|
|
||||||
} catch ( CloneNotSupportedException e ) {
|
|
||||||
//not going to happen
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
|
|
||||||
*/
|
|
||||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPConstructor [] { new CPPConstructor.CPPConstructorProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
|
|
||||||
if( ASTInternal.isFullyCached(scope) )
|
|
||||||
return ((CPPClassScope)scope).getConstructors( true );
|
|
||||||
|
|
||||||
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for( int i = 0; i < members.length; i++ ){
|
|
||||||
IASTDeclaration decl = members[i];
|
|
||||||
if( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
|
||||||
for( int j = 0; j < dtors.length; j++ ){
|
|
||||||
if( dtors[j] == null ) break;
|
|
||||||
ASTInternal.addName(scope, dtors[j].getName() );
|
|
||||||
}
|
|
||||||
} else if( decl instanceof IASTFunctionDefinition ){
|
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
|
||||||
ASTInternal.addName(scope, dtor.getName() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((CPPClassScope)scope).getConstructors( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
|
||||||
*/
|
|
||||||
public IBinding[] getFriends() {
|
|
||||||
if( definition == null ){
|
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new IBinding [] { new ProblemBinding( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ObjectSet resultSet = new ObjectSet(2);
|
|
||||||
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for( int i = 0; i < members.length; i++ ){
|
|
||||||
IASTDeclaration decl = members[i];
|
|
||||||
while( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
|
||||||
if( declSpec.isFriend() ){
|
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
|
||||||
if( declSpec instanceof ICPPASTElaboratedTypeSpecifier && dtors.length == 0 ){
|
|
||||||
resultSet.put( ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding() );
|
|
||||||
} else {
|
|
||||||
for( int j = 0; j < dtors.length; j++ ){
|
|
||||||
if( dtors[j] == null ) break;
|
|
||||||
resultSet.put( dtors[j].getName().resolveBinding() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if( decl instanceof IASTFunctionDefinition ){
|
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
|
|
||||||
if( declSpec.isFriend() ){
|
|
||||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
|
||||||
resultSet.put( dtor.getName().resolveBinding() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (IBinding[]) resultSet.keyArray( IBinding.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
|
||||||
*/
|
|
||||||
public String[] getQualifiedName() {
|
public String[] getQualifiedName() {
|
||||||
return CPPVisitor.getQualifiedName( this );
|
return CPPVisitor.getQualifiedName( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
|
||||||
*/
|
|
||||||
public char[][] getQualifiedNameCharArray() {
|
public char[][] getQualifiedNameCharArray() {
|
||||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
|
||||||
*/
|
|
||||||
public boolean isGloballyQualified() throws DOMException {
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
IScope scope = getScope();
|
IScope scope = getScope();
|
||||||
while( scope != null ){
|
while( scope != null ){
|
||||||
|
@ -784,16 +411,17 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
|
||||||
*/
|
|
||||||
public ICPPDelegate createDelegate( IASTName name ) {
|
public ICPPDelegate createDelegate( IASTName name ) {
|
||||||
return new CPPClassTypeDelegate( name, this );
|
return new CPPClassTypeDelegate( name, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
public ILinkage getLinkage() {
|
||||||
*/
|
return Linkage.CPP_LINKAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
|
||||||
public boolean isSameType( IType type ) {
|
public boolean isSameType( IType type ) {
|
||||||
if (type == this)
|
if (type == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -802,40 +430,55 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICPPBase [] getBases() {
|
||||||
|
return mixin.getBases();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField[] getFields() throws DOMException {
|
||||||
|
return mixin.getFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||||
|
return mixin.getDeclaredFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getConversionOperators() throws DOMException {
|
||||||
|
return mixin.getConversionOperators();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getMethods() throws DOMException {
|
||||||
|
return mixin.getMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||||
|
return mixin.getAllDeclaredMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||||
|
return mixin.getDeclaredMethods();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||||
|
return mixin.getConstructors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getFriends() {
|
||||||
|
return mixin.getFriends();
|
||||||
|
}
|
||||||
|
|
||||||
public ICPPClassType[] getNestedClasses() {
|
public ICPPClassType[] getNestedClasses() {
|
||||||
if( definition == null ){
|
return mixin.getNestedClasses();
|
||||||
checkForDefinition();
|
|
||||||
if( definition == null ){
|
|
||||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
|
||||||
return new ICPPClassType[] { new CPPClassTypeProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPClassType [] result = null;
|
public IField findField(String name) throws DOMException {
|
||||||
|
return mixin.findField(name);
|
||||||
IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers();
|
|
||||||
for ( int i = 0; i < decls.length; i++ ) {
|
|
||||||
IASTDeclaration decl = decls[i];
|
|
||||||
while( decl instanceof ICPPASTTemplateDeclaration )
|
|
||||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
|
||||||
if( decl instanceof IASTSimpleDeclaration ){
|
|
||||||
IBinding binding = null;
|
|
||||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
|
||||||
if( declSpec instanceof ICPPASTCompositeTypeSpecifier ){
|
|
||||||
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
|
||||||
} else if( declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
|
||||||
((IASTSimpleDeclaration)decl).getDeclarators().length == 0 )
|
|
||||||
{
|
|
||||||
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
|
||||||
}
|
|
||||||
if( binding instanceof ICPPClassType )
|
|
||||||
result = (ICPPClassType[])ArrayUtil.append( ICPPClassType.class, result, binding );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPClassType[]) ArrayUtil.trim( ICPPClassType.class, result );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILinkage getLinkage() {
|
public Object clone() {
|
||||||
return Linkage.CPP_LINKAGE;
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,407 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2004, 2007 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)
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
|
* Andrew Ferguson (Symbian)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
|
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.ICPPUsingDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType.CPPClassTypeProblem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds common implementation of methods for ICPPClassType implementations that have
|
||||||
|
* a corresponding textual definition in the source code. This functionality is then
|
||||||
|
* accessed via a delegate.
|
||||||
|
*
|
||||||
|
* @see CPPClassType
|
||||||
|
* @see CPPClassTemplate
|
||||||
|
*/
|
||||||
|
class ClassTypeMixin {
|
||||||
|
private ICPPInternalClassTypeMixinHost host;
|
||||||
|
|
||||||
|
public ClassTypeMixin(ICPPInternalClassTypeMixinHost host) {
|
||||||
|
this.host= host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBinding[] getFriends() {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new IBinding [] { new ProblemBinding( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ObjectSet resultSet = new ObjectSet(2);
|
||||||
|
IASTDeclaration [] members = host.getCompositeTypeSpecifier().getMembers();
|
||||||
|
for( int i = 0; i < members.length; i++ ){
|
||||||
|
IASTDeclaration decl = members[i];
|
||||||
|
while( decl instanceof ICPPASTTemplateDeclaration )
|
||||||
|
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||||
|
|
||||||
|
if( decl instanceof IASTSimpleDeclaration ){
|
||||||
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
||||||
|
if( declSpec.isFriend() ){
|
||||||
|
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||||
|
if( declSpec instanceof ICPPASTElaboratedTypeSpecifier && dtors.length == 0 ){
|
||||||
|
resultSet.put( ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding() );
|
||||||
|
} else {
|
||||||
|
for( int j = 0; j < dtors.length; j++ ){
|
||||||
|
if( dtors[j] == null ) break;
|
||||||
|
resultSet.put( dtors[j].getName().resolveBinding() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if( decl instanceof IASTFunctionDefinition ){
|
||||||
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
|
||||||
|
if( declSpec.isFriend() ){
|
||||||
|
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
||||||
|
resultSet.put( dtor.getName().resolveBinding() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IBinding[]) resultSet.keyArray( IBinding.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getConversionOperators() throws DOMException {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPMethod[] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBinding binding = null;
|
||||||
|
ICPPMethod [] result = null;
|
||||||
|
|
||||||
|
IASTDeclaration [] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||||
|
IASTName name = null;
|
||||||
|
for ( int i = 0; i < decls.length; i++ ) {
|
||||||
|
if( decls[i] instanceof IASTSimpleDeclaration ){
|
||||||
|
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators();
|
||||||
|
for ( int j = 0; j < dtors.length; j++ ) {
|
||||||
|
name = CPPVisitor.getMostNestedDeclarator( dtors[j] ).getName();
|
||||||
|
if( name instanceof ICPPASTConversionName ){
|
||||||
|
binding = name.resolveBinding();
|
||||||
|
if( binding instanceof ICPPMethod)
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if( decls[i] instanceof IASTFunctionDefinition ){
|
||||||
|
IASTDeclarator dtor = ((IASTFunctionDefinition)decls[i]).getDeclarator();
|
||||||
|
name = CPPVisitor.getMostNestedDeclarator( dtor ).getName();
|
||||||
|
if( name instanceof ICPPASTConversionName ){
|
||||||
|
binding = name.resolveBinding();
|
||||||
|
if( binding instanceof ICPPMethod ){
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ICPPBase [] bases = getBases();
|
||||||
|
for ( int i = 0; i < bases.length; i++ ) {
|
||||||
|
ICPPClassType cls = null;
|
||||||
|
try {
|
||||||
|
IBinding b = bases[i].getBaseClass();
|
||||||
|
if( b instanceof ICPPClassType )
|
||||||
|
cls = (ICPPClassType) b;
|
||||||
|
} catch (DOMException e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if( cls instanceof ICPPInternalClassType )
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.addAll( ICPPMethod.class, result, ((ICPPInternalClassType)cls).getConversionOperators() );
|
||||||
|
}
|
||||||
|
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPBase [] getBases() {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ICPPASTBaseSpecifier [] bases = host.getCompositeTypeSpecifier().getBaseSpecifiers();
|
||||||
|
if( bases.length == 0 )
|
||||||
|
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||||
|
|
||||||
|
ICPPBase [] bindings = new ICPPBase[ bases.length ];
|
||||||
|
for( int i = 0; i < bases.length; i++ ){
|
||||||
|
bindings[i] = new CPPBaseClause( bases[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return bindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getMethods() throws DOMException {
|
||||||
|
ObjectSet set = new ObjectSet(4);
|
||||||
|
set.addAll(getDeclaredMethods());
|
||||||
|
ICPPClassScope scope = (ICPPClassScope) host.getCompositeScope();
|
||||||
|
set.addAll( scope.getImplicitMethods() );
|
||||||
|
ICPPBase [] bases = getBases();
|
||||||
|
for ( int i = 0; i < bases.length; i++ ) {
|
||||||
|
IBinding b = bases[i].getBaseClass();
|
||||||
|
if( b instanceof ICPPClassType )
|
||||||
|
set.addAll( ((ICPPClassType)b).getMethods() );
|
||||||
|
}
|
||||||
|
return (ICPPMethod[]) set.keyArray( ICPPMethod.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPField[] { new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBinding binding = null;
|
||||||
|
ICPPField [] result = null;
|
||||||
|
|
||||||
|
IASTDeclaration [] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||||
|
for ( int i = 0; i < decls.length; i++ ) {
|
||||||
|
if( decls[i] instanceof IASTSimpleDeclaration ){
|
||||||
|
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators();
|
||||||
|
for ( int j = 0; j < dtors.length; j++ ) {
|
||||||
|
binding = dtors[j].getName().resolveBinding();
|
||||||
|
if( binding instanceof ICPPField )
|
||||||
|
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, binding );
|
||||||
|
}
|
||||||
|
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
||||||
|
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
||||||
|
binding = n.resolveBinding();
|
||||||
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
|
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
|
for ( int j = 0; j < bs.length; j++ ) {
|
||||||
|
if( bs[j] instanceof ICPPField )
|
||||||
|
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, bs[j] );
|
||||||
|
}
|
||||||
|
} else if( binding instanceof ICPPField ) {
|
||||||
|
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, binding );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ICPPField[]) ArrayUtil.trim( ICPPField.class, result );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPMethod [] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ICPPMethod[] methods = getDeclaredMethods();
|
||||||
|
ICPPBase [] bases = getBases();
|
||||||
|
for ( int i = 0; i < bases.length; i++ ) {
|
||||||
|
IBinding b = bases[i].getBaseClass();
|
||||||
|
if( b instanceof ICPPClassType )
|
||||||
|
methods = (ICPPMethod[]) ArrayUtil.addAll( ICPPMethod.class, methods, ((ICPPClassType)b).getAllDeclaredMethods() );
|
||||||
|
}
|
||||||
|
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, methods );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPMethod[] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBinding binding = null;
|
||||||
|
ICPPMethod [] result = null;
|
||||||
|
|
||||||
|
IASTDeclaration [] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||||
|
for ( int i = 0; i < decls.length; i++ ) {
|
||||||
|
IASTDeclaration decl = decls[i];
|
||||||
|
while( decl instanceof ICPPASTTemplateDeclaration )
|
||||||
|
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||||
|
if( decl instanceof IASTSimpleDeclaration ){
|
||||||
|
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||||
|
for ( int j = 0; j < dtors.length; j++ ) {
|
||||||
|
binding = dtors[j].getName().resolveBinding();
|
||||||
|
if( binding instanceof ICPPMethod)
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
||||||
|
}
|
||||||
|
} else if( decl instanceof IASTFunctionDefinition ){
|
||||||
|
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
||||||
|
dtor = CPPVisitor.getMostNestedDeclarator( dtor );
|
||||||
|
binding = dtor.getName().resolveBinding();
|
||||||
|
if( binding instanceof ICPPMethod ){
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
||||||
|
}
|
||||||
|
} else if( decl instanceof ICPPASTUsingDeclaration ){
|
||||||
|
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
||||||
|
binding = n.resolveBinding();
|
||||||
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
|
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
|
for ( int j = 0; j < bs.length; j++ ) {
|
||||||
|
if( bs[j] instanceof ICPPMethod )
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, bs[j] );
|
||||||
|
}
|
||||||
|
} else if( binding instanceof ICPPMethod ) {
|
||||||
|
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
|
||||||
|
*/
|
||||||
|
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPConstructor [] { new CPPConstructor.CPPConstructorProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ICPPClassScope scope = (ICPPClassScope) host.getCompositeScope();
|
||||||
|
if(ASTInternal.isFullyCached(scope))
|
||||||
|
return ((CPPClassScope)scope).getConstructors( true );
|
||||||
|
|
||||||
|
IASTDeclaration [] members = host.getCompositeTypeSpecifier().getMembers();
|
||||||
|
for( int i = 0; i < members.length; i++ ){
|
||||||
|
IASTDeclaration decl = members[i];
|
||||||
|
if( decl instanceof ICPPASTTemplateDeclaration )
|
||||||
|
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||||
|
if( decl instanceof IASTSimpleDeclaration ){
|
||||||
|
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||||
|
for( int j = 0; j < dtors.length; j++ ){
|
||||||
|
if( dtors[j] == null ) break;
|
||||||
|
ASTInternal.addName(scope, dtors[j].getName() );
|
||||||
|
}
|
||||||
|
} else if( decl instanceof IASTFunctionDefinition ){
|
||||||
|
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
||||||
|
ASTInternal.addName(scope, dtor.getName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((CPPClassScope)scope).getConstructors( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICPPClassType[] getNestedClasses() {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new ICPPClassType[] { new CPPClassTypeProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ICPPClassType [] result = null;
|
||||||
|
|
||||||
|
IASTDeclaration [] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||||
|
for ( int i = 0; i < decls.length; i++ ) {
|
||||||
|
IASTDeclaration decl = decls[i];
|
||||||
|
while( decl instanceof ICPPASTTemplateDeclaration )
|
||||||
|
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||||
|
if( decl instanceof IASTSimpleDeclaration ){
|
||||||
|
IBinding binding = null;
|
||||||
|
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||||
|
if( declSpec instanceof ICPPASTCompositeTypeSpecifier ){
|
||||||
|
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
||||||
|
} else if( declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
||||||
|
((IASTSimpleDeclaration)decl).getDeclarators().length == 0 )
|
||||||
|
{
|
||||||
|
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
||||||
|
}
|
||||||
|
if( binding instanceof ICPPClassType )
|
||||||
|
result = (ICPPClassType[])ArrayUtil.append( ICPPClassType.class, result, binding );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ICPPClassType[]) ArrayUtil.trim( ICPPClassType.class, result );
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField[] getFields() throws DOMException {
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
host.checkForDefinition();
|
||||||
|
if( host.getDefinition() == null ){
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new IField [] { new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, host.getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IField[] fields = getDeclaredFields();
|
||||||
|
ICPPBase [] bases = getBases();
|
||||||
|
for ( int i = 0; i < bases.length; i++ ) {
|
||||||
|
IBinding b = bases[i].getBaseClass();
|
||||||
|
if( b instanceof ICPPClassType )
|
||||||
|
fields = (IField[]) ArrayUtil.addAll( IField.class, fields, ((ICPPClassType)b).getFields() );
|
||||||
|
}
|
||||||
|
return (IField[]) ArrayUtil.trim( IField.class, fields );
|
||||||
|
}
|
||||||
|
|
||||||
|
public IField findField(String name) throws DOMException {
|
||||||
|
IBinding [] bindings = CPPSemantics.findBindings( host.getCompositeScope(), name, true );
|
||||||
|
IField field = null;
|
||||||
|
for ( int i = 0; i < bindings.length; i++ ) {
|
||||||
|
if( bindings[i] instanceof IField ){
|
||||||
|
if( field == null )
|
||||||
|
field = (IField) bindings[i];
|
||||||
|
else {
|
||||||
|
IASTNode[] declarations= host.getDeclarations();
|
||||||
|
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
|
||||||
|
return new CPPField.CPPFieldProblem( node, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,11 +13,12 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public interface ICPPInternalClassType extends ICPPInternalBinding {
|
public interface ICPPInternalClassType extends ICPPInternalBinding {
|
||||||
public ICPPMethod [] getConversionOperators();
|
public ICPPMethod [] getConversionOperators() throws DOMException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal interface for exposing internal methods to ClassTypeMixin
|
||||||
|
*/
|
||||||
|
interface ICPPInternalClassTypeMixinHost extends ICPPInternalClassType, ICPPClassType {
|
||||||
|
/**
|
||||||
|
* @return the composite type specifier for the class type
|
||||||
|
*/
|
||||||
|
ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures the ICPPInternalBinding definition is set, if this is possible.
|
||||||
|
* @see ICPPInternalBinding#getDefinition()
|
||||||
|
*/
|
||||||
|
void checkForDefinition();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue