mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
toString methods and generics.
This commit is contained in:
parent
a2f9f9a4eb
commit
bd4d1ba488
10 changed files with 558 additions and 552 deletions
|
@ -25,6 +25,9 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
|
|||
private boolean isShort;
|
||||
private boolean isLong;
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
@ -65,19 +68,19 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
|
|||
isShort = value;
|
||||
}
|
||||
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitDeclSpecifiers ){
|
||||
switch( action.visit( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitDeclSpecifiers) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if( action.shouldVisitDeclSpecifiers ){
|
||||
switch( action.leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
if (action.shouldVisitDeclSpecifiers) {
|
||||
switch (action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,10 +29,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
|||
* @author jcamelon
|
||||
*/
|
||||
public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, IASTAmbiguityParent {
|
||||
|
||||
private IASTName templateName;
|
||||
private IASTNode[] templateArguments = null;
|
||||
private IBinding binding = null;
|
||||
private int fResolutionDepth = 0;
|
||||
|
||||
|
||||
public CPPASTTemplateId() {
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
}
|
||||
|
||||
public void addTemplateArgument(IASTTypeId typeId) {
|
||||
templateArguments = (IASTNode[]) ArrayUtil.append( IASTNode.class, templateArguments, typeId );
|
||||
templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, typeId);
|
||||
if (typeId != null) {
|
||||
typeId.setParent(this);
|
||||
typeId.setPropertyInParent(TEMPLATE_ID_ARGUMENT);
|
||||
|
@ -61,7 +62,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
}
|
||||
|
||||
public void addTemplateArgument(IASTExpression expression) {
|
||||
templateArguments = (IASTNode[]) ArrayUtil.append( IASTNode.class, templateArguments, expression );
|
||||
templateArguments = (IASTNode[]) ArrayUtil.append(IASTNode.class, templateArguments, expression);
|
||||
if (expression != null) {
|
||||
expression.setParent(this);
|
||||
expression.setPropertyInParent(TEMPLATE_ID_ARGUMENT);
|
||||
|
@ -69,61 +70,56 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
}
|
||||
|
||||
public IASTNode[] getTemplateArguments() {
|
||||
if( templateArguments == null ) return ICPPASTTemplateId.EMPTY_ARG_ARRAY;
|
||||
return (IASTNode[]) ArrayUtil.trim( IASTNode.class, templateArguments );
|
||||
if (templateArguments == null) return ICPPASTTemplateId.EMPTY_ARG_ARRAY;
|
||||
return (IASTNode[]) ArrayUtil.trim(IASTNode.class, templateArguments);
|
||||
}
|
||||
|
||||
private IASTNode [] templateArguments = null;
|
||||
private IBinding binding = null;
|
||||
private int fResolutionDepth= 0;
|
||||
|
||||
public IBinding resolveBinding() {
|
||||
if (binding == null) {
|
||||
// protect for infinite recursion
|
||||
if (++fResolutionDepth > CPPASTName.MAX_RESOLUTION_DEPTH) {
|
||||
binding= new CPPASTName.RecursionResolvingBinding(this);
|
||||
}
|
||||
else {
|
||||
binding = CPPTemplates.createBinding( this );
|
||||
} else {
|
||||
binding = CPPTemplates.createBinding(this);
|
||||
}
|
||||
}
|
||||
|
||||
return binding;
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
public IASTCompletionContext getCompletionContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public char[] toCharArray() {
|
||||
return templateName.toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return templateName.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitNames ){
|
||||
switch( action.visit( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitNames) {
|
||||
switch(action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if( templateName != null ) if( !templateName.accept( action ) ) return false;
|
||||
|
||||
IASTNode [] nodes = getTemplateArguments();
|
||||
for ( int i = 0; i < nodes.length; i++ ) {
|
||||
if( !nodes[i].accept( action ) ) return false;
|
||||
if (templateName != null && !templateName.accept(action)) return false;
|
||||
|
||||
IASTNode[] nodes = getTemplateArguments();
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
if (!nodes[i].accept(action)) return false;
|
||||
}
|
||||
if( action.shouldVisitNames ){
|
||||
switch( action.leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
if (action.shouldVisitNames) {
|
||||
switch(action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -138,7 +134,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
}
|
||||
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == templateName )
|
||||
if (n == templateName)
|
||||
return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
@ -149,11 +145,11 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
|
||||
public void setBinding(IBinding binding) {
|
||||
this.binding = binding;
|
||||
fResolutionDepth= 0;
|
||||
fResolutionDepth = 0;
|
||||
}
|
||||
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
if( templateArguments == null ) return;
|
||||
if (templateArguments == null) return;
|
||||
for (int i = 0; i < templateArguments.length; ++i) {
|
||||
if (child == templateArguments[i]) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
|
@ -162,20 +158,19 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isDefinition() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
int role = ((IASTNameOwner) parent).getRoleForName(this);
|
||||
if( role == IASTNameOwner.r_definition ) return true;
|
||||
return false;
|
||||
return role == IASTNameOwner.r_definition;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void incResolutionDepth() {
|
||||
if (binding == null && ++fResolutionDepth > CPPASTName.MAX_RESOLUTION_DEPTH) {
|
||||
binding= new CPPASTName.RecursionResolvingBinding(this);
|
||||
binding = new CPPASTName.RecursionResolvingBinding(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CPPASTUsingDirective extends CPPASTNode implements
|
|||
qualifiedName.setParent(this);
|
||||
qualifiedName.setPropertyInParent(QUALIFIED_NAME);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean accept( ASTVisitor action ){
|
||||
|
@ -57,9 +57,9 @@ public class CPPASTUsingDirective extends CPPASTNode implements
|
|||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( name != null ) if( !name.accept( action ) ) return false;
|
||||
|
||||
|
||||
if( action.shouldVisitDeclarations ){
|
||||
switch( action.leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
|
@ -76,17 +76,17 @@ public class CPPASTUsingDirective extends CPPASTNode implements
|
|||
return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
|
||||
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
|
||||
List filtered = new ArrayList();
|
||||
|
||||
List<IBinding> filtered = new ArrayList<IBinding>();
|
||||
|
||||
for (int i = 0;i < bindings.length; i++) {
|
||||
if (bindings[i] instanceof ICPPNamespace) {
|
||||
filtered.add(bindings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
|
||||
|
||||
return filtered.toArray(new IBinding[filtered.size()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @param args
|
||||
* @param arguments
|
||||
*/
|
||||
public CPPClassInstance( ICPPScope scope, IBinding decl, ObjectMap argMap, IType[] args ) {
|
||||
super( scope, decl, argMap, args );
|
||||
public CPPClassInstance(ICPPScope scope, IBinding decl, ObjectMap argMap, IType[] args) {
|
||||
super(scope, decl, argMap, args);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -51,17 +51,17 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
*/
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
ICPPClassType cls = (ICPPClassType) getSpecializedBinding();
|
||||
if( cls != null ){
|
||||
if (cls != null) {
|
||||
ICPPBase[] result = null;
|
||||
ICPPBase [] bindings = cls.getBases();
|
||||
ICPPBase[] bindings = cls.getBases();
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
ICPPBase specBinding = (ICPPBase) ((ICPPInternalBase)bindings[i]).clone();
|
||||
ICPPBase specBinding = (ICPPBase) ((ICPPInternalBase) bindings[i]).clone();
|
||||
IBinding base = bindings[i].getBaseClass();
|
||||
if (base instanceof IType) {
|
||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
||||
specBase = CPPSemantics.getUltimateType(specBase, false);
|
||||
if (specBase instanceof IBinding) {
|
||||
((ICPPInternalBase)specBinding).setBaseClass((IBinding)specBase);
|
||||
((ICPPInternalBase) specBinding).setBaseClass((IBinding) specBase);
|
||||
}
|
||||
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBinding);
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||
*/
|
||||
public IField[] getFields() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -83,7 +82,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
|
||||
*/
|
||||
public IField findField(String name) throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -91,7 +89,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
||||
*/
|
||||
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -99,7 +96,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
||||
*/
|
||||
public ICPPMethod[] getMethods() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -107,7 +103,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
||||
*/
|
||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -115,7 +110,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
||||
*/
|
||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -124,7 +118,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
*/
|
||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||
CPPClassSpecializationScope scope = (CPPClassSpecializationScope) getCompositeScope();
|
||||
if( scope.isFullyCached() )
|
||||
if (scope.isFullyCached())
|
||||
return scope.getConstructors();
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
@ -133,7 +127,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
||||
*/
|
||||
public IBinding[] getFriends() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -141,15 +134,15 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
||||
*/
|
||||
public int getKey() throws DOMException {
|
||||
return ((ICPPClassType)getSpecializedBinding()).getKey();
|
||||
return ((ICPPClassType) getSpecializedBinding()).getKey();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
||||
*/
|
||||
public IScope getCompositeScope() {
|
||||
if( instanceScope == null ){
|
||||
instanceScope = new CPPClassSpecializationScope( this );
|
||||
if (instanceScope == null) {
|
||||
instanceScope = new CPPClassSpecializationScope(this);
|
||||
}
|
||||
return instanceScope;
|
||||
}
|
||||
|
@ -158,35 +151,35 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone(){
|
||||
// TODO Auto-generated method stub
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (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 )
|
||||
public boolean isSameType(IType type) {
|
||||
if (type == this)
|
||||
return true;
|
||||
if( type instanceof ITypedef || type instanceof IIndexType )
|
||||
return type.isSameType( this );
|
||||
if( type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType )
|
||||
return type.isSameType( this ); //the CPPDeferredClassInstance has some fuzziness
|
||||
if (type instanceof ITypedef || type instanceof IIndexType)
|
||||
return type.isSameType(this);
|
||||
if (type instanceof ICPPDeferredTemplateInstance && type instanceof ICPPClassType)
|
||||
return type.isSameType(this); // the CPPDeferredClassInstance has some fuzziness
|
||||
|
||||
if( type instanceof ICPPTemplateInstance ){
|
||||
if (type instanceof ICPPTemplateInstance) {
|
||||
ICPPClassType ct1= (ICPPClassType) getSpecializedBinding();
|
||||
ICPPClassType ct2= (ICPPClassType) ((ICPPTemplateInstance)type).getTemplateDefinition();
|
||||
if(!ct1.isSameType(ct2))
|
||||
ICPPClassType ct2= (ICPPClassType) ((ICPPTemplateInstance) type).getTemplateDefinition();
|
||||
if (!ct1.isSameType(ct2))
|
||||
return false;
|
||||
|
||||
ObjectMap m1 = getArgumentMap(), m2 = ((ICPPTemplateInstance)type).getArgumentMap();
|
||||
if( m1 == null || m2 == null || m1.size() != m2.size())
|
||||
ObjectMap m1 = getArgumentMap();
|
||||
ObjectMap m2 = ((ICPPTemplateInstance) type).getArgumentMap();
|
||||
if (m1 == null || m2 == null || m1.size() != m2.size())
|
||||
return false;
|
||||
for( int i = 0; i < m1.size(); i++ ){
|
||||
IType t1 = (IType) m1.getAt( i );
|
||||
IType t2 = (IType) m2.getAt( i );
|
||||
if( t1 == null || ! t1.isSameType( t2 ) )
|
||||
for (int i = 0; i < m1.size(); i++) {
|
||||
IType t1 = (IType) m1.getAt(i);
|
||||
IType t2 = (IType) m2.getAt(i);
|
||||
if (t1 == null || !t1.isSameType(t2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -210,6 +203,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof ICPPClassType ? isSameType((ICPPClassType)obj) : false;
|
||||
return obj instanceof ICPPClassType && isSameType((ICPPClassType) obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
|
@ -57,177 +56,177 @@ import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||
private static final char [] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
|
||||
private ICPPMethod[] implicits = null;
|
||||
|
||||
public CPPClassScope( ICPPASTCompositeTypeSpecifier physicalNode ) {
|
||||
super( physicalNode );
|
||||
((CPPASTCompositeTypeSpecifier)physicalNode).setScope( this );
|
||||
|
||||
public CPPClassScope(ICPPASTCompositeTypeSpecifier physicalNode) {
|
||||
super(physicalNode);
|
||||
((CPPASTCompositeTypeSpecifier) physicalNode).setScope(this);
|
||||
createImplicitMembers();
|
||||
}
|
||||
|
||||
// 12.1 The default constructor, copy constructor, copy assignment operator, and destructor are
|
||||
//special member functions. The implementation will implicitly declare these member functions
|
||||
//for a class type when the program does not declare them.
|
||||
private void createImplicitMembers(){
|
||||
private void createImplicitMembers() {
|
||||
//create bindings for the implicit members, if the user declared them then those declarations
|
||||
//will resolve to these bindings.
|
||||
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
|
||||
|
||||
IASTName name = compTypeSpec.getName();
|
||||
if( name instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName) name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
|
||||
name = ns[ns.length - 1];
|
||||
}
|
||||
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
if( !(binding instanceof ICPPClassType ) )
|
||||
if (!(binding instanceof ICPPClassType))
|
||||
return;
|
||||
|
||||
|
||||
ICPPClassType clsType = (ICPPClassType) binding;
|
||||
if( clsType instanceof ICPPClassTemplate ){
|
||||
if (clsType instanceof ICPPClassTemplate) {
|
||||
try {
|
||||
IBinding within = CPPTemplates.instantiateWithinClassTemplate( (ICPPClassTemplate) clsType );
|
||||
IBinding within = CPPTemplates.instantiateWithinClassTemplate((ICPPClassTemplate) clsType);
|
||||
if (within instanceof ICPPClassType)
|
||||
clsType = (ICPPClassType)within;
|
||||
} catch ( DOMException e ) {
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
char [] className = name.toCharArray();
|
||||
|
||||
IParameter [] voidPs = new IParameter [] { new CPPParameter( CPPSemantics.VOID_TYPE ) };
|
||||
IType pType = new CPPReferenceType( new CPPQualifierType( clsType, true, false ) );
|
||||
IParameter [] ps = new IParameter [] { new CPPParameter( pType ) };
|
||||
|
||||
char[] className = name.toCharArray();
|
||||
|
||||
IParameter[] voidPs = new IParameter[] { new CPPParameter(CPPSemantics.VOID_TYPE) };
|
||||
IType pType = new CPPReferenceType(new CPPQualifierType(clsType, true, false));
|
||||
IParameter[] ps = new IParameter[] { new CPPParameter(pType) };
|
||||
|
||||
int i= 0;
|
||||
ImplicitsAnalysis ia= new ImplicitsAnalysis( compTypeSpec );
|
||||
ImplicitsAnalysis ia= new ImplicitsAnalysis(compTypeSpec);
|
||||
implicits= new ICPPMethod[ia.getImplicitsToDeclareCount()];
|
||||
|
||||
if( !ia.hasUserDeclaredConstructor() ) {
|
||||
if (!ia.hasUserDeclaredConstructor()) {
|
||||
//default constructor: A(void)
|
||||
ICPPMethod m = new CPPImplicitConstructor( this, className, voidPs );
|
||||
implicits[i++]=m;
|
||||
addBinding( m );
|
||||
ICPPMethod m = new CPPImplicitConstructor(this, className, voidPs);
|
||||
implicits[i++] = m;
|
||||
addBinding(m);
|
||||
}
|
||||
|
||||
if( !ia.hasUserDeclaredCopyConstructor() ) {
|
||||
//copy constructor: A( const A & )
|
||||
if (!ia.hasUserDeclaredCopyConstructor()) {
|
||||
//copy constructor: A(const A &)
|
||||
|
||||
ICPPMethod m = new CPPImplicitConstructor( this, className, ps );
|
||||
ICPPMethod m = new CPPImplicitConstructor(this, className, ps);
|
||||
implicits[i++]=m;
|
||||
addBinding( m );
|
||||
addBinding(m);
|
||||
}
|
||||
|
||||
if( !ia.hasUserDeclaredCopyAssignmentOperator() ) {
|
||||
//copy assignment operator: A& operator = ( const A & )
|
||||
IType refType = new CPPReferenceType( clsType );
|
||||
ICPPMethod m = new CPPImplicitMethod( this, OverloadableOperator.ASSIGN.toCharArray(), refType, ps );
|
||||
implicits[i++]=m;
|
||||
addBinding( m );
|
||||
if (!ia.hasUserDeclaredCopyAssignmentOperator()) {
|
||||
//copy assignment operator: A& operator = (const A &)
|
||||
IType refType = new CPPReferenceType(clsType);
|
||||
ICPPMethod m = new CPPImplicitMethod(this, OverloadableOperator.ASSIGN.toCharArray(), refType, ps);
|
||||
implicits[i++] = m;
|
||||
addBinding(m);
|
||||
}
|
||||
|
||||
if( !ia.hasUserDeclaredDestructor() ) {
|
||||
if (!ia.hasUserDeclaredDestructor()) {
|
||||
//destructor: ~A()
|
||||
char [] dtorName = CharArrayUtils.concat( "~".toCharArray(), className ); //$NON-NLS-1$
|
||||
ICPPMethod m = new CPPImplicitMethod( this, dtorName, new CPPBasicType( IBasicType.t_unspecified, 0 ), voidPs );
|
||||
implicits[i++]=m;
|
||||
addBinding( m );
|
||||
char[] dtorName = CharArrayUtils.concat("~".toCharArray(), className); //$NON-NLS-1$
|
||||
ICPPMethod m = new CPPImplicitMethod(this, dtorName, new CPPBasicType(IBasicType.t_unspecified, 0), voidPs);
|
||||
implicits[i++] = m;
|
||||
addBinding(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IScope getParent() {
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IASTName compName = compType.getName();
|
||||
if( compName instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ ns.length - 1 ];
|
||||
if (compName instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ns.length - 1];
|
||||
}
|
||||
return CPPVisitor.getContainingScope( compName );
|
||||
return CPPVisitor.getContainingScope(compName);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#addBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void addBinding(IBinding binding) {
|
||||
if( binding instanceof ICPPConstructor ){
|
||||
addConstructor( binding );
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
addConstructor(binding);
|
||||
return;
|
||||
}
|
||||
super.addBinding(binding);
|
||||
}
|
||||
|
||||
public void addName(IASTName name) {
|
||||
if( name instanceof ICPPASTQualifiedName )
|
||||
if (name instanceof ICPPASTQualifiedName)
|
||||
return;
|
||||
|
||||
|
||||
IASTNode parent = name.getParent();
|
||||
if( parent instanceof IASTDeclarator ){
|
||||
if( CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){
|
||||
addConstructor( name );
|
||||
if (parent instanceof IASTDeclarator) {
|
||||
if (CPPVisitor.isConstructor(this, (IASTDeclarator) parent)) {
|
||||
addConstructor(name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.addName( name );
|
||||
super.addName(name);
|
||||
}
|
||||
|
||||
private void addConstructor( Object constructor ){
|
||||
if( bindings == null )
|
||||
private void addConstructor(Object constructor) {
|
||||
if (bindings == null)
|
||||
bindings = new CharArrayObjectMap(1);
|
||||
|
||||
if( constructor instanceof IASTName && ((IASTName)constructor).getBinding() != null ){
|
||||
|
||||
if (constructor instanceof IASTName && ((IASTName)constructor).getBinding() != null) {
|
||||
constructor = ((IASTName)constructor).getBinding();
|
||||
}
|
||||
|
||||
Object o = bindings.get( CONSTRUCTOR_KEY );
|
||||
if( o != null ){
|
||||
if( o instanceof ObjectSet ){
|
||||
((ObjectSet)o).put( constructor );
|
||||
|
||||
Object o = bindings.get(CONSTRUCTOR_KEY);
|
||||
if (o != null) {
|
||||
if (o instanceof ObjectSet) {
|
||||
((ObjectSet)o).put(constructor);
|
||||
} else {
|
||||
ObjectSet set = new ObjectSet(2);
|
||||
set.put( o );
|
||||
set.put( constructor );
|
||||
bindings.put( CONSTRUCTOR_KEY, set );
|
||||
set.put(o);
|
||||
set.put(constructor);
|
||||
bindings.put(CONSTRUCTOR_KEY, set);
|
||||
}
|
||||
} else {
|
||||
bindings.put( CONSTRUCTOR_KEY, constructor );
|
||||
bindings.put(CONSTRUCTOR_KEY, constructor);
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
|
||||
*/
|
||||
public IBinding getBinding( IASTName name, boolean resolve, IIndexFileSet fileSet ) throws DOMException {
|
||||
char [] c = name.toCharArray();
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
|
||||
char[] c = name.toCharArray();
|
||||
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IASTName compName = compType.getName();
|
||||
if( compName instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ ns.length - 1 ];
|
||||
if (compName instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ns.length - 1];
|
||||
}
|
||||
if( CharArrayUtils.equals( c, compName.toCharArray() ) ){
|
||||
if( isConstructorReference( name ) ){
|
||||
return CPPSemantics.resolveAmbiguities( name, getConstructors( bindings, resolve, name ) );
|
||||
if (CharArrayUtils.equals(c, compName.toCharArray())) {
|
||||
if (isConstructorReference(name)) {
|
||||
return CPPSemantics.resolveAmbiguities(name, getConstructors(bindings, resolve, name));
|
||||
}
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
return compName.resolveBinding();
|
||||
}
|
||||
return super.getBinding( name, resolve, fileSet);
|
||||
return super.getBinding(name, resolve, fileSet);
|
||||
}
|
||||
|
||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
|
||||
char [] c = name.toCharArray();
|
||||
|
||||
char[] c = name.toCharArray();
|
||||
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IASTName compName = compType.getName();
|
||||
if( compName instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ ns.length - 1 ];
|
||||
if (compName instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ns.length - 1];
|
||||
}
|
||||
IBinding[] result = null;
|
||||
if( (!prefixLookup && CharArrayUtils.equals( c, compName.toCharArray() ))
|
||||
|| (prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, c.length, c, true)) ){
|
||||
if( isConstructorReference( name ) ){
|
||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors( bindings, resolve, name ));
|
||||
if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray()))
|
||||
|| (prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, c.length, c, true))) {
|
||||
if (isConstructorReference(name)) {
|
||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors(bindings, resolve, name));
|
||||
}
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, compName.resolveBinding());
|
||||
|
@ -235,100 +234,101 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
||||
}
|
||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result,
|
||||
super.getBindings( name, resolve, prefixLookup, fileSet ));
|
||||
super.getBindings(name, resolve, prefixLookup, fileSet));
|
||||
return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
||||
}
|
||||
|
||||
|
||||
static protected boolean shouldResolve(boolean force, IASTName candidate, IASTName forName) {
|
||||
if(!force || candidate == forName)
|
||||
if (!force || candidate == forName)
|
||||
return false;
|
||||
if(forName == null)
|
||||
if (forName == null)
|
||||
return true;
|
||||
if(!forName.isReference() && !CPPSemantics.declaredBefore(candidate, forName, false))
|
||||
if (!forName.isReference() && !CPPSemantics.declaredBefore(candidate, forName, false))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ICPPConstructor [] getConstructors( boolean forceResolve ){
|
||||
return getConstructors( bindings, forceResolve, null );
|
||||
}
|
||||
static protected ICPPConstructor [] getConstructors( CharArrayObjectMap bindings, boolean forceResolve ) {
|
||||
|
||||
protected ICPPConstructor[] getConstructors(boolean forceResolve) {
|
||||
return getConstructors(bindings, forceResolve, null);
|
||||
}
|
||||
static protected ICPPConstructor [] getConstructors( CharArrayObjectMap bindings, boolean forceResolve, IASTName forName ){
|
||||
if( bindings == null )
|
||||
static protected ICPPConstructor[] getConstructors(CharArrayObjectMap bindings, boolean forceResolve) {
|
||||
return getConstructors(bindings, forceResolve, null);
|
||||
}
|
||||
static protected ICPPConstructor[] getConstructors(CharArrayObjectMap bindings, boolean forceResolve, IASTName forName) {
|
||||
if (bindings == null)
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
|
||||
Object o = bindings.get( CONSTRUCTOR_KEY );
|
||||
if( o != null ){
|
||||
|
||||
Object o = bindings.get(CONSTRUCTOR_KEY);
|
||||
if (o != null) {
|
||||
IBinding binding = null;
|
||||
if( o instanceof ObjectSet ) {
|
||||
if (o instanceof ObjectSet) {
|
||||
ObjectSet set = (ObjectSet) o;
|
||||
IBinding [] bs = null;
|
||||
for( int i = 0; i < set.size(); i++ ){
|
||||
Object obj = set.keyAt( i );
|
||||
if( obj instanceof IASTName ){
|
||||
IASTName n = (IASTName) obj;
|
||||
IBinding[] bs = null;
|
||||
for (int i = 0; i < set.size(); i++) {
|
||||
Object obj = set.keyAt(i);
|
||||
if (obj instanceof IASTName) {
|
||||
IASTName n = (IASTName) obj;
|
||||
binding = shouldResolve(forceResolve, n, forName) ? n.resolveBinding() : n.getBinding();
|
||||
if( binding != null ) {
|
||||
set.remove( n );
|
||||
set.put( binding );
|
||||
if (binding != null) {
|
||||
set.remove(n);
|
||||
set.put(binding);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
} else if( obj instanceof ICPPConstructor )
|
||||
bs = (IBinding[]) ArrayUtil.append( ICPPConstructor.class, bs, obj );
|
||||
}
|
||||
return (ICPPConstructor[]) ArrayUtil.trim( ICPPConstructor.class, bs );
|
||||
} else if( o instanceof IASTName ){
|
||||
if( shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName)o).getBinding() != null ){
|
||||
} else if (obj instanceof ICPPConstructor) {
|
||||
bs = (IBinding[]) ArrayUtil.append(ICPPConstructor.class, bs, obj);
|
||||
}
|
||||
}
|
||||
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, bs);
|
||||
} else if (o instanceof IASTName) {
|
||||
if (shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName)o).getBinding() != null) {
|
||||
binding = ((IASTName)o).resolveBinding();
|
||||
bindings.put( CONSTRUCTOR_KEY, binding );
|
||||
bindings.put(CONSTRUCTOR_KEY, binding);
|
||||
}
|
||||
} else if( o instanceof IBinding ){
|
||||
} else if (o instanceof IBinding) {
|
||||
binding = (IBinding) o;
|
||||
}
|
||||
if( binding != null && binding instanceof ICPPConstructor){
|
||||
if (binding != null && binding instanceof ICPPConstructor) {
|
||||
return new ICPPConstructor[] { (ICPPConstructor) binding };
|
||||
}
|
||||
}
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||
*/
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
char [] n = name.toCharArray();
|
||||
char[] n = name.toCharArray();
|
||||
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
|
||||
IASTName compName = compType.getName();
|
||||
if( compName instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ ns.length - 1 ];
|
||||
if (compName instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames();
|
||||
compName = ns[ns.length - 1];
|
||||
}
|
||||
|
||||
if(CharArrayUtils.equals(compName.toCharArray(), n)) {
|
||||
if (CharArrayUtils.equals(compName.toCharArray(), n)) {
|
||||
return new IBinding[] {getClassType()};
|
||||
}
|
||||
|
||||
|
||||
return super.find(name);
|
||||
}
|
||||
|
||||
public static boolean isConstructorReference( IASTName name ){
|
||||
if( name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false;
|
||||
|
||||
public static boolean isConstructorReference(IASTName name) {
|
||||
if (name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return false;
|
||||
IASTNode node = name.getParent();
|
||||
if( node instanceof ICPPASTTemplateId )
|
||||
if (node instanceof ICPPASTTemplateId)
|
||||
node = node.getParent();
|
||||
if( node instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)node).getNames();
|
||||
if( ns[ ns.length - 1 ] == name )
|
||||
if (node instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] ns = ((ICPPASTQualifiedName)node).getNames();
|
||||
if (ns[ns.length - 1] == name)
|
||||
node = node.getParent();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
if( node instanceof IASTDeclSpecifier ){
|
||||
if (node instanceof IASTDeclSpecifier) {
|
||||
IASTNode parent = node.getParent();
|
||||
if( parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression )
|
||||
if (parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -344,15 +344,15 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
if (binding instanceof ICPPClassType)
|
||||
return (ICPPClassType) binding;
|
||||
|
||||
return new CPPClassType.CPPClassTypeProblem( compSpec.getName(), IProblemBinding.SEMANTIC_BAD_SCOPE, compSpec.getName().toCharArray() );
|
||||
return new CPPClassType.CPPClassTypeProblem(compSpec.getName(), IProblemBinding.SEMANTIC_BAD_SCOPE, compSpec.getName().toCharArray());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
|
||||
*/
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
if( implicits == null )
|
||||
implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem( null, IProblemBinding.SEMANTIC_INVALID_TYPE, CPPSemantics.EMPTY_NAME_ARRAY ) };
|
||||
if (implicits == null)
|
||||
implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem(null, IProblemBinding.SEMANTIC_INVALID_TYPE, CPPSemantics.EMPTY_NAME_ARRAY) };
|
||||
return implicits;
|
||||
}
|
||||
|
||||
|
@ -361,20 +361,20 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
*/
|
||||
public IName getScopeName() {
|
||||
IASTNode node = getPhysicalNode();
|
||||
if( node instanceof ICPPASTCompositeTypeSpecifier ){
|
||||
if (node instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
return ((ICPPASTCompositeTypeSpecifier)node).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void removeBinding(IBinding binding) {
|
||||
if( binding instanceof ICPPConstructor ){
|
||||
removeBinding( CONSTRUCTOR_KEY, binding );
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
removeBinding(CONSTRUCTOR_KEY, binding);
|
||||
} else {
|
||||
removeBinding( binding.getNameCharArray(), binding );
|
||||
removeBinding(binding.getNameCharArray(), binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,31 +382,31 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
/**
|
||||
* Helps analysis of the class declaration for user declared members relevant
|
||||
* to deciding which implicit bindings to declare.
|
||||
*
|
||||
*
|
||||
* @see chapter 12 of the ISO specification
|
||||
*/
|
||||
*/
|
||||
class ImplicitsAnalysis {
|
||||
private boolean hasUserDeclaredConstructor;
|
||||
private boolean hasUserDeclaredCopyConstructor;
|
||||
private boolean hasUserDeclaredCopyAssignmentOperator;
|
||||
private boolean hasUserDeclaredDestructor;
|
||||
|
||||
ImplicitsAnalysis( ICPPASTCompositeTypeSpecifier compSpec ) {
|
||||
|
||||
ImplicitsAnalysis(ICPPASTCompositeTypeSpecifier compSpec) {
|
||||
ICPPASTFunctionDeclarator[] ctors= getUserDeclaredCtorOrDtor(compSpec, true);
|
||||
|
||||
|
||||
hasUserDeclaredConstructor= ctors.length> 0;
|
||||
hasUserDeclaredCopyConstructor= false;
|
||||
hasUserDeclaredCopyAssignmentOperator= false;
|
||||
hasUserDeclaredDestructor= getUserDeclaredCtorOrDtor(compSpec, false).length>0;
|
||||
|
||||
outer: for(int i=0; i<ctors.length; i++) {
|
||||
|
||||
outer: for (int i=0; i<ctors.length; i++) {
|
||||
ICPPASTFunctionDeclarator dcltor= ctors[i];
|
||||
IASTParameterDeclaration [] ps = dcltor.getParameters();
|
||||
if( ps.length >= 1 ){
|
||||
if(paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) {
|
||||
// and all remaining arguments have initialisers
|
||||
for(int j=1; j<ps.length; j++) {
|
||||
if( ps[j].getDeclarator().getInitializer() == null ) {
|
||||
IASTParameterDeclaration[] ps = dcltor.getParameters();
|
||||
if (ps.length >= 1) {
|
||||
if (paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) {
|
||||
// and all remaining arguments have initializers
|
||||
for (int j = 1; j < ps.length; j++) {
|
||||
if (ps[j].getDeclarator().getInitializer() == null) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
@ -414,89 +414,88 @@ class ImplicitsAnalysis {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean hasUserDeclaredCAO= getUserDeclaredCopyAssignmentOperators(compSpec).length > 0;
|
||||
hasUserDeclaredCopyAssignmentOperator= hasUserDeclaredCAO;
|
||||
}
|
||||
|
||||
|
||||
public int getImplicitsToDeclareCount() {
|
||||
return (!hasUserDeclaredDestructor ? 1 : 0)
|
||||
+ (!hasUserDeclaredConstructor ? 1 : 0)
|
||||
+ (!hasUserDeclaredCopyConstructor ? 1 : 0)
|
||||
+ (!hasUserDeclaredCopyAssignmentOperator ? 1 : 0);
|
||||
}
|
||||
|
||||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor( ICPPASTCompositeTypeSpecifier compSpec, boolean constructor ) {
|
||||
|
||||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCtorOrDtor(ICPPASTCompositeTypeSpecifier compSpec, boolean constructor) {
|
||||
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
|
||||
IASTDeclaration [] members = compSpec.getMembers();
|
||||
char [] name = compSpec.getName().toCharArray();
|
||||
IASTDeclaration[] members = compSpec.getMembers();
|
||||
char[] name = compSpec.getName().toCharArray();
|
||||
IASTDeclarator dcltor = null;
|
||||
IASTDeclSpecifier spec = null;
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i] instanceof IASTSimpleDeclaration ){
|
||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
||||
if( dtors.length == 0 || dtors.length > 1 )
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i] instanceof IASTSimpleDeclaration) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
||||
if (dtors.length == 0 || dtors.length > 1)
|
||||
continue;
|
||||
dcltor = dtors[0];
|
||||
spec = ((IASTSimpleDeclaration)members[i]).getDeclSpecifier();
|
||||
} else if( members[i] instanceof IASTFunctionDefinition ){
|
||||
} else if (members[i] instanceof IASTFunctionDefinition) {
|
||||
dcltor = ((IASTFunctionDefinition)members[i]).getDeclarator();
|
||||
spec = ((IASTFunctionDefinition)members[i]).getDeclSpecifier();
|
||||
}
|
||||
|
||||
|
||||
if( !(dcltor instanceof ICPPASTFunctionDeclarator) || !(spec instanceof IASTSimpleDeclSpecifier) ||
|
||||
((IASTSimpleDeclSpecifier)spec).getType() != IASTSimpleDeclSpecifier.t_unspecified)
|
||||
{
|
||||
|
||||
|
||||
if (!(dcltor instanceof ICPPASTFunctionDeclarator) || !(spec instanceof IASTSimpleDeclSpecifier) ||
|
||||
((IASTSimpleDeclSpecifier)spec).getType() != IASTSimpleDeclSpecifier.t_unspecified) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
boolean nameEquals= false;
|
||||
if(constructor) {
|
||||
nameEquals= CharArrayUtils.equals( dcltor.getName().toCharArray(), name );
|
||||
if (constructor) {
|
||||
nameEquals= CharArrayUtils.equals(dcltor.getName().toCharArray(), name);
|
||||
} else {
|
||||
char[] cname= dcltor.getName().toCharArray();
|
||||
if(cname.length>0 && cname[0]=='~') {
|
||||
nameEquals= CharArrayUtils.equals( cname, 1, name.length, name );
|
||||
if (cname.length > 0 && cname[0] == '~') {
|
||||
nameEquals= CharArrayUtils.equals(cname, 1, name.length, name);
|
||||
}
|
||||
}
|
||||
|
||||
if(!nameEquals)
|
||||
|
||||
if (!nameEquals)
|
||||
continue;
|
||||
|
||||
|
||||
result.add((ICPPASTFunctionDeclarator) dcltor);
|
||||
}
|
||||
return result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
|
||||
}
|
||||
|
||||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators( ICPPASTCompositeTypeSpecifier compSpec ) {
|
||||
|
||||
private static ICPPASTFunctionDeclarator[] getUserDeclaredCopyAssignmentOperators(ICPPASTCompositeTypeSpecifier compSpec) {
|
||||
List<ICPPASTFunctionDeclarator> result= new ArrayList<ICPPASTFunctionDeclarator>();
|
||||
IASTDeclaration [] members = compSpec.getMembers();
|
||||
IASTDeclaration[] members = compSpec.getMembers();
|
||||
IASTDeclarator dcltor = null;
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i] instanceof IASTSimpleDeclaration ){
|
||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
||||
if( dtors.length == 0 || dtors.length > 1 )
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i] instanceof IASTSimpleDeclaration) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
||||
if (dtors.length == 0 || dtors.length > 1)
|
||||
continue;
|
||||
dcltor = dtors[0];
|
||||
} else if( members[i] instanceof IASTFunctionDefinition ){
|
||||
} else if (members[i] instanceof IASTFunctionDefinition) {
|
||||
dcltor = ((IASTFunctionDefinition)members[i]).getDeclarator();
|
||||
}
|
||||
if( !(dcltor instanceof ICPPASTFunctionDeclarator) ||
|
||||
!CharArrayUtils.equals( dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray() ) )
|
||||
if (!(dcltor instanceof ICPPASTFunctionDeclarator) ||
|
||||
!CharArrayUtils.equals(dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IASTParameterDeclaration [] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters();
|
||||
if(ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0], null))
|
||||
|
||||
IASTParameterDeclaration[] ps = ((ICPPASTFunctionDeclarator)dcltor).getParameters();
|
||||
if (ps.length != 1 || !paramHasTypeReferenceToTheAssociatedClassType(ps[0], null))
|
||||
continue;
|
||||
|
||||
|
||||
result.add((ICPPASTFunctionDeclarator)dcltor);
|
||||
}
|
||||
return result.toArray(new ICPPASTFunctionDeclarator[result.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param compSpec the name the parameter must have in order to match, or null for any name
|
||||
* @param dec
|
||||
|
@ -506,10 +505,10 @@ class ImplicitsAnalysis {
|
|||
private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) {
|
||||
boolean result= false;
|
||||
IASTDeclarator pdtor= dec.getDeclarator();
|
||||
if(pdtor.getPointerOperators().length==1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) {
|
||||
if(dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
|
||||
if (pdtor.getPointerOperators().length == 1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) {
|
||||
if (dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
|
||||
ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier();
|
||||
if(name==null || name.equals(nts.getName().getRawSignature())) {
|
||||
if (name == null || name.equals(nts.getName().getRawSignature())) {
|
||||
result= true;
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +527,7 @@ class ImplicitsAnalysis {
|
|||
public boolean hasUserDeclaredCopyAssignmentOperator() {
|
||||
return hasUserDeclaredCopyAssignmentOperator;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasUserDeclaredDestructor() {
|
||||
return hasUserDeclaredDestructor;
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
implements ICPPClassTemplate, ICPPInternalClassTemplate {
|
||||
|
||||
private ObjectMap instances = null;
|
||||
|
||||
|
||||
/**
|
||||
* @param specialized
|
||||
* @param scope
|
||||
* @param argumentMap
|
||||
*/
|
||||
public CPPClassTemplateSpecialization(IBinding specialized,
|
||||
ICPPScope scope, ObjectMap argumentMap) {
|
||||
public CPPClassTemplateSpecialization(IBinding specialized, ICPPScope scope,
|
||||
ObjectMap argumentMap) {
|
||||
super(specialized, scope, argumentMap);
|
||||
}
|
||||
|
||||
|
@ -61,31 +61,31 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
}
|
||||
|
||||
public void addSpecialization(IType[] arguments, ICPPSpecialization specialization) {
|
||||
if( instances == null )
|
||||
if (instances == null)
|
||||
instances = new ObjectMap(2);
|
||||
instances.put( arguments, specialization );
|
||||
instances.put(arguments, specialization);
|
||||
}
|
||||
|
||||
public ICPPSpecialization getInstance( IType [] arguments ) {
|
||||
if( instances == null )
|
||||
|
||||
public ICPPSpecialization getInstance(IType[] arguments) {
|
||||
if (instances == null)
|
||||
return null;
|
||||
|
||||
|
||||
int found = -1;
|
||||
for( int i = 0; i < instances.size(); i++ ){
|
||||
IType [] args = (IType[]) instances.keyAt( i );
|
||||
if( args.length == arguments.length ){
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
IType[] args = (IType[]) instances.keyAt(i);
|
||||
if (args.length == arguments.length) {
|
||||
int j = 0;
|
||||
for(; j < args.length; j++) {
|
||||
if( !( args[j].isSameType( arguments[j] ) ) )
|
||||
if (!(args[j].isSameType(arguments[j])))
|
||||
break;
|
||||
}
|
||||
if( j == args.length ){
|
||||
if (j == args.length) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( found != -1 ){
|
||||
if (found != -1) {
|
||||
return (ICPPSpecialization) instances.getAt(found);
|
||||
}
|
||||
return null;
|
||||
|
@ -93,28 +93,32 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
|
||||
public IBinding instantiate(IType[] arguments) {
|
||||
ICPPTemplateDefinition template = null;
|
||||
|
||||
|
||||
try {
|
||||
template = CPPTemplates.matchTemplatePartialSpecialization( this, arguments );
|
||||
template = CPPTemplates.matchTemplatePartialSpecialization(this, arguments);
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
}
|
||||
|
||||
if( template instanceof IProblemBinding )
|
||||
|
||||
if (template instanceof IProblemBinding) {
|
||||
return template;
|
||||
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
||||
return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );
|
||||
}
|
||||
|
||||
return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
|
||||
if (template != null && template instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
return ((ICPPInternalTemplateInstantiator) template).instantiate(arguments);
|
||||
}
|
||||
|
||||
return CPPTemplates.instantiateTemplate(this, arguments, argumentMap);
|
||||
}
|
||||
|
||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ){
|
||||
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
|
||||
//should not occur
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,21 +34,21 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
|
|||
private ICPPScope scope = null;
|
||||
private IASTName name = null;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public CPPUnknownBinding( ICPPScope scope, IBinding scopeBinding, IASTName name ) {
|
||||
public CPPUnknownBinding(ICPPScope scope, IBinding scopeBinding, IASTName name) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.scopeBinding = scopeBinding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)```
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#getUnknownScope()
|
||||
*/
|
||||
public ICPPScope getUnknownScope() {
|
||||
if( unknownScope == null ){
|
||||
unknownScope = new CPPUnknownScope( this, name );
|
||||
if (unknownScope == null) {
|
||||
unknownScope = new CPPUnknownScope(this, name);
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
@ -70,33 +70,33 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void addDefinition( IASTNode node ) {
|
||||
public void addDefinition(IASTNode node) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void addDeclaration( IASTNode node ) {
|
||||
public void addDeclaration(IASTNode node) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#removeDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void removeDeclaration( IASTNode node ) {
|
||||
public void removeDeclaration(IASTNode node) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#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() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
return CPPVisitor.getQualifiedNameCharArray(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -130,26 +130,33 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
|
||||
*/
|
||||
public IBinding resolveUnknown( ObjectMap argMap ) throws DOMException {
|
||||
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
|
||||
IBinding result = this;
|
||||
if( argMap.containsKey( scopeBinding ) ){
|
||||
IType t = (IType) argMap.get( scopeBinding );
|
||||
t = CPPSemantics.getUltimateType( t, false );
|
||||
if( t instanceof ICPPClassType ){
|
||||
if (argMap.containsKey(scopeBinding)) {
|
||||
IType t = (IType) argMap.get(scopeBinding);
|
||||
t = CPPSemantics.getUltimateType(t, false);
|
||||
if (t instanceof ICPPClassType) {
|
||||
IScope s = ((ICPPClassType)t).getCompositeScope();
|
||||
|
||||
if( s != null && ASTInternal.isFullyCached(s) )
|
||||
result = s.getBinding( name, true );
|
||||
// CPPSemantics.LookupData data = CPPSemantics.createLookupData( name, false );
|
||||
// CPPSemantics.lookup( data, s );
|
||||
// IBinding result = CPPSemantics.resolveAmbiguities( data, name );
|
||||
|
||||
if (s != null && ASTInternal.isFullyCached(s))
|
||||
result = s.getBinding(name, true);
|
||||
// CPPSemantics.LookupData data = CPPSemantics.createLookupData(name, false);
|
||||
// CPPSemantics.lookup(data, s);
|
||||
// IBinding result = CPPSemantics.resolveAmbiguities(data, name);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* For debug purposes only
|
||||
*/
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
|
||||
/**
|
||||
* Represents a C++ class for which we don't yet have a complete declaration.
|
||||
*
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType {
|
||||
|
@ -35,8 +37,8 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
|
|||
* @param scope
|
||||
* @param name
|
||||
*/
|
||||
public CPPUnknownClass( ICPPScope scope, IBinding scopeBinding, IASTName name ) {
|
||||
super( scope, scopeBinding, name );
|
||||
public CPPUnknownClass(ICPPScope scope, IBinding scopeBinding, IASTName name) {
|
||||
super(scope, scopeBinding, name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -56,7 +58,7 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
|
||||
*/
|
||||
public IField findField( String name ) {
|
||||
public IField findField(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -126,12 +128,11 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
||||
*/
|
||||
public boolean isSameType( IType type ) {
|
||||
public boolean isSameType(IType type) {
|
||||
return type == this;
|
||||
}
|
||||
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
return ICPPClassType.EMPTY_CLASS_ARRAY;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
private IASTName scopeName = null;
|
||||
private CharArrayObjectMap map = null;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public CPPUnknownScope( IBinding binding, IASTName name ) {
|
||||
public CPPUnknownScope(IBinding binding, IASTName name) {
|
||||
super();
|
||||
this.scopeName = name;
|
||||
this.binding = binding;
|
||||
|
@ -62,7 +62,7 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||
*/
|
||||
public IBinding[] find( String name ) {
|
||||
public IBinding[] find(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -76,15 +76,13 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void addName( IASTName name ) {
|
||||
|
||||
public void addName(IASTName name) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void removeBinding( IBinding binding1 ) {
|
||||
|
||||
public void removeBinding(IBinding binding) {
|
||||
}
|
||||
|
||||
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||
|
@ -98,28 +96,28 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
||||
*/
|
||||
public IBinding getBinding( IASTName name, boolean resolve, IIndexFileSet fileSet ) {
|
||||
if( map == null )
|
||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||
if (map == null)
|
||||
map = new CharArrayObjectMap(2);
|
||||
|
||||
char [] c = name.toCharArray();
|
||||
if( map.containsKey( c ) ){
|
||||
return (IBinding) map.get( c );
|
||||
}
|
||||
|
||||
IBinding b = new CPPUnknownClass( this, binding, name );
|
||||
name.setBinding( b );
|
||||
map.put( c, b );
|
||||
|
||||
char[] c = name.toCharArray();
|
||||
if (map.containsKey(c)) {
|
||||
return (IBinding) map.get(c);
|
||||
}
|
||||
|
||||
IBinding b = new CPPUnknownClass(this, binding, name);
|
||||
name.setBinding(b);
|
||||
map.put(c, b);
|
||||
return b;
|
||||
}
|
||||
|
||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
|
||||
if( map == null )
|
||||
|
||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
|
||||
IIndexFileSet fileSet) {
|
||||
if (map == null)
|
||||
map = new CharArrayObjectMap(2);
|
||||
|
||||
char [] c = name.toCharArray();
|
||||
|
||||
|
||||
char[] c = name.toCharArray();
|
||||
|
||||
IBinding[] result = null;
|
||||
if (prefixLookup) {
|
||||
Object[] keys = map.keyArray();
|
||||
|
@ -130,9 +128,9 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
result = new IBinding[] { (IBinding) map.get( c ) };
|
||||
result = new IBinding[] { (IBinding) map.get(c) };
|
||||
}
|
||||
|
||||
|
||||
result = (IBinding[]) ArrayUtil.trim(IBinding.class, result);
|
||||
return result;
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#setFullyCached(boolean)
|
||||
*/
|
||||
public void setFullyCached( boolean b ) {
|
||||
public void setFullyCached(boolean b) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -156,8 +154,14 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
|||
public void flushCache() {
|
||||
}
|
||||
|
||||
public void addBinding(IBinding aBinding) {
|
||||
public void addBinding(IBinding binding) {
|
||||
// do nothing, this is part of template magic and not a normal scope
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* For debug purposes only
|
||||
*/
|
||||
public String toString() {
|
||||
return scopeName.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue