1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 307818: Show target type of typedef specializations in content assist.

This commit is contained in:
Markus Schorn 2010-04-01 09:29:56 +00:00
parent 0908dbf0cd
commit e45f335e8b
2 changed files with 58 additions and 40 deletions

View file

@ -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,14 +461,14 @@ 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 (normalize || type instanceof ICPPSpecialization) {
// Skip the typedef and proceed with its target type.
} else {
if (type instanceof ITypedef) {
// skip it
// Use the typedef and stop
types = (IType[]) ArrayUtil.append(IType.class, types, type);
type= null;
}
} else {
if (type instanceof ICPPReferenceType) {
// reference types ignore cv-qualifiers
@ -502,7 +503,6 @@ public class ASTTypeUtil {
}
}
}
}
if (type instanceof ITypeContainer) {
type = ((ITypeContainer) type).getType();
} else if (type instanceof IFunctionType) {

View file

@ -222,6 +222,10 @@ public class CompletionTests extends AbstractContentAssistTest {
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 <typename T> struct vector {
// typedef T value_type;
// void push_back(const value_type& value) {}
// };
// typedef int MyType;
// void test() {
// vector<MyType> v;
// v.push_back(/*cursor*/);
// }
public void testTypedefSpecialization_Bug307818() throws Exception {
final String[] expected= { "push_back(const int & value) : void" };
assertParameterHint(expected);
}
}