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 db01c4190e0..8ed7b861469 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 @@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; @@ -460,47 +461,46 @@ public class ASTTypeUtil { IQualifierType cvq= null; ICPPReferenceType ref= null; while (type != null && ++i < 100) { - if (!normalize) { - types = (IType[]) ArrayUtil.append(IType.class, types, type); - if (type instanceof ITypedef) { - type= null; // stop here + if (type instanceof ITypedef) { + if (normalize || type instanceof ICPPSpecialization) { + // Skip the typedef and proceed with its target type. + } else { + // Use the typedef and stop + types = (IType[]) ArrayUtil.append(IType.class, types, type); + type= null; } } else { - if (type instanceof ITypedef) { - // skip it - } else { - if (type instanceof ICPPReferenceType) { - // reference types ignore cv-qualifiers - cvq=null; - // lvalue references win over rvalue references - if (ref == null || ref.isRValueReference()) { - // delay reference to see if there are more - ref= (ICPPReferenceType) type; - } - } else { - if (cvq != null) { - // merge cv qualifiers - if (type instanceof IQualifierType || type instanceof IPointerType) { - type= SemanticUtil.addQualifiers(type, cvq.isConst(), cvq.isVolatile()); - cvq= null; - } - } - if (type instanceof IQualifierType) { - // delay cv qualifier to merge it with others - cvq= (IQualifierType) type; - } else { - // no reference, no cv qualifier: output reference and cv-qualifier - if (ref != null) { - types = (IType[]) ArrayUtil.append(IType.class, types, ref); - ref= null; - } - if (cvq != null) { - types = (IType[]) ArrayUtil.append(IType.class, types, cvq); - cvq= null; - } - types = (IType[]) ArrayUtil.append(IType.class, types, type); - } + if (type instanceof ICPPReferenceType) { + // reference types ignore cv-qualifiers + cvq=null; + // lvalue references win over rvalue references + if (ref == null || ref.isRValueReference()) { + // delay reference to see if there are more + ref= (ICPPReferenceType) type; } + } else { + if (cvq != null) { + // merge cv qualifiers + if (type instanceof IQualifierType || type instanceof IPointerType) { + type= SemanticUtil.addQualifiers(type, cvq.isConst(), cvq.isVolatile()); + cvq= null; + } + } + if (type instanceof IQualifierType) { + // delay cv qualifier to merge it with others + cvq= (IQualifierType) type; + } else { + // no reference, no cv qualifier: output reference and cv-qualifier + if (ref != null) { + types = (IType[]) ArrayUtil.append(IType.class, types, ref); + ref= null; + } + if (cvq != null) { + types = (IType[]) ArrayUtil.append(IType.class, types, cvq); + cvq= null; + } + types = (IType[]) ArrayUtil.append(IType.class, types, type); + } } } if (type instanceof ITypeContainer) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java index b9080de1bb1..3dcadcc3f99 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java @@ -221,7 +221,11 @@ public class CompletionTests extends AbstractContentAssistTest { protected void assertCompletionResults(String[] expected) throws Exception { assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS); } - + + protected void assertParameterHint(String[] expected) throws Exception { + assertContentAssistResults(fCursorOffset, expected, false, AbstractContentAssistTest.COMPARE_DISP_STRINGS); + } + //void gfunc() {C1 v; v.m/*cursor*/ public void testLocalVariable() throws Exception { final String[] expected= { @@ -1286,8 +1290,22 @@ public class CompletionTests extends AbstractContentAssistTest { //public: // InitializerListTest() : h/*cursor*/ //}; - public void testCunstructorInitializerList_BaseClassInput_Bug266586() throws Exception { + public void testConstructorInitializerList_BaseClassInput_Bug266586() throws Exception { final String[] expected= { "Helper(void)", "Helper(const Helper &)" }; assertCompletionResults(fCursorOffset, expected, COMPARE_ID_STRINGS); } + + // template struct vector { + // typedef T value_type; + // void push_back(const value_type& value) {} + // }; + // typedef int MyType; + // void test() { + // vector v; + // v.push_back(/*cursor*/); + // } + public void testTypedefSpecialization_Bug307818() throws Exception { + final String[] expected= { "push_back(const int & value) : void" }; + assertParameterHint(expected); + } } \ No newline at end of file