From 1be0d21863c20bd0460ebdf0c18647e8e7fb1b81 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Tue, 6 Nov 2007 11:13:48 +0000 Subject: [PATCH] 201177: apply fix + add test from Sergey --- .../tests/IndexCPPBindingResolutionTest.java | 41 +++++++++++++++++++ .../core/dom/parser/cpp/CPPClassType.java | 7 ++-- .../core/dom/parser/cpp/CPPEnumeration.java | 3 +- .../core/pdom/dom/cpp/PDOMCPPClassType.java | 3 +- .../core/pdom/dom/cpp/PDOMCPPEnumeration.java | 3 +- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index f6a706ab17d..b5458ae63e6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -8,6 +8,7 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -32,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; @@ -61,6 +63,45 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti suite.addTest(suite(ProjectWithDepProj.class)); } + // namespace ns { class A; enum E {E1}; typedef int T; } + // + // class B { + // public: + // void m(ns::A* a); + // void n(ns::E* a); + // void o(ns::T* a); + // void p(ns::E a); + // }; + + // namespace ns { + // class A {}; + // typedef int T; + // } + // + // using ns::A; + // using ns::E; + // using ns::T; + // using ns::E1; + // + // void B::m(A* a) {} + // void B::n(E* a) {} + // void B::o(T* a) {} + // void B::p(E a) {} + // + // void usage() { + // B b; + // b.p(E1); + // } + public void testUsingTypeDirective_201177() { + IBinding b0= getBindingFromASTName("B::m", 4); + IBinding b1= getBindingFromASTName("B::n", 4); + IBinding b2= getBindingFromASTName("B::o", 4); + IBinding b3= getBindingFromASTName("p(E1)", 1); + assertInstance(b0, ICPPMethod.class); + assertInstance(b1, ICPPMethod.class); + assertInstance(b2, ICPPMethod.class); + } + // namespace n { class A{}; class B{}; class C{}; } // namespace m { 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 47bdd889421..3a92214987e 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 @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) * Bryan Wilkinson (QNX) + * Sergey Prigogin (Google) *******************************************************************************/ /* * Created on Nov 29, 2004 @@ -794,10 +795,10 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) */ public boolean isSameType( IType type ) { - if( type == this ) + if (type == this) return true; - if( type instanceof ITypedef || type instanceof IIndexType) - return type.isSameType( this ); + if (type instanceof ITypedef || type instanceof IIndexType || type instanceof ICPPDelegate) + return 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 0828255897c..83af1bedde0 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 @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ /* @@ -188,7 +189,7 @@ public class CPPEnumeration extends PlatformObject implements IEnumeration, ICPP public boolean isSameType( IType type ) { if( type == this ) return true; - if( type instanceof ITypedef || type instanceof IIndexType) + if( type instanceof ITypedef || type instanceof IIndexType || type instanceof ICPPDelegate) return type.isSameType( this ); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java index d9fcf4a017c..9e0a07757a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java @@ -10,6 +10,7 @@ * Markus Schorn (Wind River Systems) * Andrew Ferguson (Symbian) * Bryan Wilkinson (QNX) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -129,7 +130,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType, } public boolean isSameType(IType type) { - if (type instanceof ITypedef) { + if (type instanceof ITypedef || type instanceof ICPPDelegate) { return type.isSameType(this); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java index 39b91adbc3a..fa2af9817fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java @@ -8,6 +8,7 @@ * Contributors: * QNX - Initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -98,7 +99,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding } public boolean isSameType(IType type) { - if (type instanceof ITypedef) { + if (type instanceof ITypedef || type instanceof ICPPDelegate) { return type.isSameType(this); }