Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2009-07-16 08:00:32 -0400
committerMarkus Schorn2009-07-16 08:00:32 -0400
commitb0e9a6571793aa6049e781feab80b69353d8e913 (patch)
treebf1fc0c9ae4315a9a26f8b4babdc48879f451bff /core
parent05d3320f064a32bbebb934a9e8cacf4106ebaea3 (diff)
downloadorg.eclipse.cdt-b0e9a6571793aa6049e781feab80b69353d8e913.tar.gz
org.eclipse.cdt-b0e9a6571793aa6049e781feab80b69353d8e913.tar.xz
org.eclipse.cdt-b0e9a6571793aa6049e781feab80b69353d8e913.zip
Open call hierarchy from function definition inside unnamed namespace, bug 283679.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandleFactory.java19
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java29
2 files changed, 40 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandleFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandleFactory.java
index ace460237b..7e5a0a33c4 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandleFactory.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/CElementHandleFactory.java
@@ -126,14 +126,17 @@ public class CElementHandleFactory {
if (parentBinding instanceof ICPPNamespace) {
char[] scopeName= parentBinding.getNameCharArray();
- if (scopeName.length != 0) {
- // named namespace
- ICElement grandParent= createParent(tu, parentBinding);
- if (grandParent != null) {
- return new NamespaceHandle(grandParent, (ICPPNamespace) parentBinding);
- }
- }
- } else if (parentBinding instanceof ICompositeType) {
+ // skip unnamed namespace
+ if (scopeName.length == 0) {
+ return createParent(tu, parentBinding);
+ }
+ 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);
if (grandParent != null) {
return new StructureHandle(grandParent, (ICompositeType) parentBinding);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java
index 80827a35d2..1d2923c900 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java
@@ -414,4 +414,33 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
TreeItem ti= checkTreeNode(chTree, 0, 0, "call()");
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);
+ }
+
}

Back to the top