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:
parent
0908dbf0cd
commit
e45f335e8b
2 changed files with 58 additions and 40 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 <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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue