diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java index babe9a0320f..911a7246829 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java @@ -472,7 +472,7 @@ public class CompleteParser2Tests extends TestCase { assertSame( ((IQualifierType)rt.getType()).getType(), B ); IType pt = ftype.getParameterTypes()[0]; - assertEquals( p.getType(), pt ); + assertTrue( p.getType().isSameType( pt ) ); assertTrue( pt instanceof IPointerType ); assertSame( ((IPointerType) pt).getType(), A ); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java index 23520d86f52..dcc6e0a6010 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java @@ -16,4 +16,10 @@ package org.eclipse.cdt.core.dom.ast; public interface IType extends Cloneable { public Object clone(); + /** + * is the given type the same as this type? + * @param type + * @return + */ + public boolean isSameType( IType type ); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java index 0e151c6a658..0a39913581a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java @@ -180,4 +180,11 @@ public class ProblemBinding implements IProblemBinding, IType, IScope { public boolean isFullyCached() throws DOMException { throw new DOMException( this ); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) + */ + public boolean isSameType( IType type ) { + return type == this; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java index 3401aa5e328..364b9b8f340 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; import org.eclipse.cdt.core.dom.ast.c.ICArrayType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; @@ -29,7 +30,11 @@ public class CArrayType implements ICArrayType, ITypeContainer { this.type = type; } - public boolean equals(Object obj) { + public boolean isSameType(IType obj) { + if( obj == this ) + return true; + if( obj instanceof ITypedef ) + return obj.isSameType( this ); if( obj instanceof ICArrayType ){ ICArrayType at = (ICArrayType) obj; try { @@ -39,7 +44,7 @@ public class CArrayType implements ICArrayType, ITypeContainer { if( isVolatile() != at.isVolatile() ) return false; if( isVariableLength() != at.isVariableLength() ) return false; - return at.getType().equals( type ); + return at.getType().isSameType( type ); } catch ( DOMException e ) { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java index c79bb2b659c..9a636dfec85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICBasicType; @@ -69,10 +70,12 @@ public class CBasicType implements ICBasicType { return sds.isLongLong(); } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { + public boolean isSameType(IType obj) { + if( obj == this ) + return true; + if( obj instanceof ITypedef ) + return obj.isSameType( this ); + if (!(obj instanceof CBasicType)) return false; CBasicType cObj = (CBasicType)obj; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java index f0e84f78c63..12c3e96aaec 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CEnumeration.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier; @@ -142,4 +143,16 @@ public class CEnumeration implements IEnumeration { public void addDefinition( IASTName name ) { definition = name; } + + /* (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 ) + return type.isSameType( this ); + + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java index 3a6de2bd10a..886577f9206 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; /** * @author dsteffle @@ -30,7 +31,11 @@ public class CFunctionType implements IFunctionType { this.parameters = types; } - public boolean equals( Object o ){ + public boolean isSameType( IType o ){ + if( o == this ) + return true; + if( o instanceof ITypedef ) + return o.isSameType( this ); if( o instanceof IFunctionType ){ IFunctionType ft = (IFunctionType) o; IType [] fps; @@ -42,13 +47,13 @@ public class CFunctionType implements IFunctionType { if( fps.length != parameters.length ) return false; try { - if( ! returnType.equals( ft.getReturnType() ) ) + if( ! returnType.isSameType( ft.getReturnType() ) ) return false; } catch ( DOMException e1 ) { return false; } for( int i = 0; i < parameters.length; i++ ) - if( ! parameters[i].equals( fps[i] ) ) + if( ! parameters[i].isSameType( fps[i] ) ) return false; return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java index 48d364ef7b1..ea2a756ba69 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTPointer; import org.eclipse.cdt.core.dom.ast.c.ICPointerType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; @@ -30,7 +31,12 @@ public class CPointerType implements ICPointerType, ITypeContainer { this.nextType = next; } - public boolean equals( Object obj ){ + public boolean isSameType( IType obj ){ + if( obj == this ) + return true; + if( obj instanceof ITypedef ) + return obj.isSameType( this ); + if( obj instanceof ICPointerType ){ ICPointerType pt = (ICPointerType) obj; try { @@ -38,7 +44,7 @@ public class CPointerType implements ICPointerType, ITypeContainer { if( isRestrict() != pt.isRestrict() ) return false; if( isVolatile() != pt.isVolatile() ) return false; - return pt.getType().equals( nextType ); + return pt.getType().isSameType( nextType ); } catch ( DOMException e ) { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java index 8287df45fa8..ba97e58ec20 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifiedPointerType.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier; import org.eclipse.cdt.core.dom.ast.c.ICPointerType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; @@ -72,4 +73,21 @@ public class CQualifiedPointerType implements ICPointerType, ITypeContainer { } return t; } + + /* (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 ) + return type.isSameType( this ); + + if( type instanceof CQualifiedPointerType ){ + CQualifiedPointerType qual = (CQualifiedPointerType) type; + if( qual.isConst() == isConst() && qual.isRestrict() == isRestrict() && qual.isVolatile() == isVolatile() ) + return getType().isSameType( qual.getType() ); + } + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java index 9cdce3bb7a1..2f9720c8e64 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier; @@ -38,7 +39,12 @@ public class CQualifierType implements ICQualifierType, ITypeContainer { this.declSpec = declSpec; } - public boolean equals( Object obj ){ + public boolean isSameType( IType obj ){ + if( obj == this ) + return true; + if( obj instanceof ITypedef ) + return obj.isSameType( this ); + if( obj instanceof ICQualifierType ){ ICQualifierType qt = (ICQualifierType) obj; try { @@ -46,7 +52,7 @@ public class CQualifierType implements ICQualifierType, ITypeContainer { if( isRestrict() != qt.isRestrict() ) return false; if( isVolatile() != qt.isVolatile() ) return false; - return qt.getType().equals( getType() ); + return qt.getType().isSameType( getType() ); } catch ( DOMException e ) { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java index 56e1f4a5366..dd29e960c5d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java @@ -26,6 +26,7 @@ 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.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope; @@ -207,4 +208,15 @@ public class CStructure implements ICompositeType, ICInternalBinding { definition = compositeTypeSpec.getName(); compositeTypeSpec.getName().setBinding( 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 ) + return true; + if( type instanceof ITypedef ) + return type.isSameType( this ); + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypeDef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypeDef.java index aa1e2769f48..87ee588f2a3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypeDef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CTypeDef.java @@ -11,6 +11,7 @@ **********************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -74,4 +75,26 @@ public class CTypeDef implements ITypedef, ITypeContainer { } return t; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) + */ + public boolean isSameType( IType t ) { + if( t == this ) + return true; + if( t instanceof ITypedef ) + try { + IType temp = getType(); + if( temp != null ) + return temp.isSameType( ((ITypedef)t).getType()); + return false; + } catch ( DOMException e ) { + return false; + } + + IType temp = getType(); + if( temp != null ) + return temp.isSameType( t ); + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index a4e45b38bd2..13859885cd0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -747,7 +747,7 @@ public class CVisitor { t2 = ((IVariable)binding).getType(); } catch ( DOMException e1 ) { } - if( t1 != null && t2 != null && t1.equals( t2 ) ){ + if( t1 != null && t2 != null && t1.isSameType( t2 ) ){ if( binding instanceof CVariable ) ((CVariable)binding).addDeclaration( name ); } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java index 93251721665..da6b04330d2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; /** @@ -44,10 +45,15 @@ public class CPPArrayType implements IArrayType, ITypeContainer { this.type = t; } - public boolean equals(Object obj) { + public boolean isSameType(IType obj) { + if( obj == this ) + return true; + if( obj instanceof ITypedef ) + return ((ITypedef)obj).isSameType( this ); + if( obj instanceof IArrayType ){ try { - return ((IArrayType) obj).getType().equals( type ); + return ((IArrayType) obj).getType().isSameType( type ); } catch ( DOMException e ) { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java index 081bb8b0861..714d4c13a72 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java @@ -34,9 +34,9 @@ public class CPPBasicType implements ICPPBasicType { qualifierBits = bits; } - public boolean equals( Object object ) { + public boolean isSameType( IType object ) { if( object instanceof CPPTypedef ) - return object.equals( this ); + return object.isSameType( this ); if( !(object instanceof CPPBasicType) ) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java index accacff9f34..76897e42876 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java @@ -19,6 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; @@ -192,4 +194,15 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP public void addDefinition(IASTNode node) { } + /* (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 ) + return ((ITypedef)type).isSameType( this ); + return false; + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index 2c2d9c77449..aaa6f0f5861 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -21,6 +21,7 @@ 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.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; @@ -235,4 +236,15 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements 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 ) + return ((ITypedef)type).isSameType( this ); + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java index ce8fef3cda2..7030d2e6c5c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java @@ -29,6 +29,7 @@ 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.IType; +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.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; @@ -98,15 +99,15 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType { public Object clone() { return ((ICPPClassType)getBinding()).clone(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassType#getConversionOperators() - */ public ICPPMethod[] getConversionOperators() { IBinding binding = getBinding(); if( binding instanceof ICPPInternalClassType ) return ((ICPPInternalClassType)binding).getConversionOperators(); return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } + public boolean isSameType( IType type ) { + return ((ICPPClassType)getBinding()).isSameType( type ); + } } public static class CPPClassTypeProblem extends ProblemBinding implements ICPPClassType{ public CPPClassTypeProblem( IASTNode node, int id, char[] arg ) { @@ -692,4 +693,15 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType { public ICPPDelegate createDelegate( IASTName name ) { return new CPPClassTypeDelegate( name, 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 ) + return true; + if( type instanceof ITypedef ) + return ((ITypedef)type).isSameType( this ); + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java index 42d01f0792e..0c5f019cc78 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPEnumeration.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate; @@ -40,6 +41,9 @@ public class CPPEnumeration implements IEnumeration, ICPPInternalBinding, ICPPBi public Object clone() { return ((IEnumeration)getBinding()).clone(); } + public boolean isSameType( IType type ) { + return ((IEnumeration)getBinding()).isSameType( type ); + } } private IASTName enumName; @@ -165,4 +169,15 @@ public class CPPEnumeration implements IEnumeration, ICPPInternalBinding, ICPPBi // TODO Auto-generated method stub } + + /* (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 ) + return ((ITypedef)type).isSameType( this ); + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java index 9053bec18ad..843003518e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java @@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; /** * @author aniefer @@ -34,7 +35,9 @@ public class CPPFunctionType implements IFunctionType { this.parameters = types; } - public boolean equals( Object o ){ + public boolean isSameType( IType o ){ + if( o instanceof ITypedef ) + return o.isSameType( this ); if( o instanceof IFunctionType ){ IFunctionType ft = (IFunctionType) o; IType [] fps; @@ -50,13 +53,13 @@ public class CPPFunctionType implements IFunctionType { //constructors & destructors have null return type if( ( returnType == null ) ^ ( ft.getReturnType() == null ) ) return false; - else if( returnType != null && ! returnType.equals( ft.getReturnType() ) ) + else if( returnType != null && ! returnType.isSameType( ft.getReturnType() ) ) return false; } catch ( DOMException e1 ) { return false; } for( int i = 0; i < parameters.length; i++ ) - if( ! parameters[i].equals( fps[i] ) ) + if( ! parameters[i].isSameType( fps[i] ) ) return false; return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java index 5846785e2b3..54772a62756 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java @@ -198,7 +198,7 @@ public class CPPImplicitMethod extends CPPMethod { if( ps.length == params.length ){ int idx = 0; for( ; idx < ps.length && ps[idx] != null; idx++ ){ - if( !ps[idx].equals(params[idx]) ) + if( !ps[idx].isSameType(params[idx]) ) break; } if( idx == ps.length ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java index 69755b9f752..477a3b086e1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java @@ -39,22 +39,17 @@ public class CPPPointerToMemberType extends CPPPointerType implements this.operator = operator; } - public boolean equals( Object o ){ - if( !super.equals( o ) ) + public boolean isSameType( IType o ){ + if( !super.isSameType( o ) ) return false; if( !( o instanceof CPPPointerToMemberType ) ) - return false; - - - if( o instanceof ITypedef ) - return o.equals( this ); - + return false; CPPPointerToMemberType pt = (CPPPointerToMemberType) o; - IBinding cls = pt.getMemberOfClass(); + ICPPClassType cls = pt.getMemberOfClass(); if( cls != null ) - return cls.equals( getMemberOfClass() ); + return cls.isSameType( getMemberOfClass() ); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java index 5ff3e944d4f..ad5c97511e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java @@ -49,9 +49,12 @@ public class CPPPointerType implements IPointerType, ITypeContainer { this.type = type; } - public boolean equals( Object o ){ - if( o instanceof ITypedef ) - return o.equals( this ); + public boolean isSameType( IType o ){ + if( o == this ) + return true; + if( o instanceof ITypedef ) + return ((ITypedef)o).isSameType( this ); + if( !( o instanceof CPPPointerType ) ) return false; @@ -60,7 +63,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer { CPPPointerType pt = (CPPPointerType) o; if( isConst == pt.isConst && isVolatile == pt.isVolatile ) - return type.equals( pt.getType() ); + return type.isSameType( pt.getType() ); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java index 113dbe806db..00a8e449393 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java @@ -34,15 +34,15 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer { this.isVolatile = isVolatile; } - public boolean equals( Object o ){ + public boolean isSameType( IType o ){ if( o instanceof ITypedef ) - return o.equals( this ); + return o.isSameType( this ); if( !( o instanceof CPPQualifierType ) ) return false; CPPQualifierType pt = (CPPQualifierType) o; if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) - return type.equals( pt.getType() ); + return type.isSameType( pt.getType() ); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java index feb0291ba42..c4c78a35d65 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java @@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; @@ -43,13 +44,18 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer { type = t; } - public boolean equals(Object obj) { + public boolean isSameType(IType obj) { + if( obj == this ) + return true; + if( obj instanceof ITypedef ) + return ((ITypedef)obj).isSameType( this ); + if( type == null ) return (obj == null); if( obj instanceof ICPPReferenceType ){ try { - return type.equals( ((ICPPReferenceType) obj).getType() ); + return type.isSameType( ((ICPPReferenceType) obj).getType() ); } catch ( DOMException e ) { return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java index ed739a30869..1abf0786a3d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java @@ -1761,7 +1761,7 @@ public class CPPSemantics { if( varArgs ){ cost = new Cost( source, null ); cost.rank = Cost.ELLIPSIS_CONVERSION; - } else if( source.equals( target ) ){ + } else if( source.isSameType( target ) ){ cost = new Cost( source, target ); cost.rank = Cost.IDENTITY_RANK; //exact match, no cost } else { @@ -1872,7 +1872,7 @@ public class CPPSemantics { } catch ( DOMException e ) { ft = e.getProblem(); } - if( type.equals( ft ) ){ + if( type.isSameType( ft ) ){ if( result == null ) result = fn; else @@ -2056,7 +2056,7 @@ public class CPPSemantics { return cost; } - if( cost.source.equals( cost.target ) ){ + if( cost.source.isSameType( cost.target ) ){ cost.rank = Cost.IDENTITY_RANK; return cost; } @@ -2077,7 +2077,7 @@ public class CPPSemantics { return cost; } - if( s.equals( t ) ){ + if( s.isSameType( t ) ){ return cost; } @@ -2326,7 +2326,7 @@ public class CPPSemantics { IType src = getUltimateType( cost.source, true ); IType trg = getUltimateType( cost.target, true ); - if( src.equals( trg ) ) + if( src.isSameType( trg ) ) return; if( src instanceof IBasicType && trg instanceof IBasicType ){ @@ -2390,7 +2390,7 @@ public class CPPSemantics { //derived class of B ICPPPointerToMemberType spm = (ICPPPointerToMemberType) s; ICPPPointerToMemberType tpm = (ICPPPointerToMemberType) t; - if( spm.getType().equals( tpm.getType() ) ){ + if( spm.getType().isSameType( tpm.getType() ) ){ temp = hasBaseClass( tpm.getMemberOfClass(), spm.getMemberOfClass(), false ); cost.rank = ( temp > -1 ) ? Cost.CONVERSION_RANK : Cost.NO_MATCH_RANK; cost.conversion = ( temp > -1 ) ? temp : 0; @@ -2565,7 +2565,7 @@ public class CPPSemantics { IType type = null; try { type = function.getType(); - return type.equals( CPPVisitor.createType( declarator ) ); + return type.isSameType( CPPVisitor.createType( declarator ) ); } catch (DOMException e) { } return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java index 4201d7d3ce1..dd4f2dd8eef 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; @@ -140,4 +141,15 @@ public class CPPTemplateParameter implements ICPPTemplateParameter, IType, ICPPI // TODO Auto-generated method stub } + + /* (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 ) + return ((ITypedef)type).isSameType( this ); + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java index 4fae0ac5d00..da33d8a878d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java @@ -356,7 +356,7 @@ public class CPPTemplates { IType type = CPPVisitor.createType( (IASTDeclarator) parent ); try { IType ftype = ((ICPPFunction)definition).getType(); - if( ftype.equals( type ) ) + if( ftype.isSameType( type ) ) result = true; } catch (DOMException e) { } @@ -370,7 +370,7 @@ public class CPPTemplates { for (; i < args.length; i++) { IType t1 = CPPVisitor.createType( spec.getArguments()[i] ); IType t2 = CPPVisitor.createType( args[i] ); - if( t1 != null && t2 != null && t1.equals( t2 ) ) + if( t1 != null && t2 != null && t1.isSameType( t2 ) ) continue; break; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java index 4b9b9ad2359..b31f336e4df 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java @@ -45,6 +45,9 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding } return null; } + public boolean isSameType( IType type ) { + return ((ITypedef)getBinding()).isSameType( type ); + } } private IASTName [] declarations = null; private IType type = null; @@ -71,25 +74,22 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding return declarations[0]; } - public boolean equals( Object o ){ + public boolean isSameType( IType o ){ if( o == this ) return true; if( o instanceof ITypedef ) try { IType t = getType(); if( t != null ) - return t.equals( ((ITypedef)o).getType()); + return t.isSameType( ((ITypedef)o).getType()); return false; } catch ( DOMException e ) { return false; } - - if( !( o instanceof IType ) ) - return false; - + IType t = getType(); if( t != null ) - return t.equals( o ); + return t.isSameType( o ); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index 58fe6474d5f..5ef2e83861b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -485,7 +485,7 @@ public class CPPVisitor { try { IType t1 = ((ITypedef)binding).getType(); IType t2 = createType( declarator ); - if( t1 != null && t2 != null && t1.equals( t2 ) ){ + if( t1 != null && t2 != null && t1.isSameType( t2 ) ){ ((ICPPInternalBinding)binding).addDeclaration( name ); return binding; } @@ -533,7 +533,7 @@ public class CPPVisitor { } } if( t1 != null && t2 != null ){ - if( t1.equals( t2 ) ){ + if( t1.isSameType( t2 ) ){ if( binding instanceof ICPPInternalBinding ) ((ICPPInternalBinding)binding).addDeclaration( name ); } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java index 1c5f4c5367e..f62b8559a23 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java @@ -41,8 +41,8 @@ public class GPPPointerToMemberType extends CPPPointerToMemberType implements return isRestrict; } - public boolean equals( Object o ){ - if( !super.equals( o ) ) return false; + public boolean isSameType( IType o ){ + if( !super.isSameType( o ) ) return false; if( o instanceof IGPPPointerToMemberType ){ return (isRestrict == ((IGPPPointerToMemberType) o).isRestrict()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java index f0e09883b86..66c78bae217 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java @@ -52,8 +52,8 @@ public class GPPPointerType extends CPPPointerType implements IGPPPointerType { } - public boolean equals( Object o ){ - if( !super.equals( o ) ) return false; + public boolean isSameType( IType o ){ + if( !super.isSameType( o ) ) return false; if( o instanceof IGPPPointerType ){ return (isRestrict == ((IGPPPointerType) o).isRestrict());