mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 395571 - Show name of nesting type when printing names of nested types in completions
Change-Id: I2fc191403a6ead68d30b99e427a005109355baad
This commit is contained in:
parent
35687baf43
commit
e7e66605f2
5 changed files with 31 additions and 10 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
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.ICPPNamespace;
|
||||
|
@ -445,8 +446,10 @@ public class ASTTypeUtil {
|
|||
result.append(Keywords.ENUM);
|
||||
result.append(SPACE);
|
||||
}
|
||||
boolean qualify = normalize || (type instanceof ITypedef && type instanceof ICPPSpecialization);
|
||||
appendCppName((ICPPBinding) type, normalize, qualify, result);
|
||||
ICPPBinding binding = ((ICPPBinding) type);
|
||||
boolean nested = binding.getOwner() instanceof ICPPClassType;
|
||||
boolean qualify = normalize || nested || (type instanceof ITypedef && type instanceof ICPPSpecialization);
|
||||
appendCppName(binding, normalize, qualify, result);
|
||||
} else if (type instanceof ICompositeType) {
|
||||
// Don't display class, and for consistency don't display struct/union as well (bug 101114).
|
||||
appendNameCheckAnonymous((ICompositeType) type, result);
|
||||
|
|
|
@ -279,7 +279,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s4::mem4 : {struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, "s4::mem4 : s4::{struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||
|
@ -298,7 +298,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s4::mem4 : {struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, "s4::mem4 : s4::{struct_member.cpp:129}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u4::mem4 : {union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, "u4::mem4 : u4::{union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||
|
@ -480,7 +480,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u4::mem4 : {union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, "u4::mem4 : u4::{union_member.cpp:161}");
|
||||
checkTreeNode(tree, 0, 0, "main() : void");
|
||||
}
|
||||
|
||||
|
|
|
@ -256,8 +256,8 @@ public class ContentAssistTests extends BaseUITestCase {
|
|||
|
||||
results = getResults(cu, c2.indexOf("::") + 2); //$NON-NLS-1$
|
||||
assertEquals(3, results.length);
|
||||
assertEquals("getAbility(void) : enum _Ability", results[1].getDisplayString()); //$NON-NLS-1$
|
||||
assertEquals("Strategy(enum _Ability a)", results[0].getDisplayString()); //$NON-NLS-1$
|
||||
assertEquals("getAbility(void) : enum Strategy::_Ability", results[1].getDisplayString()); //$NON-NLS-1$
|
||||
assertEquals("Strategy(enum Strategy::_Ability a)", results[0].getDisplayString()); //$NON-NLS-1$
|
||||
assertEquals("_Ability", results[2].getDisplayString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
|
|
@ -1537,6 +1537,23 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
final String[] expected = { "i" };
|
||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// struct meta1;
|
||||
//
|
||||
// template <typename T>
|
||||
// struct meta2;
|
||||
//
|
||||
// template <typename T>
|
||||
// void waldo(T, typename meta1<T>::type, typename meta2<T>::type);
|
||||
//
|
||||
// int main() {
|
||||
// wald/*cursor*/
|
||||
// }
|
||||
public void testNestingClassNameInCompletion_395571() throws Exception {
|
||||
final String[] expected = { "waldo(T, meta1<T>::type, meta2<T>::type) : void" };
|
||||
assertCompletionResults(fCursorOffset, expected, DISPLAY);
|
||||
}
|
||||
|
||||
// void foo() { Specialization<int, /*cursor*/
|
||||
public void testTemplateArgumentList() throws Exception {
|
||||
|
|
|
@ -532,8 +532,9 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
|||
idArgs.append(parameterDelimiter);
|
||||
}
|
||||
|
||||
dispArgs.append(ASTTypeUtil.getType(paramType, false));
|
||||
idArgs.append(ASTTypeUtil.getType(paramType, false));
|
||||
String paramTypeString = ASTTypeUtil.getType(paramType, false);
|
||||
dispArgs.append(paramTypeString);
|
||||
idArgs.append(paramTypeString);
|
||||
String paramName = param.getName();
|
||||
if (paramName != null && paramName.length() > 0) {
|
||||
dispArgs.append(' ');
|
||||
|
|
Loading…
Add table
Reference in a new issue