diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index bcb156440b9..875c4017bf0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -60,6 +60,47 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa setStrategy(new ReferencedProject(true)); } + // class Str1 { + // public: + // Str1(const char* s) { + // s_ = s; + // } + // + // const char* s_; + // }; + // + // template + // class StrT { + // public: + // StrT(const T* s) { + // s_ = s; + // } + // + // const T* s_; + // }; + // + // template + // class C1 { + // public: + // void m1(const Str1& s) {} + // void m2(const StrT s) {} + // }; + + // void main() { + // C1 c1; + // c1.m1("aaa"); // OK + // c1.m2("aaa"); // problem + // } + public void _testUnindexedConstructorInstanceImplicitReferenceToDeferred() throws Exception { + IBinding b0= getBindingFromASTName("C1 c1", 8); + IBinding b1= getBindingFromASTName("m1(\"aaa\")", 2); + IBinding b2= getBindingFromASTName("m2(\"aaa\")", 2); + + assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length); + assertEquals(1, getIndex().findNames(b2, IIndex.FIND_REFERENCES).length); + } + + // template // class X { // public: static void foo() {} @@ -85,6 +126,35 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa IBinding b0= getBindingFromASTName("X()", 4); assertInstance(b0, ICPPConstructor.class); } + + // template + // class StrT { + // public: + // StrT(const T* s) { + // s_ = s; + // } + // + // const T* s_; + // }; + // + // template + // class C1 { + // public: + // void m2(T t) {} + // }; + + // class A {}; + // void foo() { + // C1< StrT > c1a; + // c1a.m2(*new StrT(new A())); + // } + public void testUnindexedConstructorInstanceImplicitReference3() throws Exception { + IBinding b0= getBindingFromASTName("C1< StrT >", 2); + IBinding b1= getBindingFromASTName("StrT > c1a", 7); + IBinding b2= getBindingFromASTName("StrT(", 7); + IBinding b3= getBindingFromASTName("c1a;", 3); + IBinding b4= getBindingFromASTName("m2(*", 2); + } // class Str1 { // public: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index 22bae4b30bf..4b28577b117 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -60,13 +60,13 @@ public class ASTTypeUtil { private static final int DEAULT_ITYPE_SIZE = 2; /** - * Returns a String represnetation of the parameter type of an IFunctionType. + * Returns a String representation of the parameter type of an IFunctionType. * * This function calls ASTTypeUtil#getParameterTypeStringArray(IFunctionType) and wraps the * results in "()" with a comma separated list. * * @param type - * @return the represnetation of the parameter type of an IFunctionType + * @return the representation of the parameter type of an IFunctionType */ public static String getParameterTypeString(IFunctionType type) { StringBuffer result = new StringBuffer(); @@ -82,6 +82,23 @@ public class ASTTypeUtil { result.append(Keywords.cpRPAREN); return result.toString(); } + + /** + * Returns a String representation of the type array as a + * comma-separated list. + * @param types + * @return representation of the type array as a comma-separated list + */ + public static String getTypeListString(IType[] types) { + StringBuffer result = new StringBuffer(); + for(int i=0; i"); //$NON-NLS-1$ //$NON-NLS-2$ + try { + result.append(" "+getConstantNameForValue(getLinkageImpl(), getNodeType())); //$NON-NLS-1$ + } catch(CoreException ce) { + result.append(" "+getNodeType()); //$NON-NLS-1$ + } + return result.toString(); + } }