mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Open call hierarchy from function definition inside unnamed namespace, bug 283679.
This commit is contained in:
parent
c4d647ea1b
commit
3c77086ce7
2 changed files with 40 additions and 8 deletions
|
@ -126,14 +126,17 @@ public class CElementHandleFactory {
|
||||||
|
|
||||||
if (parentBinding instanceof ICPPNamespace) {
|
if (parentBinding instanceof ICPPNamespace) {
|
||||||
char[] scopeName= parentBinding.getNameCharArray();
|
char[] scopeName= parentBinding.getNameCharArray();
|
||||||
if (scopeName.length != 0) {
|
// skip unnamed namespace
|
||||||
// named namespace
|
if (scopeName.length == 0) {
|
||||||
ICElement grandParent= createParent(tu, parentBinding);
|
return createParent(tu, parentBinding);
|
||||||
if (grandParent != null) {
|
|
||||||
return new NamespaceHandle(grandParent, (ICPPNamespace) parentBinding);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (parentBinding instanceof ICompositeType) {
|
ICElement grandParent= createParent(tu, parentBinding);
|
||||||
|
if (grandParent == null)
|
||||||
|
return null;
|
||||||
|
return new NamespaceHandle(grandParent, (ICPPNamespace) parentBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentBinding instanceof ICompositeType) {
|
||||||
ICElement grandParent= createParent(tu, parentBinding);
|
ICElement grandParent= createParent(tu, parentBinding);
|
||||||
if (grandParent != null) {
|
if (grandParent != null) {
|
||||||
return new StructureHandle(grandParent, (ICompositeType) parentBinding);
|
return new StructureHandle(grandParent, (ICompositeType) parentBinding);
|
||||||
|
|
|
@ -414,4 +414,33 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
|
||||||
TreeItem ti= checkTreeNode(chTree, 0, 0, "call()");
|
TreeItem ti= checkTreeNode(chTree, 0, 0, "call()");
|
||||||
checkTreeNode(chTree, 0, 1, null);
|
checkTreeNode(chTree, 0, 1, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// namespace {
|
||||||
|
// void doNothing()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// int main() {
|
||||||
|
// doNothing();
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
public void testUnnamedNamespace_283679() throws Exception {
|
||||||
|
final StringBuffer[] contents = getContentsForTest(1);
|
||||||
|
final String content = contents[0].toString();
|
||||||
|
IFile f2= createFile(getProject(), "testUnnamedNamespace_283679.cpp", content);
|
||||||
|
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
|
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||||
|
|
||||||
|
// open editor, check outline
|
||||||
|
CEditor editor= openEditor(f2);
|
||||||
|
int idx = content.indexOf("doNothing()");
|
||||||
|
editor.selectAndReveal(idx, 0);
|
||||||
|
openCallHierarchy(editor, true);
|
||||||
|
|
||||||
|
Tree chTree= checkTreeNode(ch, 0, "doNothing()").getParent();
|
||||||
|
TreeItem ti= checkTreeNode(chTree, 0, 0, "main()");
|
||||||
|
checkTreeNode(chTree, 0, 1, null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue