diff options
37 files changed, 2233 insertions, 715 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java index b1b2a7fb4ea..df1ddd84aa7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java @@ -37,7 +37,11 @@ import org.eclipse.core.runtime.Path; /** * Creates labels for ICElement objects. + * + * @deprecated Use org.eclipse.cdt.ui.CElementLabelProvider instead. + * Internally you can also use org.eclipse.cdt.internal.ui.viewsupport.CElementBaseLabels. */ +@Deprecated public class CElementBaseLabels { /** diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java index db3dbca748c..9a87dce5424 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java @@ -65,24 +65,24 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("proto"), 5); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "proto()"); + checkTreeNode(tree, 0, "proto() : void"); expandTreeItem(tree, 0); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("func"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "func()"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "func() : void"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("proto(); //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "proto()"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "proto() : void"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("func(); //ref"), 4); openCallHierarchy(editor); - checkTreeNode(tree, 0, "func()"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "func() : void"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testVariablesC() throws Exception { @@ -109,23 +109,23 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("extern_var"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "extern_var"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "extern_var : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("global_var"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "global_var"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "global_var : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("extern_var; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "extern_var"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "extern_var : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("global_var; //ref"), 7); openCallHierarchy(editor); - checkTreeNode(tree, 0, "global_var"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "global_var : int"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testEnumeratorC() throws Exception { @@ -165,20 +165,20 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "enumerator"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("main"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "main()"); + checkTreeNode(tree, 0, "main() : void"); editor.selectAndReveal(content.indexOf("enumerator; //ref"), 0); openCallHierarchy(editor); checkTreeNode(tree, 0, "enumerator"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("main"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "main()"); + checkTreeNode(tree, 0, "main() : void"); } // {testStructMembers} @@ -219,41 +219,41 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "s1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "s2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); editor.selectAndReveal(content.indexOf("mem4"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s4::mem4 : {struct_member.c:129}"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem5"); + checkTreeNode(tree, 0, ANON+"::mem5 : int"); editor.selectAndReveal(content.indexOf("mem1; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "s2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem4."), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s4::mem4 : {struct_member.c:129}"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testStructMembersCpp() throws Exception { @@ -265,41 +265,41 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "s1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "s2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); editor.selectAndReveal(content.indexOf("mem4"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s4::mem4 : s4::{struct_member.cpp:129}"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::"+ANON+"::mem5"); + checkTreeNode(tree, 0, "s4::"+ANON+"::mem5 : int"); editor.selectAndReveal(content.indexOf("mem1; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "s2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem4."), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s4::mem4 : s4::{struct_member.cpp:129}"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testAnonymousStructMembersC_156671() throws Exception { @@ -311,23 +311,23 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem3; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testAnonymousStructMembersCpp_156671() throws Exception { @@ -339,23 +339,23 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::"+ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s4::"+ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem3; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "s4::"+ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "s4::"+ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); } // {testUnionMembers} @@ -401,41 +401,41 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "u1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "u2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); editor.selectAndReveal(content.indexOf("mem4"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u4::mem4 : {union_member.c:161}"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem5"); + checkTreeNode(tree, 0, ANON+"::mem5 : int"); editor.selectAndReveal(content.indexOf("mem1; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "u2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem4."), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u4::mem4 : {union_member.c:161}"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testUnionMembersCpp() throws Exception { @@ -447,41 +447,41 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "u1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "u2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); editor.selectAndReveal(content.indexOf("mem4"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u4::mem4 : u4::{union_member.cpp:161}"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::"+ANON+"::mem5"); + checkTreeNode(tree, 0, "u4::"+ANON+"::mem5 : int"); editor.selectAndReveal(content.indexOf("mem1; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u1::mem1"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u1::mem1 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem2; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u2::mem2"); - checkTreeNode(tree, 0, 0, "main() (2 matches)"); + checkTreeNode(tree, 0, "u2::mem2 : int"); + checkTreeNode(tree, 0, 0, "main() : void (2 matches)"); editor.selectAndReveal(content.indexOf("mem4."), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::mem4"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u4::mem4 : u4::{union_member.cpp:161}"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testAnonymousUnionMembersC_156671() throws Exception { @@ -493,23 +493,23 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem3; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); } public void testAnonymousUnionMembersCpp_156671() throws Exception { @@ -521,23 +521,23 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::"+ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u4::"+ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem3; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, ANON+"::mem3"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, ANON+"::mem3 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); editor.selectAndReveal(content.indexOf("mem5; //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "u4::"+ANON+"::mem5"); - checkTreeNode(tree, 0, 0, "main()"); + checkTreeNode(tree, 0, "u4::"+ANON+"::mem5 : int"); + checkTreeNode(tree, 0, 0, "main() : void"); } // void gf(); @@ -567,19 +567,19 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content1.indexOf("sf"), 0); openCallHierarchy(editor); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "sf()"); + checkTreeNode(tree, 0, "sf() : void"); assertEquals(1, tree.getItemCount()); - i1= checkTreeNode(tree, 0, 0, "gf()"); // sf()[f1] <- gf() - i2= checkTreeNode(tree, 0, 1, "sf()"); // sf()[f1] <- sf()[f1] + i1= checkTreeNode(tree, 0, 0, "gf() : void"); // sf()[f1] <- gf() + i2= checkTreeNode(tree, 0, 1, "sf() : void"); // sf()[f1] <- sf()[f1] checkTreeNode(tree, 0, 2, null); expandTreeItem(i1); expandTreeItem(i2); checkTreeNode(i2, 0, null); - i3= checkTreeNode(i1, 0, "gf()"); // sf()[f1] <- gf() <- gf() - i4= checkTreeNode(i1, 1, "sf()"); // sf()[f1] <- gf() <- sf()[f1] - i5= checkTreeNode(i1, 2, "sf()"); // sf()[f1] <- gf() <- sf()[f2] + i3= checkTreeNode(i1, 0, "gf() : void"); // sf()[f1] <- gf() <- gf() + i4= checkTreeNode(i1, 1, "sf() : void"); // sf()[f1] <- gf() <- sf()[f1] + i5= checkTreeNode(i1, 2, "sf() : void"); // sf()[f1] <- gf() <- sf()[f2] if (((CHNode) i4.getData()).getRepresentedDeclaration().getResource().equals(file2)) { TreeItem i0= i4; i4=i5; i5=i0; @@ -589,7 +589,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { expandTreeItem(i5); checkTreeNode(i3, 0, null); checkTreeNode(i4, 0, null); - i6= checkTreeNode(i5, 0, "sf()"); // sf()[f1] <- gf() <- sf()[f2] <- sf()[f2] + i6= checkTreeNode(i5, 0, "sf() : void"); // sf()[f1] <- gf() <- sf()[f2] <- sf()[f2] expandTreeItem(i6); checkTreeNode(i6, 0, null); @@ -599,10 +599,10 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content1.indexOf("sf"), 0); openCallHierarchy(editor); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "sf()"); + checkTreeNode(tree, 0, "sf() : void"); assertEquals(1, tree.getItemCount()); - i1= checkTreeNode(tree, 0, 0, "sf()"); // sf()[f2] <- sf()[f2] + i1= checkTreeNode(tree, 0, 0, "sf() : void"); // sf()[f2] <- sf()[f2] checkTreeNode(tree, 0, 1, null); // not called by gf() expandTreeItem(i1); @@ -637,19 +637,19 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content1.indexOf("sf"), 0); openCallHierarchy(editor); tree = getCHTreeViewer().getTree(); - i0= checkTreeNode(tree, 0, "sf()"); + i0= checkTreeNode(tree, 0, "sf() : void"); assertEquals(1, tree.getItemCount()); - i1= checkTreeNode(tree, 0, 0, "gf()"); // sf()[f1] <- gf() - i2= checkTreeNode(tree, 0, 1, "sf()"); // sf()[f1] <- sf()[f1] + i1= checkTreeNode(tree, 0, 0, "gf() : void"); // sf()[f1] <- gf() + i2= checkTreeNode(tree, 0, 1, "sf() : void"); // sf()[f1] <- sf()[f1] checkTreeNode(tree, 0, 2, null); expandTreeItem(i1); expandTreeItem(i2); checkTreeNode(i2, 0, null); - i3= checkTreeNode(i1, 0, "gf()"); // sf()[f1] <- gf() <- gf() - i4= checkTreeNode(i1, 1, "sf()"); // sf()[f1] <- gf() <- sf()[f1] - i5= checkTreeNode(i1, 2, "sf()"); // sf()[f1] <- gf() <- sf()[f2] + i3= checkTreeNode(i1, 0, "gf() : void"); // sf()[f1] <- gf() <- gf() + i4= checkTreeNode(i1, 1, "sf() : void"); // sf()[f1] <- gf() <- sf()[f1] + i5= checkTreeNode(i1, 2, "sf() : void"); // sf()[f1] <- gf() <- sf()[f2] if (((CHNode) i4.getData()).getRepresentedDeclaration().getResource().equals(file2)) { i0= i4; i4=i5; i5=i0; @@ -659,7 +659,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { expandTreeItem(i5); checkTreeNode(i3, 0, null); checkTreeNode(i4, 0, null); - i6= checkTreeNode(i5, 0, "sf()"); // sf()[f1] <- gf() <- sf()[f2] <- sf()[f2] + i6= checkTreeNode(i5, 0, "sf() : void"); // sf()[f1] <- gf() <- sf()[f2] <- sf()[f2] expandTreeItem(i6); checkTreeNode(i6, 0, null); @@ -669,10 +669,10 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content1.indexOf("sf"), 0); openCallHierarchy(editor); tree = getCHTreeViewer().getTree(); - i0= checkTreeNode(tree, 0, "sf()"); + i0= checkTreeNode(tree, 0, "sf() : void"); assertEquals(1, tree.getItemCount()); - i1= checkTreeNode(tree, 0, 0, "sf()"); // sf()[f2] <- sf()[f2] + i1= checkTreeNode(tree, 0, 0, "sf() : void"); // sf()[f2] <- sf()[f2] checkTreeNode(tree, 0, 1, null); // not called by gf() expandTreeItem(i1); @@ -707,23 +707,23 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("proto"), 5); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "proto(int)"); - checkTreeNode(tree, 0, 0, "main(int)"); + checkTreeNode(tree, 0, "proto(int) : void"); + checkTreeNode(tree, 0, 0, "main(int) : void"); editor.selectAndReveal(content.indexOf("func"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "func(int)"); - checkTreeNode(tree, 0, 0, "main(int)"); + checkTreeNode(tree, 0, "func(int) : void"); + checkTreeNode(tree, 0, 0, "main(int) : void"); editor.selectAndReveal(content.indexOf("proto(1); //ref"), 0); openCallHierarchy(editor); - checkTreeNode(tree, 0, "proto(int)"); - checkTreeNode(tree, 0, 0, "main(int)"); + checkTreeNode(tree, 0, "proto(int) : void"); + checkTreeNode(tree, 0, 0, "main(int) : void"); editor.selectAndReveal(content.indexOf("func(1); //ref"), 4); openCallHierarchy(editor); - checkTreeNode(tree, 0, "func(int)"); - checkTreeNode(tree, 0, 0, "main(int)"); + checkTreeNode(tree, 0, "func(int) : void"); + checkTreeNode(tree, 0, 0, "main(int) : void"); } finally { CProjectHelper.delete(triggerCompositeBindings); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java index aaf92a35ce8..e302bab3f05 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java @@ -57,59 +57,59 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("method"), 2); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("method(); // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); } // {testStaticMethods} @@ -140,59 +140,59 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("method"), 2); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("method(); // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); } @@ -228,59 +228,59 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("field"), 2); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "MyClass::field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("static_field"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::static_field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::static_field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("field; // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("static_field; // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::static_field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::static_field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("field; // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("static_field; // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::static_field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::static_field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("field; // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(content.indexOf("static_field; // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::static_field"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::static_field : int"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); } // {testAutomaticConstructor} @@ -303,7 +303,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::MyClass()"); - checkTreeNode(tree, 0, 0, "automatic()"); + checkTreeNode(tree, 0, 0, "automatic() : void"); } public void _testAutomaticDestructor_156668() throws Exception { @@ -317,7 +317,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("~MyClass"), 2); openCallHierarchy(editor); checkTreeNode(tree, 0, "MyClass::~MyClass()"); - checkTreeNode(tree, 0, 0, "automatic()"); + checkTreeNode(tree, 0, 0, "automatic() : void"); } // {testConstructor} @@ -341,7 +341,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::MyClass()"); - checkTreeNode(tree, 0, 0, "heap()"); + checkTreeNode(tree, 0, 0, "heap() : void"); } public void testDestructor_156669() throws Exception { @@ -354,7 +354,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::~MyClass()"); - checkTreeNode(tree, 0, 0, "heap()"); + checkTreeNode(tree, 0, 0, "heap() : void"); } @@ -388,52 +388,52 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("var"), 2); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "ns::var"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::var : int"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); editor.selectAndReveal(content.indexOf("func()"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "ns::func()"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::func() : void"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); editor.selectAndReveal(content.indexOf("func(); // r1"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "ns::func()"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::func() : void"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); editor.selectAndReveal(content.indexOf("var; // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "ns::var"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::var : int"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); editor.selectAndReveal(content.indexOf("func(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "ns::func()"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::func() : void"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); editor.selectAndReveal(content.indexOf("var; // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "ns::var"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::var : int"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); editor.selectAndReveal(content.indexOf("func(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "ns::func()"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::func() : void"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); } public void testNamespacePart2_156519() throws Exception { @@ -446,9 +446,9 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "ns::var"); - checkTreeNode(tree, 0, 0, "gfunc1()"); - checkTreeNode(tree, 0, 1, "gfunc2()"); - checkTreeNode(tree, 0, 2, "ns::func()"); + checkTreeNode(tree, 0, "ns::var : int"); + checkTreeNode(tree, 0, 0, "gfunc1() : void"); + checkTreeNode(tree, 0, 1, "gfunc2() : void"); + checkTreeNode(tree, 0, 2, "ns::func() : void"); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java index ce1a0fb40c4..3239e634aac 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java @@ -97,39 +97,39 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("inline_method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("inline_method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); } @@ -170,11 +170,11 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { openCallHierarchy(editor); TreeViewer tv = getCHTreeViewer(); - checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); - TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2()"); + checkTreeNode(tv.getTree(), 0, "MyClass::method3() : void"); + TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2() : void"); checkTreeNode(tv.getTree(), 0, 1, null); tv.setExpandedState(item.getData(), true); - TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method1()"); + TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method1() : void"); checkTreeNode(item, 1, null); item= nextItem; tv.setExpandedState(item.getData(), true); checkTreeNode(item, 0, null); @@ -221,9 +221,9 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { openCallHierarchy(editor); TreeViewer tv = getCHTreeViewer(); - checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); - TreeItem item0= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1()"); - TreeItem item1= checkTreeNode(tv.getTree(), 0, 1, "MyClass::method2()"); + checkTreeNode(tv.getTree(), 0, "MyClass::method3() : void"); + TreeItem item0= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1() : void"); + TreeItem item1= checkTreeNode(tv.getTree(), 0, 1, "MyClass::method2() : void"); checkTreeNode(tv.getTree(), 0, 2, null); // method 1 @@ -232,7 +232,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { // method 2 tv.setExpandedState(item1.getData(), true); - TreeItem nextItem= checkTreeNode(item1, 0, "MyClass::method1()"); + TreeItem nextItem= checkTreeNode(item1, 0, "MyClass::method1() : void"); checkTreeNode(item1, 1, null); item1= nextItem; tv.setExpandedState(item1.getData(), true); checkTreeNode(item1, 0, null); @@ -282,18 +282,18 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { TreeViewer tv = getCHTreeViewer(); final Tree tree = tv.getTree(); - checkTreeNode(tree, 0, "main()"); - TreeItem item= checkTreeNode(tree, 0, 0, "MyClass::method1()"); + checkTreeNode(tree, 0, "main() : void"); + TreeItem item= checkTreeNode(tree, 0, 0, "MyClass::method1() : void"); checkTreeNode(tree, 0, 1, null); tv.setExpandedState(item.getData(), true); - TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()"); - TreeItem item1= checkTreeNode(item, 1, "MyClass::method1()"); + TreeItem item0= checkTreeNode(item, 0, "MyClass::method1() : void"); + TreeItem item1= checkTreeNode(item, 1, "MyClass::method1() : void"); checkTreeNode(item, 2, null); item= null; try { tv.setExpandedState(item0.getData(), true); - checkTreeNode(item0, 0, "MyClass::method2()"); + checkTreeNode(item0, 0, "MyClass::method2() : void"); } catch (Throwable e) { TreeItem tmp= item0; item0= item1; item1= tmp; @@ -301,14 +301,14 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { // method 1 tv.setExpandedState(item0.getData(), true); - TreeItem nextItem= checkTreeNode(item0, 0, "MyClass::method2()"); + TreeItem nextItem= checkTreeNode(item0, 0, "MyClass::method2() : void"); checkTreeNode(item0, 1, null); item0= nextItem; tv.setExpandedState(item0.getData(), true); checkTreeNode(item0, 0, null); // method 2 tv.setExpandedState(item1.getData(), true); - nextItem= checkTreeNode(item1, 0, "MyClass::method3()"); + nextItem= checkTreeNode(item1, 0, "MyClass::method3() : void"); checkTreeNode(item1, 1, null); item1= nextItem; tv.setExpandedState(item1.getData(), true); checkTreeNode(item1, 0, null); 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 f9c28a5788c..c05f12fd540 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 @@ -70,12 +70,12 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { TreeItem node= checkTreeNode(outlineTree, 0, 0, "method() : void"); openCH(workbenchWindow, node); - Tree chTree= checkTreeNode(ch, 0, "SomeClass::method()").getParent(); + Tree chTree= checkTreeNode(ch, 0, "SomeClass::method() : void").getParent(); checkTreeNode(chTree, 0, 1, null); ch.onSetShowReferencedBy(false); - checkTreeNode(chTree, 0, "SomeClass::method()"); - checkTreeNode(chTree, 0, 0, "SomeClass::field"); + checkTreeNode(chTree, 0, "SomeClass::method() : void"); + checkTreeNode(chTree, 0, 0, "SomeClass::field : int"); } // class SomeClass { @@ -114,12 +114,12 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { openCH(workbenchWindow, node1); ch.onSetShowReferencedBy(false); - Tree chTree= checkTreeNode(ch, 0, "SomeClass::ambiguous_impl()").getParent(); - checkTreeNode(chTree, 0, 0, "SomeClass::ref1"); + Tree chTree= checkTreeNode(ch, 0, "SomeClass::ambiguous_impl() : void").getParent(); + checkTreeNode(chTree, 0, 0, "SomeClass::ref1 : int"); // open and check call hierarchy openCH(workbenchWindow, node2); - checkTreeNode(chTree, 0, "other()"); + checkTreeNode(chTree, 0, "other() : void"); // open editor, check outline @@ -130,8 +130,8 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // open and check call hierarchy openCH(workbenchWindow, node1); ch.onSetShowReferencedBy(false); - chTree= checkTreeNode(ch, 0, "SomeClass::ambiguous_impl()").getParent(); - checkTreeNode(chTree, 0, 0, "SomeClass::ref2"); + chTree= checkTreeNode(ch, 0, "SomeClass::ambiguous_impl() : void").getParent(); + checkTreeNode(chTree, 0, 0, "SomeClass::ref2 : int"); } private void openCH(final IWorkbenchWindow workbenchWindow, TreeItem node1) { @@ -172,33 +172,33 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor); - Tree chTree= checkTreeNode(ch, 0, "Base::vmethod()").getParent(); - checkTreeNode(chTree, 0, 0, "regRefs()"); - checkTreeNode(chTree, 0, 1, "vrefs()"); + Tree chTree= checkTreeNode(ch, 0, "Base::vmethod() : void").getParent(); + checkTreeNode(chTree, 0, 0, "regRefs() : void"); + checkTreeNode(chTree, 0, 1, "vrefs() : void"); checkTreeNode(chTree, 0, 2, null); idx = content.indexOf("vmethod", idx+1); editor.selectAndReveal(idx, 0); openCallHierarchy(editor); - chTree= checkTreeNode(ch, 0, "Derived::vmethod()").getParent(); - checkTreeNode(chTree, 0, 0, "vrefs()"); + chTree= checkTreeNode(ch, 0, "Derived::vmethod() : void").getParent(); + checkTreeNode(chTree, 0, 0, "vrefs() : void"); checkTreeNode(chTree, 0, 1, null); idx = content.indexOf(" method")+1; editor.selectAndReveal(idx, 0); openCallHierarchy(editor); - chTree= checkTreeNode(ch, 0, "Base::method()").getParent(); - checkTreeNode(chTree, 0, 0, "regRefs()"); - checkTreeNode(chTree, 0, 1, "vrefs()"); + chTree= checkTreeNode(ch, 0, "Base::method() : void").getParent(); + checkTreeNode(chTree, 0, 0, "regRefs() : void"); + checkTreeNode(chTree, 0, 1, "vrefs() : void"); checkTreeNode(chTree, 0, 2, null); idx = content.indexOf(" method", idx+1)+1; editor.selectAndReveal(idx, 0); openCallHierarchy(editor); - chTree= checkTreeNode(ch, 0, "Derived::method()").getParent(); + chTree= checkTreeNode(ch, 0, "Derived::method() : void").getParent(); checkTreeNode(chTree, 0, 0, null); } @@ -228,13 +228,13 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, false); - Tree chTree= checkTreeNode(ch, 0, "vrefs()").getParent(); - TreeItem item= checkTreeNode(chTree, 0, 0, "Base::vmethod()"); + Tree chTree= checkTreeNode(ch, 0, "vrefs() : void").getParent(); + TreeItem item= checkTreeNode(chTree, 0, 0, "Base::vmethod() : void"); checkTreeNode(chTree, 0, 1, null); expandTreeItem(item); - checkTreeNode(item, 0, "Base::vmethod()"); - checkTreeNode(item, 1, "Derived::vmethod()"); + checkTreeNode(item, 0, "Base::vmethod() : void"); + checkTreeNode(item, 1, "Derived::vmethod() : void"); checkTreeNode(item, 2, null); } @@ -263,8 +263,8 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { int idx = content.indexOf("Foo(3)"); editor.selectAndReveal(idx, 0); openCallHierarchy(editor, true); - Tree chTree= checkTreeNode(ch, 0, "CSome<int>::Foo(const int &)").getParent(); - TreeItem item= checkTreeNode(chTree, 0, 0, "test()"); + Tree chTree= checkTreeNode(ch, 0, "CSome<int>::Foo(const int &) : int").getParent(); + TreeItem item= checkTreeNode(chTree, 0, 0, "test() : void"); checkTreeNode(chTree, 0, 1, null); } @@ -304,23 +304,23 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, false); - Tree chTree= checkTreeNode(ch, 0, "main()").getParent(); - TreeItem ti= checkTreeNode(chTree, 0, 0, "func(Base *)"); + Tree chTree= checkTreeNode(ch, 0, "main() : int").getParent(); + TreeItem ti= checkTreeNode(chTree, 0, 0, "func(Base *) : void"); expandTreeItem(ti); checkTreeNode(chTree, 0, 1, null); - TreeItem ti1= checkTreeNode(ti, 0, "Base::First()"); + TreeItem ti1= checkTreeNode(ti, 0, "Base::First() : void"); expandTreeItem(ti1); - TreeItem ti2= checkTreeNode(ti, 1, "Base::Second()"); + TreeItem ti2= checkTreeNode(ti, 1, "Base::Second() : void"); expandTreeItem(ti2); checkTreeNode(ti, 2, null); - checkTreeNode(ti1, 0, "Base::First()"); - checkTreeNode(ti1, 1, "Derived::First()"); + checkTreeNode(ti1, 0, "Base::First() : void"); + checkTreeNode(ti1, 1, "Derived::First() : void"); checkTreeNode(ti1, 2, null); - checkTreeNode(ti2, 0, "Base::Second()"); - checkTreeNode(ti2, 1, "Derived::Second()"); + checkTreeNode(ti2, 0, "Base::Second() : void"); + checkTreeNode(ti2, 1, "Derived::Second() : void"); checkTreeNode(ti2, 2, null); } @@ -345,14 +345,14 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, false); - Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *)").getParent(); - TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int)"); + Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *) : void").getParent(); + TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int) : void"); idx = content.indexOf("CALL(0"); editor.selectAndReveal(idx+4, 0); openCallHierarchy(editor, true); - chTree= checkTreeNode(ch, 0, "call(int)").getParent(); - ti= checkTreeNode(chTree, 0, 0, "PREFIX_Test(char *, char *)"); + chTree= checkTreeNode(ch, 0, "call(int) : void").getParent(); + ti= checkTreeNode(chTree, 0, 0, "PREFIX_Test(char *, char *) : void"); } // void shared_func(); @@ -380,8 +380,8 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, true); - Tree chTree= checkTreeNode(ch, 0, "shared_func()").getParent(); - TreeItem ti= checkTreeNode(chTree, 0, 0, "call()"); + Tree chTree= checkTreeNode(ch, 0, "shared_func() : void").getParent(); + TreeItem ti= checkTreeNode(chTree, 0, 0, "call() : void"); checkTreeNode(chTree, 0, 1, null); } @@ -410,8 +410,8 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, true); - Tree chTree= checkTreeNode(ch, 0, "shared_func()").getParent(); - TreeItem ti= checkTreeNode(chTree, 0, 0, "call()"); + Tree chTree= checkTreeNode(ch, 0, "shared_func() : void").getParent(); + TreeItem ti= checkTreeNode(chTree, 0, 0, "call() : void"); checkTreeNode(chTree, 0, 1, null); } @@ -438,8 +438,8 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, true); - Tree chTree= checkTreeNode(ch, 0, "doNothing()").getParent(); - TreeItem ti= checkTreeNode(chTree, 0, 0, "main()"); + Tree chTree= checkTreeNode(ch, 0, "doNothing() : void").getParent(); + TreeItem ti= checkTreeNode(chTree, 0, 0, "main() : int"); checkTreeNode(chTree, 0, 1, null); } @@ -473,10 +473,10 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { editor.selectAndReveal(idx, 0); openCallHierarchy(editor, false); - Tree chTree= checkTreeNode(ch, 0, "Base::dosomething()").getParent(); - TreeItem item= checkTreeNode(chTree, 0, 0, "Base::dosomething()"); + Tree chTree= checkTreeNode(ch, 0, "Base::dosomething() : void").getParent(); + TreeItem item= checkTreeNode(chTree, 0, 0, "Base::dosomething() : void"); expandTreeItem(item); - checkTreeNode(chTree, 0, 1, "Derived::dosomething()"); + checkTreeNode(chTree, 0, 1, "Derived::dosomething() : void"); checkTreeNode(chTree, 0, 2, null); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java index 284a6b0c698..43a8c414ae9 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java @@ -69,39 +69,39 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("inline_method(); // r2"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); editor.selectAndReveal(source.indexOf("inline_method(); // r3"), 2); openCallHierarchy(editor); - checkTreeNode(tree, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 0, "func()"); - checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 2, "MyClass::method()"); + checkTreeNode(tree, 0, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 0, "func() : void"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method() : void"); + checkTreeNode(tree, 0, 2, "MyClass::method() : void"); } @@ -142,11 +142,11 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); TreeViewer tv = getCHTreeViewer(); - checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); - TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2()"); + checkTreeNode(tv.getTree(), 0, "MyClass::method3() : void"); + TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method2() : void"); checkTreeNode(tv.getTree(), 0, 1, null); tv.setExpandedState(item.getData(), true); - TreeItem nextItem = checkTreeNode(item, 0, "MyClass::method1()"); + TreeItem nextItem = checkTreeNode(item, 0, "MyClass::method1() : void"); checkTreeNode(item, 1, null); item= nextItem; tv.setExpandedState(item.getData(), true); checkTreeNode(item, 0, null); @@ -192,9 +192,9 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); TreeViewer tv = getCHTreeViewer(); - TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); - TreeItem item0= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1()"); - TreeItem item1= checkTreeNode(tv.getTree(), 0, 1, "MyClass::method2()"); + TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3() : void"); + TreeItem item0= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1() : void"); + TreeItem item1= checkTreeNode(tv.getTree(), 0, 1, "MyClass::method2() : void"); checkTreeNode(tv.getTree(), 0, 2, null); item= null; // method 1 @@ -203,7 +203,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // method 2 tv.setExpandedState(item1.getData(), true); - TreeItem nextItem= checkTreeNode(item1, 0, "MyClass::method1()"); + TreeItem nextItem= checkTreeNode(item1, 0, "MyClass::method1() : void"); checkTreeNode(item1, 1, null); item1= nextItem; tv.setExpandedState(item1.getData(), true); checkTreeNode(item1, 0, null); @@ -252,32 +252,32 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, false); TreeViewer tv = getCHTreeViewer(); - checkTreeNode(tv.getTree(), 0, "main()"); - TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1()"); + checkTreeNode(tv.getTree(), 0, "main() : void"); + TreeItem item= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1() : void"); checkTreeNode(tv.getTree(), 0, 1, null); tv.setExpandedState(item.getData(), true); - TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()"); - TreeItem item1= checkTreeNode(item, 1, "MyClass::method1()"); + TreeItem item0= checkTreeNode(item, 0, "MyClass::method1() : void"); + TreeItem item1= checkTreeNode(item, 1, "MyClass::method1() : void"); checkTreeNode(item, 2, null); item= null; // method 1 try { tv.setExpandedState(item0.getData(), true); - checkTreeNode(item0, 0, "MyClass::method2()"); + checkTreeNode(item0, 0, "MyClass::method2() : void"); } catch (Throwable e) { TreeItem tmp= item0; item0= item1; item1= tmp; } expandTreeItem(item0); - item= checkTreeNode(item0, 0, "MyClass::method2()"); + item= checkTreeNode(item0, 0, "MyClass::method2() : void"); checkTreeNode(item0, 1, null); item0= item; tv.setExpandedState(item0.getData(), true); checkTreeNode(item0, 0, null); // method 2 tv.setExpandedState(item1.getData(), true); - item= checkTreeNode(item1, 0, "MyClass::method3()"); + item= checkTreeNode(item1, 0, "MyClass::method3() : void"); checkTreeNode(item1, 1, null); item1= item; tv.setExpandedState(item1.getData(), true); checkTreeNode(item1, 0, null); @@ -307,12 +307,12 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "cfunc()"); - TreeItem node= checkTreeNode(tree, 0, 0, "cxcpp()"); + checkTreeNode(tree, 0, "cfunc() : void"); + TreeItem node= checkTreeNode(tree, 0, 0, "cxcpp() : void"); checkTreeNode(tree, 0, 1, null); expandTreeItem(node); - checkTreeNode(node, 0, "cppfunc()"); + checkTreeNode(node, 0, "cppfunc() : void"); checkTreeNode(node, 1, null); @@ -321,12 +321,12 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, false); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "cppfunc()"); - node= checkTreeNode(tree, 0, 0, "cxcpp()"); + checkTreeNode(tree, 0, "cppfunc() : void"); + node= checkTreeNode(tree, 0, 0, "cxcpp() : void"); checkTreeNode(tree, 0, 1, null); expandTreeItem(node); - checkTreeNode(node, 0, "cfunc()"); + checkTreeNode(node, 0, "cfunc() : void"); checkTreeNode(node, 1, null); } @@ -353,12 +353,12 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, false); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "cfunc()"); - TreeItem node= checkTreeNode(tree, 0, 0, "cxcpp()"); + checkTreeNode(tree, 0, "cfunc() : void"); + TreeItem node= checkTreeNode(tree, 0, 0, "cxcpp() : void"); checkTreeNode(tree, 0, 1, null); expandTreeItem(node); - checkTreeNode(node, 0, "cppfunc()"); + checkTreeNode(node, 0, "cppfunc() : void"); checkTreeNode(node, 1, null); @@ -367,12 +367,12 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "cppfunc()"); - node= checkTreeNode(tree, 0, 0, "cxcpp()"); + checkTreeNode(tree, 0, "cppfunc() : void"); + node= checkTreeNode(tree, 0, 0, "cxcpp() : void"); checkTreeNode(tree, 0, 1, null); expandTreeItem(node); - checkTreeNode(node, 0, "cfunc()"); + checkTreeNode(node, 0, "cfunc() : void"); checkTreeNode(node, 1, null); } @@ -424,9 +424,9 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "f<T>(T)"); - checkTreeNode(tree, 0, 0, "testint()"); - checkTreeNode(tree, 0, 1, "testintptr()"); + checkTreeNode(tree, 0, "f<T>(T) : void"); + checkTreeNode(tree, 0, 0, "testint() : void"); + checkTreeNode(tree, 0, 1, "testintptr() : void"); checkTreeNode(tree, 0, 2, null); pos= source.indexOf("f(", pos+1); @@ -434,8 +434,8 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "f<char>(char)"); - checkTreeNode(tree, 0, 0, "testchar()"); + checkTreeNode(tree, 0, "f<char>(char) : void"); + checkTreeNode(tree, 0, 0, "testchar() : void"); checkTreeNode(tree, 0, 1, null); pos= source.indexOf("m(", pos+1); @@ -443,8 +443,8 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "CT<T>::m()"); - checkTreeNode(tree, 0, 0, "testint()"); + checkTreeNode(tree, 0, "CT<T>::m() : void"); + checkTreeNode(tree, 0, 0, "testint() : void"); checkTreeNode(tree, 0, 1, null); pos= source.indexOf("m(", pos+1); @@ -452,8 +452,8 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "CT<T *>::m()"); - checkTreeNode(tree, 0, 0, "testintptr()"); + checkTreeNode(tree, 0, "CT<T *>::m() : void"); + checkTreeNode(tree, 0, 0, "testintptr() : void"); checkTreeNode(tree, 0, 1, null); pos= source.indexOf("m(", pos+1); @@ -461,8 +461,8 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "CT<char>::m()"); - checkTreeNode(tree, 0, 0, "testchar()"); + checkTreeNode(tree, 0, "CT<char>::m() : void"); + checkTreeNode(tree, 0, 0, "testchar() : void"); checkTreeNode(tree, 0, 1, null); } @@ -488,16 +488,16 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor, true); Tree tree = getCHTreeViewer().getTree(); - checkTreeNode(tree, 0, "a()"); - TreeItem node = checkTreeNode(tree, 0, 0, "(anonymous)::operator ()()"); + checkTreeNode(tree, 0, "a() : void"); + TreeItem node = checkTreeNode(tree, 0, 0, "(anonymous)::operator ()() : void"); expandTreeItem(node); - node= checkTreeNode(node, 0, "c()"); + node= checkTreeNode(node, 0, "c() : void"); checkTreeNode(node, 1, null); expandTreeItem(node); - node= checkTreeNode(node, 0, "(anonymous)::operator ()()"); + node= checkTreeNode(node, 0, "(anonymous)::operator ()() : void"); checkTreeNode(node, 1, null); expandTreeItem(node); - node= checkTreeNode(node, 0, "d()"); + node= checkTreeNode(node, 0, "d() : void"); checkTreeNode(node, 1, null); expandTreeItem(node); checkTreeNode(node, 0, null); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java index 368f49c8b0d..3df7c8de99f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java @@ -40,6 +40,6 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest { openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "a"); - checkTreeNode(tree, 0, 0, "{init b}()"); + checkTreeNode(tree, 0, 0, "{init b}() : int"); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java index 40befb1a427..4d06bddb2e2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java @@ -196,7 +196,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "S1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : int"}); editor.selectAndReveal(content.indexOf("S2"), 1); openTypeHierarchy(editor); @@ -204,7 +204,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item = checkTreeNode(tree, 0, "S2"); item= checkTreeNode(item, 0, "S2"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a2", "b2"}); + checkMethodTable(new String[] {"a2 : int", "b2 : int"}); editor.selectAndReveal(content.indexOf("S2;"), 1); openTypeHierarchy(editor); @@ -220,7 +220,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "S3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); editor.selectAndReveal(content.indexOf("T3"), 1); openTypeHierarchy(editor); @@ -250,7 +250,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "S1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : int"}); editor.selectAndReveal(content.indexOf("b3"), 1); openTypeHierarchy(editor); @@ -258,7 +258,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "S3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); } // struct S1 { @@ -284,7 +284,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "S1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : int"}); editor.selectAndReveal(content.indexOf("S2"), 1); openTypeHierarchy(editor); @@ -292,7 +292,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "S2"); item= checkTreeNode(item, 0, "S2"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a2", "b2"}); + checkMethodTable(new String[] {"a2 : int", "b2 : int"}); editor.selectAndReveal(content.indexOf("S2;"), 1); openTypeHierarchy(editor); @@ -308,7 +308,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "S3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); editor.selectAndReveal(content.indexOf("T3"), 1); openTypeHierarchy(editor); @@ -339,7 +339,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "S1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : int"}); editor.selectAndReveal(content.indexOf("a3"), 1); openTypeHierarchy(editor); @@ -347,7 +347,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "S3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); } // union U1 { @@ -373,7 +373,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "U1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : char"}); editor.selectAndReveal(content.indexOf("U2"), 1); openTypeHierarchy(editor); @@ -381,7 +381,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item = checkTreeNode(tree, 0, "U2"); item= checkTreeNode(item, 0, "U2"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a2", "b2"}); + checkMethodTable(new String[] {"a2 : int", "b2 : int"}); editor.selectAndReveal(content.indexOf("U2;"), 1); openTypeHierarchy(editor); @@ -397,7 +397,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "U3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); editor.selectAndReveal(content.indexOf("T3"), 1); openTypeHierarchy(editor); @@ -423,7 +423,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "U1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : char"}); } // union U1 { @@ -449,7 +449,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "U1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : int"}); editor.selectAndReveal(content.indexOf("U2"), 1); openTypeHierarchy(editor); @@ -457,7 +457,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "U2"); item= checkTreeNode(item, 0, "U2"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a2", "b2"}); + checkMethodTable(new String[] {"a2 : int", "b2 : int"}); editor.selectAndReveal(content.indexOf("U2;"), 1); @@ -474,7 +474,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "U3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); editor.selectAndReveal(content.indexOf("T3"), 1); openTypeHierarchy(editor); @@ -508,7 +508,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { Tree tree = getHierarchyViewer().getTree(); TreeItem item= checkTreeNode(tree, 0, "U1"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a1", "b1"}); + checkMethodTable(new String[] {"a1 : int", "b1 : int"}); editor.selectAndReveal(content.indexOf("b3"), 1); openTypeHierarchy(editor); @@ -516,6 +516,6 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { item= checkTreeNode(tree, 0, "U3"); item= checkTreeNode(item, 0, "T3"); assertEquals(0, item.getItemCount()); - checkMethodTable(new String[] {"a3", "b3"}); + checkMethodTable(new String[] {"a3 : int", "b3 : int"}); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java index c59a1026a14..0f0f96fad04 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java @@ -74,7 +74,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(0, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("Simple2"), 1); @@ -90,7 +90,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(content.indexOf("Simple3"), 1); @@ -106,7 +106,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("Simple4"), 1); @@ -119,7 +119,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item1.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class Simple1 { @@ -167,7 +167,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(0, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("method2"), 1); @@ -183,7 +183,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(content.indexOf("field3"), 1); @@ -199,7 +199,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("method4"), 1); @@ -212,7 +212,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item1.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class Multi1 { @@ -259,7 +259,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("Multi2"), 1); @@ -277,7 +277,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(content.indexOf("Multi3"), 1); @@ -300,7 +300,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("Multi4"), 1); @@ -323,7 +323,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class Multi1 { @@ -370,7 +370,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("method2"), 1); @@ -388,7 +388,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(content.indexOf("field3"), 1); @@ -411,7 +411,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("method4"), 1); @@ -434,7 +434,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class Diamond1 { @@ -486,7 +486,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("Diamond2"), 1); @@ -504,7 +504,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(content.indexOf("Diamond3"), 1); @@ -522,7 +522,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("Diamond4"), 1); @@ -545,7 +545,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class Diamond1 { @@ -597,7 +597,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("method2"), 1); @@ -615,7 +615,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(content.indexOf("field3"), 1); @@ -633,7 +633,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("method4"), 1); @@ -656,7 +656,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class ViaTypedef1 { @@ -702,7 +702,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(0, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1); @@ -734,7 +734,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("ViaTypedef4"), 1); @@ -747,7 +747,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item1.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // class ViaTypedef1 { @@ -793,7 +793,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(0, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1); @@ -825,7 +825,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(content.indexOf("method4"), 1); @@ -838,7 +838,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { assertEquals(1, item1.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } // template <typename T> class SimpleTemplate { @@ -862,6 +862,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { item1= checkTreeNode(tree, 0, "SimpleTemplate"); assertEquals(1, tree.getItemCount()); assertEquals(0, item1.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : T", "method1() : T"}); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java index f4a0c3f16b1..f6631f137f1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java @@ -165,18 +165,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item1= checkTreeNode(tree, 0, "Simple1"); assertEquals(1, tree.getItemCount()); - - item2= checkTreeNode(item1, 0, "Simple2"); - item4= checkTreeNode(item1, 1, "Simple4"); - assertEquals(2, item1.getItemCount()); - - item3= checkTreeNode(item2, 0, "Simple3"); - assertEquals(1, item2.getItemCount()); - - assertEquals(0, item3.getItemCount()); - assertEquals(0, item4.getItemCount()); - - + assertEquals(0, item1.getItemCount()); editor.selectAndReveal(content.indexOf("method2"), 1); openQuickTypeHierarchy(editor); @@ -187,11 +176,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item2= checkTreeNode(item1, 0, "Simple2"); assertEquals(1, item1.getItemCount()); - item3= checkTreeNode(item2, 0, "Simple3"); - assertEquals(1, item2.getItemCount()); - - assertEquals(0, item3.getItemCount()); - + assertEquals(0, item2.getItemCount()); editor.selectAndReveal(content.indexOf("field3"), 1); @@ -374,15 +359,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item1= checkTreeNode(tree, 0, "Multi1"); assertEquals(1, tree.getItemCount()); - item3= checkTreeNode(item1, 0, "Multi3"); - assertEquals(1, item1.getItemCount()); + assertEquals(0, item1.getItemCount()); - item4= checkTreeNode(item3, 0, "Multi4"); - assertEquals(1, item3.getItemCount()); - - assertEquals(0, item4.getItemCount()); - - editor.selectAndReveal(content.indexOf("method2"), 1); openQuickTypeHierarchy(editor); @@ -391,16 +369,9 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item2= checkTreeNode(tree, 0, "Multi2"); assertEquals(1, tree.getItemCount()); - item3= checkTreeNode(item2, 0, "Multi3"); - assertEquals(1, item2.getItemCount()); + assertEquals(0, item2.getItemCount()); - item4= checkTreeNode(item3, 0, "Multi4"); - assertEquals(1, item3.getItemCount()); - - assertEquals(0, item4.getItemCount()); - - editor.selectAndReveal(content.indexOf("field3"), 1); openQuickTypeHierarchy(editor); tree= getQuickTypeHierarchyViewer(editor); @@ -410,16 +381,11 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item3= checkTreeNode(item1, 0, "Multi3"); assertEquals(1, item1.getItemCount()); - item4= checkTreeNode(item3, 0, "Multi4"); - assertEquals(1, item3.getItemCount()); - assertEquals(0, item4.getItemCount()); + assertEquals(0, item3.getItemCount()); item3= checkTreeNode(item2, 0, "Multi3"); - assertEquals(1, item1.getItemCount()); - item4= checkTreeNode(item3, 0, "Multi4"); - assertEquals(1, item3.getItemCount()); - assertEquals(0, item4.getItemCount()); - + assertEquals(1, item2.getItemCount()); + assertEquals(0, item3.getItemCount()); @@ -596,19 +562,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item1= checkTreeNode(tree, 0, "Diamond1"); assertEquals(1, tree.getItemCount()); - item2= checkTreeNode(item1, 0, "Diamond2"); - item3= checkTreeNode(item1, 1, "Diamond3"); - assertEquals(2, item1.getItemCount()); + assertEquals(0, item1.getItemCount()); - item4= checkTreeNode(item2, 0, "Diamond4"); - assertEquals(1, item2.getItemCount()); - assertEquals(0, item4.getItemCount()); - - item4= checkTreeNode(item3, 0, "Diamond4"); - assertEquals(1, item3.getItemCount()); - assertEquals(0, item4.getItemCount()); - - editor.selectAndReveal(content.indexOf("method2"), 1); @@ -620,13 +575,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item2= checkTreeNode(item1, 0, "Diamond2"); assertEquals(1, item1.getItemCount()); - - item4= checkTreeNode(item2, 0, "Diamond4"); - assertEquals(1, item2.getItemCount()); - assertEquals(0, item4.getItemCount()); - - - + assertEquals(0, item2.getItemCount()); + editor.selectAndReveal(content.indexOf("field3"), 1); openQuickTypeHierarchy(editor); @@ -637,11 +587,9 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item3= checkTreeNode(item1, 0, "Diamond3"); assertEquals(1, item1.getItemCount()); - - item4= checkTreeNode(item3, 0, "Diamond4"); - assertEquals(1, item3.getItemCount()); - assertEquals(0, item4.getItemCount()); + assertEquals(0, item3.getItemCount()); + editor.selectAndReveal(content.indexOf("method4"), 1); openQuickTypeHierarchy(editor); tree= getQuickTypeHierarchyViewer(editor); @@ -794,17 +742,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { item1= checkTreeNode(tree, 0, "ViaTypedef1"); assertEquals(1, tree.getItemCount()); - - item2= checkTreeNode(item1, 0, "ViaTypedef2"); - item4= checkTreeNode(item1, 1, "ViaTypedef4"); - assertEquals(2, item1.getItemCount()); - - item3= checkTreeNode(item2, 0, "ViaTypedef3"); - assertEquals(1, item2.getItemCount()); - - assertEquals(0, item3.getItemCount()); - assertEquals(0, item4.getItemCount()); - + assertEquals(0, item1.getItemCount()); editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java index 1e4caa21779..717fdb4cbf0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java @@ -113,7 +113,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest { assertEquals(0, item3.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field1", "method1()"}); + checkMethodTable(new String[] {"field1 : int", "method1() : int"}); editor.selectAndReveal(source.indexOf("Simple2"), 1); @@ -129,7 +129,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field2", "method2()"}); + checkMethodTable(new String[] {"field2 : int", "method2() : int"}); editor.selectAndReveal(source.indexOf("Simple3"), 1); @@ -145,7 +145,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest { assertEquals(1, item2.getItemCount()); assertEquals(0, item3.getItemCount()); - checkMethodTable(new String[] {"field3", "method3()"}); + checkMethodTable(new String[] {"field3 : int", "method3() : int"}); editor.selectAndReveal(source.indexOf("Simple4"), 1); @@ -158,6 +158,6 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest { assertEquals(1, item1.getItemCount()); assertEquals(0, item4.getItemCount()); - checkMethodTable(new String[] {"field4", "method4()"}); + checkMethodTable(new String[] {"field4 : int", "method4() : int"}); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java index c3b5ca59833..10e822ba8c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java @@ -37,7 +37,6 @@ public class Strings { * <p> * This is used for performance optimization. * </p> - * @since 3.4 */ public static final boolean USE_TEXT_PROCESSOR; static { @@ -469,6 +468,47 @@ public class Strings { return LegacyActionTools.removeMnemonics(string); } + + /** + * Adds special marks so that that the given styled string is readable in a BiDi environment. + * + * @param styledString the styled string + * @return the processed styled string + */ + public static StyledString markLTR(StyledString styledString) { + + /* + * NOTE: For performance reasons we do not call markLTR(styledString, null) + */ + + if (!USE_TEXT_PROCESSOR) + return styledString; + + String inputString= styledString.getString(); + String string= TextProcessor.process(inputString); + if (string != inputString) + insertMarks(styledString, inputString, string); + return styledString; + } + + /** + * Adds special marks so that that the given styled string is readable in a BiDi environment. + * + * @param styledString the styled string + * @param delimiters the additional delimiters + * @return the processed styled string + */ + public static StyledString markLTR(StyledString styledString, String delimiters) { + if (!USE_TEXT_PROCESSOR) + return styledString; + + String inputString= styledString.getString(); + String string= TextProcessor.process(inputString, delimiters); + if (string != inputString) + insertMarks(styledString, inputString, string); + return styledString; + } + /** * Adds special marks so that that the given string is readable in a BiDi environment. * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java index 8d49d66bb10..cf271af08ce 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,10 +24,10 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ISourceReference; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.internal.ui.util.EditorUtility; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; public class OpenActionUtil { @@ -67,17 +67,17 @@ public class OpenActionUtil { } /** - * Shows a dialog for resolving an ambigous C element. - * Utility method that can be called by subclassers. + * Shows a dialog for resolving an ambiguous C element. + * Utility method that can be called by subclasses. */ public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message) { return selectCElement(elements, shell, title, message, 0, 0); } /** - * Shows a dialog for resolving an ambigous C element. - * @see CElementBaseLabels - * @param elements an array of ambigous elements. + * Shows a dialog for resolving an ambiguous C element. + * @see CElementLabels + * @param elements an array of ambiguous elements. * @param shell parent shell for showing the dialog * @param title title of the dialog * @param message message to be shown in the dialog @@ -86,7 +86,7 @@ public class OpenActionUtil { * @return the selected element or <code>null</code> * @since 4.0 */ - public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message, int textFlags, int imageFlags) { + public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message, long textFlags, int imageFlags) { int nResults= elements.length; if (nResults == 0) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java index bcc9de0967c..1d6c9524dd8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,20 +15,20 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; /** * Action used for the include browser forward / backward buttons */ public class CHHistoryAction extends Action { - final static int LABEL_OPTIONS= - CElementBaseLabels.M_PARAMETER_TYPES | - CElementBaseLabels.ALL_FULLY_QUALIFIED | - CElementBaseLabels.TEMPLATE_ARGUMENTS | - CElementBaseLabels.MF_POST_FILE_QUALIFIED; + final static long LABEL_OPTIONS= + CElementLabels.M_PARAMETER_TYPES | + CElementLabels.ALL_FULLY_QUALIFIED | + CElementLabels.TEMPLATE_ARGUMENTS | + CElementLabels.MF_POST_FILE_QUALIFIED; private CHViewPart fViewPart; private ICElement fElement; @@ -38,7 +38,7 @@ public class CHHistoryAction extends Action { fViewPart= viewPart; fElement= element; - String elementName= CElementBaseLabels.getElementLabel(element, LABEL_OPTIONS); + String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS); setText(elementName); setImageDescriptor(getImageDescriptor(element)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java index 104825814a9..b8166c2f110 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; @@ -66,7 +66,7 @@ public class CHHistoryListAction extends Action { } }; - LabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS); + ILabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS); fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java index ffd203478af..663231f1bf9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,14 +7,15 @@ * * Contributors: * Markus Schorn - initial API and implementation + * Patrick Hofer [bug 325799] *******************************************************************************/ package org.eclipse.cdt.internal.ui.callhierarchy; import java.util.HashMap; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.StyledCellLabelProvider; +import org.eclipse.jface.viewers.StyledString; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -23,18 +24,19 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor; -public class CHLabelProvider extends LabelProvider implements IColorProvider { - private final static int LABEL_OPTIONS_SIMPLE = CElementBaseLabels.ALL_FULLY_QUALIFIED - | CElementBaseLabels.M_PARAMETER_TYPES | CElementBaseLabels.TEMPLATE_ARGUMENTS; - private final static int LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementBaseLabels.MF_POST_FILE_QUALIFIED; +public class CHLabelProvider extends AppearanceAwareLabelProvider { + private final static long LABEL_OPTIONS_SIMPLE = CElementLabels.ALL_FULLY_QUALIFIED + | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.TEMPLATE_ARGUMENTS; + private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED; private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, CElementImageProvider.OVERLAY_ICONS); private CHContentProvider fContentProvider; @@ -76,7 +78,7 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider { if (decl != null) { String label; if (node.isMultiDef()) { - int options= fCLabelProvider.getTextFlags(); + long options= fCLabelProvider.getTextFlags(); fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE); label= fCLabelProvider.getText(decl); fCLabelProvider.setTextFlags(options); @@ -91,12 +93,49 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider { if (refCount > 1) { label += NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches); //$NON-NLS-1$ } - return label; + return decorateText(label, element); } } return super.getText(element); } + @Override + public StyledString getStyledText(Object element) { + if (element instanceof CHNode) { + CHNode node= (CHNode) element; + ICElement decl= node.getOneRepresentedDeclaration(); + if (decl != null) { + StyledString label; + if (node.isMultiDef()) { + long options= fCLabelProvider.getTextFlags(); + fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE); + label= fCLabelProvider.getStyledText(decl); + fCLabelProvider.setTextFlags(options); + } + else { + label= fCLabelProvider.getStyledText(decl); + if (node.isInitializer()) { + label= addInitializerDecoration(label); + } + } + int refCount= node.getReferenceCount(); + if (refCount > 1) { + final int offset= label.length(); + label.append(NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches)); //$NON-NLS-1$ + label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER); + + } + //return label; + String decorated= decorateText(label.getString(), element); + if (decorated != null) { + return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label); + } + return label; + } + } + return fCLabelProvider.getStyledText(element); + } + private String addInitializerDecoration(String label) { int i= 0; char[] content= label.toCharArray(); @@ -115,6 +154,27 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider { return buf.toString(); } + private StyledString addInitializerDecoration(StyledString label) { + int i= 0; + char[] content= label.toString().toCharArray(); + for (i = 0; i < content.length; i++) { + char c = content[i]; + if (c == '-' || Character.isWhitespace(c)) { + break; + } + } + StyledString label2= new StyledString(); + label2.append("{init "); //$NON-NLS-1$ + i += label2.length(); + label2.append(label); + label2.insert('}', i++); + label2.insert('(', i++); + label2.insert(')', i++); + label2.setStyle(0, i, null); + return label2; + } + + @Override public void dispose() { fCLabelProvider.dispose(); @@ -161,11 +221,8 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider { return result; } - public Color getBackground(Object element) { - return null; - } - - public Color getForeground(Object element) { + @Override + public Color getForeground(Object element) { if (element instanceof CHMultiDefNode) { return fColorInactive; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java index a0af6b432b9..3042732a4ea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java @@ -66,7 +66,6 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IFunction; import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.actions.CdtActionConstants; import org.eclipse.cdt.ui.actions.OpenViewActionGroup; @@ -82,6 +81,7 @@ import org.eclipse.cdt.internal.ui.util.CoreUtility; import org.eclipse.cdt.internal.ui.util.Messages; import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener; import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; @@ -318,7 +318,7 @@ public class CHViewPart extends ViewPart { fLabelProvider= new CHLabelProvider(display, fContentProvider); fTreeViewer= new ExtendedTreeViewer(fViewerPage); fTreeViewer.setContentProvider(fContentProvider); - fTreeViewer.setLabelProvider(fLabelProvider); + fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider)); fTreeViewer.setAutoExpandLevel(2); fTreeViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { @@ -641,7 +641,7 @@ public class CHViewPart extends ViewPart { String format, scope, label; // label - label= CElementBaseLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS); + label= CElementLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS); // scope IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet(); @@ -704,7 +704,7 @@ public class CHViewPart extends ViewPart { final ICElement element= node.getRepresentedDeclaration(); if (element != null) { String label= Messages.format(CHMessages.CHViewPart_FocusOn_label, - CElementLabels.getTextLabel(element, CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES)); + CElementLabels.getTextLabel(element, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES)); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) { @Override public void run() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java index a9eb3f86e9f..59e228e1c20 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,7 +36,7 @@ import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.model.ext.ICElementHandle; @@ -103,7 +103,7 @@ public class CallHierarchyUI { } elem = OpenActionUtil.selectCElement(input, window.getShell(), CHMessages.CallHierarchyUI_label, CHMessages.CallHierarchyUI_selectMessage, - CElementBaseLabels.ALL_DEFAULT | CElementBaseLabels.MF_POST_FILE_QUALIFIED, 0); + CElementLabels.ALL_DEFAULT | CElementLabels.MF_POST_FILE_QUALIFIED, 0); break; } if (elem != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java index e8ae70b19a1..f3d9221b7df 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 QNX Software Systems and others. + * Copyright (c) 2002, 2010 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.cview; +import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -35,7 +36,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; */ public class CViewLabelProvider extends AppearanceAwareLabelProvider { - public CViewLabelProvider(int textFlags, int imageFlags) { + public CViewLabelProvider(long textFlags, int imageFlags) { super(textFlags, imageFlags); } @@ -46,8 +47,8 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider { public String getText(Object element) { if (element instanceof IncludeReferenceProxy) { final IIncludeReference ref = ((IncludeReferenceProxy)element).getReference(); - final IPath location = ref.getPath(); - final IContainer[] containers= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); + final IPath uriPathLocation = ref.getPath().makeAbsolute(); + final IContainer[] containers= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(uriPathLocation)); if (containers.length > 0) { // bug 192707, prefer the project the reference belongs to. final ICProject prj= ref.getCProject(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java index 4f4355fabab..d7a65ac641d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java @@ -60,7 +60,7 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IncludesGrouping; import org.eclipse.cdt.ui.PreferenceConstants; @@ -100,7 +100,7 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent */ private boolean fSimpleName; - public COutlineLabelProvider(int textFlags, int imageFlags) { + public COutlineLabelProvider(long textFlags, int imageFlags) { super(textFlags, imageFlags); PreferenceConstants.getPreferenceStore().addPropertyChangeListener(this); fSimpleName= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS); @@ -113,9 +113,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent } @Override - protected int evaluateTextFlags(Object element) { + protected long evaluateTextFlags(Object element) { if (fSimpleName) { - return super.evaluateTextFlags(element) | CElementBaseLabels.M_SIMPLE_NAME | CElementBaseLabels.F_SIMPLE_NAME; + return super.evaluateTextFlags(element) | CElementLabels.M_SIMPLE_NAME | CElementLabels.F_SIMPLE_NAME; } return super.evaluateTextFlags(element); } @@ -272,7 +272,7 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent } } - private static final int TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementBaseLabels.F_APP_TYPE_SIGNATURE | CElementBaseLabels.M_APP_RETURNTYPE; + private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE; private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS; protected ITextEditor fEditor; protected ITranslationUnit fInput; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java index 144ada290de..6020d18e116 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,8 +15,8 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; @@ -33,7 +33,7 @@ public class IBHistoryAction extends Action { fViewPart= viewPart; fElement= element; - String elementName= CElementBaseLabels.getElementLabel(element, CElementBaseLabels.ALL_POST_QUALIFIED); + String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED); setText(elementName); setImageDescriptor(getImageDescriptor(element)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java index a73e4bc4e0a..4ed390a4c1c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,7 @@ import java.util.List; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.StatusDialog; +import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; @@ -27,7 +28,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; @@ -66,7 +67,7 @@ public class IBHistoryListAction extends Action { } }; - CUILabelProvider labelProvider= new CUILabelProvider(CElementBaseLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS); + ILabelProvider labelProvider= new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS); fHistoryList= new ListDialogField<ITranslationUnit>(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java index 83e89b0904a..2f3318be3e8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java @@ -58,7 +58,6 @@ import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.ui.CUIPlugin; @@ -68,6 +67,7 @@ import org.eclipse.cdt.internal.core.model.ext.ICElementHandle; import org.eclipse.cdt.internal.ui.search.LineSearchElement.Match; import org.eclipse.cdt.internal.ui.util.Messages; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; @@ -78,10 +78,10 @@ public abstract class PDOMSearchQuery implements ISearchQuery { public static final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS; public static final int FIND_ALL_OCCURRENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES; - protected final static int LABEL_FLAGS= - CElementBaseLabels.M_PARAMETER_TYPES | - CElementBaseLabels.ALL_FULLY_QUALIFIED | - CElementBaseLabels.TEMPLATE_ARGUMENTS; + protected final static long LABEL_FLAGS= + CElementLabels.M_PARAMETER_TYPES | + CElementLabels.ALL_FULLY_QUALIFIED | + CElementLabels.TEMPLATE_ARGUMENTS; protected PDOMSearchResult result = new PDOMSearchResult(this); @@ -129,7 +129,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery { if (names.length > 0) { ICElementHandle elem= IndexUI.getCElementForName((ICProject) null, index, names[0]); if (elem != null) { - return CElementBaseLabels.getElementLabel(elem, LABEL_FLAGS); + return CElementLabels.getElementLabel(elem, LABEL_FLAGS); } } return defaultLabel; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 13e9b542a7d..1f2dc556a31 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -74,7 +74,7 @@ import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.ui.CUIPlugin; @@ -493,7 +493,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { ICElement[] elemArray= uniqueElements.toArray(new ICElement[uniqueElements.size()]); target = (ISourceReference) OpenActionUtil.selectCElement(elemArray, fAction.getSite().getShell(), CEditorMessages.OpenDeclarationsAction_dialog_title, CEditorMessages.OpenDeclarationsAction_selectMessage, - CElementBaseLabels.ALL_DEFAULT | CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.MF_POST_FILE_QUALIFIED, 0); + CElementLabels.ALL_DEFAULT | CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.MF_POST_FILE_QUALIFIED, 0); } if (target != null) { ITranslationUnit tu= target.getTranslationUnit(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java index 3f2bb413ed1..a0b4f58acb3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 QNX Software Systems and others. + * Copyright (c) 2005, 2010 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,15 +21,15 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; + import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; -import org.eclipse.cdt.internal.ui.editor.AbstractCModelOutlinePage; import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider; import org.eclipse.cdt.internal.ui.editor.LexicalSortingAction; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; /** @@ -40,7 +40,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; */ public class COutlineInformationControl extends AbstractInformationControl { - private static final int TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementBaseLabels.F_APP_TYPE_SIGNATURE | CElementBaseLabels.M_APP_RETURNTYPE; + private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE; private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS; private ICElement fInput = null; @@ -76,8 +76,8 @@ public class COutlineInformationControl extends AbstractInformationControl { treeViewer.setContentProvider(fOutlineContentProvider); fSortingAction= new LexicalSortingAction(treeViewer, ".isChecked"); //$NON-NLS-1$ treeViewer.addFilter(new NamePatternFilter()); - treeViewer.setLabelProvider(new DecoratingCLabelProvider( - new AbstractCModelOutlinePage.COutlineLabelProvider(TEXT_FLAGS, IMAGE_FLAGS), true)); + treeViewer.setLabelProvider(new DecoratingCLabelProvider(new AppearanceAwareLabelProvider(TEXT_FLAGS, + IMAGE_FLAGS), true)); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); return treeViewer; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java index 940d305d3c1..4c9d0f98d9e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,19 +15,19 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; /** * Action used for the include browser forward / backward buttons */ public class THHistoryAction extends Action { - final static int LABEL_OPTIONS= - CElementBaseLabels.M_PARAMETER_TYPES | - CElementBaseLabels.ALL_FULLY_QUALIFIED | - CElementBaseLabels.MF_POST_FILE_QUALIFIED; + final static long LABEL_OPTIONS= + CElementLabels.M_PARAMETER_TYPES | + CElementLabels.ALL_FULLY_QUALIFIED | + CElementLabels.MF_POST_FILE_QUALIFIED; private THViewPart fViewPart; private ICElement fElement; @@ -37,7 +37,7 @@ public class THHistoryAction extends Action { fViewPart= hierarchyView; fElement= element; - String elementName= CElementBaseLabels.getElementLabel(element, LABEL_OPTIONS); + String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS); setText(elementName); setImageDescriptor(getImageDescriptor(element)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java index 06896e4ed66..81391ee6717 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; @@ -66,7 +66,7 @@ public class THHistoryListAction extends Action { } }; - LabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS); + ILabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS); fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java index 845ee7ae879..783b271a684 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,8 +14,9 @@ import java.util.HashMap; import java.util.Iterator; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.StyledCellLabelProvider; +import org.eclipse.jface.viewers.StyledString; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; @@ -23,16 +24,18 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.ui.CElementImageDescriptor; +import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor; -public class THLabelProvider extends LabelProvider implements IColorProvider { - private final static int LABEL_OPTIONS_SIMPLE= CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES; - private final static int LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementBaseLabels.MF_POST_FILE_QUALIFIED; +public class THLabelProvider extends AppearanceAwareLabelProvider { + + private final static long LABEL_OPTIONS_SIMPLE= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE; + private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED; private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, 0); private THHierarchyModel fModel; @@ -76,12 +79,31 @@ public class THLabelProvider extends LabelProvider implements IColorProvider { ICElement decl= node.getElement(); if (decl != null) { String label= fCLabelProvider.getText(decl); - return label; + return decorateText(label, element); } } return super.getText(element); } + @Override + public StyledString getStyledText(Object element) { + if (element instanceof THNode) { + THNode node= (THNode) element; + ICElement decl= node.getElement(); + if (decl != null) { + StyledString label= fCLabelProvider.getStyledText(decl); + if (fModel.isShowInheritedMembers()) { + } + String decorated= decorateText(label.getString(), element); + if (decorated != null) { + return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label); + } + return label; + } + } + return super.getStyledText(element); + } + @Override public void dispose() { fCLabelProvider.dispose(); @@ -118,11 +140,8 @@ public class THLabelProvider extends LabelProvider implements IColorProvider { return result; } - public Color getBackground(Object element) { - return null; - } - - public Color getForeground(Object element) { + @Override + public Color getForeground(Object element) { if (element instanceof THNode) { THNode node= (THNode) element; if (node.isFiltered()) { @@ -143,4 +162,9 @@ public class THLabelProvider extends LabelProvider implements IColorProvider { public void setHideNonImplementers(boolean val) { fHideNonImplementers= val; } + + @Override + public void addLabelDecorator(ILabelDecorator decorator) { + super.addLabelDecorator(decorator); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java index b7e779eb0c1..d13cee18982 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java @@ -84,7 +84,6 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IDeclaration; import org.eclipse.cdt.core.model.IMember; import org.eclipse.cdt.core.model.IMethodDeclaration; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.actions.CdtActionConstants; @@ -98,9 +97,11 @@ import org.eclipse.cdt.internal.ui.actions.CopyTreeAction; import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds; import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider; +import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; +import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener; import org.eclipse.cdt.internal.ui.viewsupport.SelectionProviderMediator; import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI; @@ -129,8 +130,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter { private static final int ORIENTATION_SINGLE = 3; // options for label provider - private static final int MEMBER_LABEL_OPTIONS_SIMPLE = CElementBaseLabels.M_PARAMETER_TYPES; - private static final int MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE | CElementBaseLabels.ALL_POST_QUALIFIED; + private static final long MEMBER_LABEL_OPTIONS_SIMPLE = CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE; + private static final long MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE | CElementLabels.ALL_POST_QUALIFIED; private static final int MEMBER_ICON_OPTIONS = CElementImageProvider.OVERLAY_ICONS; // state information @@ -402,7 +403,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter { if (hierarchyView && !elem.equals(fModel.getInput())) { String label= MessageFormat.format(Messages.THViewPart_FocusOn, new Object[] { - CElementLabels.getTextLabel(elem, CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES) + CElementLabels.getTextLabel(elem, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES) }); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) { @Override @@ -456,10 +457,10 @@ public class THViewPart extends ViewPart implements ITHModelPresenter { } private Control createMemberControl(ViewForm parent) { - fMemberLabelProvider= new CUILabelProvider(MEMBER_LABEL_OPTIONS_SIMPLE, MEMBER_ICON_OPTIONS); + fMemberLabelProvider= new AppearanceAwareLabelProvider(MEMBER_LABEL_OPTIONS_SIMPLE, MEMBER_ICON_OPTIONS); fMemberViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); fMemberViewer.setContentProvider(new THMemberContentProvider()); - fMemberViewer.setLabelProvider(fMemberLabelProvider); + fMemberViewer.setLabelProvider(new DecoratingCLabelProvider(fMemberLabelProvider, true)); fMemberViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { onOpenElement(event.getSelection()); @@ -529,7 +530,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter { fHierarchyLabelProvider= new THLabelProvider(display, fModel); fHierarchyTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); fHierarchyTreeViewer.setContentProvider(new THContentProvider()); - fHierarchyTreeViewer.setLabelProvider(fHierarchyLabelProvider); + fHierarchyTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fHierarchyLabelProvider, true)); fHierarchyTreeViewer.setSorter(new ViewerSorter()); fHierarchyTreeViewer.setUseHashlookup(true); fHierarchyTreeViewer.addOpenListener(new IOpenListener() { @@ -883,7 +884,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter { String label; // label - label= CElementBaseLabels.getElementLabel(elem, 0); + label= CElementLabels.getElementLabel(elem, 0); // scope IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet(); @@ -900,7 +901,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter { if (node != null) { elem= node.getElement(); if (elem != null) { - label= CElementBaseLabels.getElementLabel(elem, 0); + label= CElementLabels.getElementLabel(elem, 0); image= fHierarchyLabelProvider.getImage(elem); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java index 26a8f9b7b27..7c0c66584ef 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.ui.viewsupport; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; /** * CUILabelProvider that respects settings from the Appearance preference page. @@ -23,13 +23,13 @@ import org.eclipse.cdt.core.model.util.CElementBaseLabels; */ public class AppearanceAwareLabelProvider extends CUILabelProvider implements IPropertyChangeListener { - public final static int DEFAULT_TEXTFLAGS= CElementBaseLabels.M_PARAMETER_TYPES | CElementBaseLabels.PROJECT_POST_QUALIFIED; + public final static long DEFAULT_TEXTFLAGS= CElementLabels.M_PARAMETER_TYPES | CElementLabels.PROJECT_POST_QUALIFIED | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE; public final static int DEFAULT_IMAGEFLAGS= CElementImageProvider.OVERLAY_ICONS; /** * Constructor for AppearanceAwareLabelProvider. */ - public AppearanceAwareLabelProvider(int textFlags, int imageFlags) { + public AppearanceAwareLabelProvider(long textFlags, int imageFlags) { super(textFlags, imageFlags); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java index ca649e62c6c..095e2eba145 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java @@ -77,22 +77,22 @@ public class CElementImageProvider { public final static int LIGHT_TYPE_ICONS= 0x4; /** - * Show error overrlay. + * Show error overlay. */ public final static int OVERLAY_ERROR= 0x8; /** - * Show warning overrlay + * Show warning overlay */ public final static int OVERLAY_WARNING= 0x10; /** - * Show override overrlay. + * Show override overlay. */ public final static int OVERLAY_OVERRIDE= 0x20; /** - * Show implements overrlay. + * Show implements overlay. */ public final static int OVERLAY_IMPLEMENTS= 0x40; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java new file mode 100644 index 00000000000..15c3b2bb2ba --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java @@ -0,0 +1,973 @@ +/******************************************************************************* + * Copyright (c) 2003, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corp. - Rational Software - initial implementation + * Markus Schorn (Wind River Systems) + * Gerhard Schaber (Wind River Systems) + * Patrick Hofer [bug 325799] + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.viewsupport; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.jface.viewers.StyledString.Styler; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IEnumerator; +import org.eclipse.cdt.core.model.IField; +import org.eclipse.cdt.core.model.IFunctionDeclaration; +import org.eclipse.cdt.core.model.IInheritance; +import org.eclipse.cdt.core.model.IMacro; +import org.eclipse.cdt.core.model.IMethodDeclaration; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.ITemplate; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.model.ITypeDef; +import org.eclipse.cdt.core.model.IVariableDeclaration; +import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.core.model.CoreModelMessages; + + +// Most parts of this file were previously located in CElementLabels. +// FlexibleBuffer and sub-types are taken from JDTs JavaElementLabelComposer. + +/** + * Creates labels for ICElement objects. + */ +public class CElementLabelComposer { + + /** + * An adapter for buffer supported by the label composer. + */ + public static abstract class FlexibleBuffer { + + /** + * Appends the string representation of the given character to the buffer. + * + * @param ch the character to append + * @return a reference to this object + */ + public abstract FlexibleBuffer append(char ch); + + /** + * Appends the given string to the buffer. + * + * @param string the string to append + * @return a reference to this object + */ + public abstract FlexibleBuffer append(String string); + + /** + * Returns the length of the the buffer. + * + * @return the length of the current string + */ + public abstract int length(); + + /** + * Sets a styler to use for the given source range. The range must be subrange of actual + * string of this buffer. Stylers previously set for that range will be overwritten. + * + * @param offset the start offset of the range + * @param length the length of the range + * @param styler the styler to set + * + * @throws StringIndexOutOfBoundsException if <code>start</code> is less than zero, or if + * offset plus length is greater than the length of this object. + */ + public abstract void setStyle(int offset, int length, Styler styler); + } + + public static class FlexibleStringBuffer extends FlexibleBuffer { + private final StringBuffer fStringBuffer; + + public FlexibleStringBuffer(StringBuffer stringBuffer) { + fStringBuffer= stringBuffer; + } + + @Override + public FlexibleBuffer append(char ch) { + fStringBuffer.append(ch); + return this; + } + + @Override + public FlexibleBuffer append(String string) { + fStringBuffer.append(string); + return this; + } + + @Override + public int length() { + return fStringBuffer.length(); + } + + @Override + public void setStyle(int offset, int length, Styler styler) { + // no style + } + + @Override + public String toString() { + return fStringBuffer.toString(); + } + } + + public static class FlexibleStyledString extends FlexibleBuffer { + private final StyledString fStyledString; + + public FlexibleStyledString(StyledString stringBuffer) { + fStyledString= stringBuffer; + } + + @Override + public FlexibleBuffer append(char ch) { + fStyledString.append(ch); + return this; + } + + @Override + public FlexibleBuffer append(String string) { + fStyledString.append(string); + return this; + } + + @Override + public int length() { + return fStyledString.length(); + } + + @Override + public void setStyle(int offset, int length, Styler styler) { + fStyledString.setStyle(offset, length, styler); + } + + @Override + public String toString() { + return fStyledString.toString(); + } + } + + + private static final Styler QUALIFIER_STYLE= StyledString.QUALIFIER_STYLER; + //private static final Styler COUNTER_STYLE= StyledString.COUNTER_STYLER; + private static final Styler DECORATIONS_STYLE= StyledString.DECORATIONS_STYLER; + + + private final FlexibleBuffer fBuffer; + + /** + * Creates a new java element composer based on the given buffer. + * + * @param buffer the buffer + */ + public CElementLabelComposer(FlexibleBuffer buffer) { + fBuffer= buffer; + } + + /** + * Creates a new java element composer based on the given buffer. + * + * @param buffer the buffer + */ + public CElementLabelComposer(StyledString buffer) { + this(new FlexibleStyledString(buffer)); + } + + /** + * Creates a new java element composer based on the given buffer. + * + * @param buffer the buffer + */ + public CElementLabelComposer(StringBuffer buffer) { + this(new FlexibleStringBuffer(buffer)); + } + + + /** + * Appends the label for an element to a StringBuffer. + * @param element any element (IMethodDeclaration, IField, ITypeDef, IVariableDeclaration, etc.) + * @param flags any of the flags (M_*, F_*, ROOT_*, etc.) defined in this class + */ + public void appendElementLabel(ICElement element, long flags) { + int type= element.getElementType(); + ISourceRoot root= null; + + if (type != ICElement.C_MODEL && type != ICElement.C_PROJECT && !(type == ICElement.C_CCONTAINER && element instanceof ISourceRoot)) + root= getSourceRoot(element); + if (root != null && getFlag(flags, CElementLabels.PREPEND_ROOT_PATH)) { + getSourceRootLabel(root, CElementLabels.ROOT_QUALIFIED); + fBuffer.append(CElementLabels.CONCAT_STRING); + } + switch (type) { + case ICElement.C_MACRO: + appendMacroLabel((IMacro) element, flags); + break; + case ICElement.C_METHOD : + case ICElement.C_METHOD_DECLARATION: + case ICElement.C_TEMPLATE_METHOD: + case ICElement.C_TEMPLATE_METHOD_DECLARATION: + appendMethodLabel( (IMethodDeclaration) element, flags); + break; + case ICElement.C_FUNCTION: + case ICElement.C_FUNCTION_DECLARATION: + case ICElement.C_TEMPLATE_FUNCTION: + case ICElement.C_TEMPLATE_FUNCTION_DECLARATION: + appendFunctionLabel( (IFunctionDeclaration) element, flags); + break; + case ICElement.C_FIELD : + appendFieldLabel( (IField) element, flags); + break; + case ICElement.C_VARIABLE: + case ICElement.C_VARIABLE_DECLARATION: + appendVariableLabel( (IVariableDeclaration) element, flags); + break; + case ICElement.C_ENUMERATOR: + appendEnumeratorLabel((IEnumerator) element, flags); + break; + case ICElement.C_CLASS: + case ICElement.C_STRUCT: + case ICElement.C_UNION: + case ICElement.C_ENUMERATION: + case ICElement.C_TEMPLATE_CLASS: + case ICElement.C_TEMPLATE_STRUCT: + case ICElement.C_TEMPLATE_UNION: + case ICElement.C_TEMPLATE_CLASS_DECLARATION: + case ICElement.C_TEMPLATE_STRUCT_DECLARATION: + case ICElement.C_TEMPLATE_UNION_DECLARATION: + case ICElement.C_NAMESPACE: + appendTypeLabel( element, flags); + break; + case ICElement.C_TYPEDEF: + appendTypeDefLabel((ITypeDef)element, flags); + break; + case ICElement.C_UNIT: + appendTranslationUnitLabel((ITranslationUnit) element, flags); + break; + case ICElement.C_CCONTAINER: + ICContainer container = (ICContainer) element; + if (container instanceof ISourceRoot) + getSourceRootLabel((ISourceRoot) container, flags); + else + appendContainerLabel(container, flags); + break; + case ICElement.C_PROJECT: + case ICElement.C_MODEL: + fBuffer.append(element.getElementName()); + break; + default: + fBuffer.append(element.getElementName()); + } + + if (root != null && getFlag(flags, CElementLabels.APPEND_ROOT_PATH)) { + int offset= fBuffer.length(); + fBuffer.append(CElementLabels.CONCAT_STRING); + getSourceRootLabel(root, CElementLabels.ROOT_QUALIFIED); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + + if (element instanceof IBinary) { + IBinary bin = (IBinary)element; + fBuffer.append(" - [" + bin.getCPU() + "/" + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + } + } + + + /** + * Appends the label for a macro definition to a StringBuffer. + * @param macro a macro definition + * @param flags {@link CElementLabels#MF_POST_FILE_QUALIFIED}, or 0. + */ + public void appendMacroLabel(IMacro macro, long flags) { + fBuffer.append(macro.getElementName()); + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + IPath path= macro.getPath(); + if (path != null) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } + } + + /** + * Appends the label for a method declaration to a StringBuffer. + * @param method a method declaration + * @param flags any of the M_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} + */ + public void appendMethodLabel( IMethodDeclaration method, long flags ) { + try { + //return type + if( getFlag( flags, CElementLabels.M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) { + fBuffer.append( method.getReturnType() ); + fBuffer.append( ' ' ); + } + + //qualification + if( getFlag( flags, CElementLabels.M_FULLY_QUALIFIED ) ){ + ICElement parent = method.getParent(); + if (parent != null && parent.exists() && !(parent instanceof ITranslationUnit)) { + appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS)); + fBuffer.append( "::" ); //$NON-NLS-1$ + } + } + + if (getFlag(flags, CElementLabels.M_SIMPLE_NAME)) { + fBuffer.append(getSimpleName(method.getElementName())); + } else { + fBuffer.append(method.getElementName()); + } + + //template parameters + if (method instanceof ITemplate) { + appendTemplateParameters((ITemplate)method, flags); + } + + //parameters + if( getFlag( flags, CElementLabels.M_PARAMETER_TYPES ) ) { + fBuffer.append('('); + + String[] types = method.getParameterTypes(); + + if (types != null) { + for (int i= 0; i < types.length; i++) { + if (i > 0) { + fBuffer.append( CElementLabels.COMMA_STRING ); + } + fBuffer.append( types[i] ); + } + } + fBuffer.append(')'); + } + + //exceptions + if( getFlag( flags, CElementLabels.M_EXCEPTIONS ) && method.exists() ){ + String [] types = method.getExceptions(); + if (types.length > 0) { + fBuffer.append(" throw( "); //$NON-NLS-1$ + for (int i= 0; i < types.length; i++) { + if (i > 0) { + fBuffer.append(CElementLabels.COMMA_STRING); + } + fBuffer.append( types[i] ); + } + fBuffer.append( " )" ); //$NON-NLS-1$ + } + } + + if( getFlag( flags, CElementLabels.M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor() && !method.isDestructor()) { + final String typeName= method.getReturnType(); + if (typeName != null && typeName.length() > 0) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.DECL_STRING ); + fBuffer.append(typeName); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE); + } + } + } + + // post qualification + if( getFlag(flags, CElementLabels.M_POST_QUALIFIED)) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + appendTypeLabel( method.getParent(), CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS)); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + + IPath path= method.getPath(); + if (path != null) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + + } + } catch (CModelException e) { + CUIPlugin.log(e); + } + } + + /** + * Strip any qualifier from the given name. + * + * @param elementName + * @return a "simple" name + */ + private static String getSimpleName(String elementName) { + int idx = elementName.lastIndexOf("::"); //$NON-NLS-1$ + if (idx >= 0) { + return elementName.substring(idx+2); + } + return elementName; + } + + private void appendTemplateParameters(ITemplate template, long flags) { + String[] args= null; + if (getFlag(flags, CElementLabels.TEMPLATE_ARGUMENTS)) { + args = template.getTemplateArguments(); + } else if (getFlag(flags, CElementLabels.TEMPLATE_PARAMETERS)) { + args= template.getTemplateParameterTypes(); + } else { + return; + } + + fBuffer.append('<'); + if (args != null) { + for (int i= 0; i < args.length; i++) { + if (i > 0) { + fBuffer.append( ',' ); + } + fBuffer.append( args[i] ); + } + } + fBuffer.append('>'); + } + + /** + * Appends the label for a field to a StringBuffer. + * @param field a field + * @param flags any of the F_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} + */ + public void appendFieldLabel(IField field, long flags ) { + try { + //return type + if( getFlag( flags, CElementLabels.F_PRE_TYPE_SIGNATURE ) && field.exists()) { + fBuffer.append( field.getTypeName() ); + fBuffer.append( ' ' ); + } + + //qualification + if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){ + ICElement parent = field.getParent(); + if (parent != null && parent.exists()) { + appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS)); + fBuffer.append( "::" ); //$NON-NLS-1$ + } + } + + if (getFlag(flags, CElementLabels.F_SIMPLE_NAME)) { + fBuffer.append(getSimpleName(field.getElementName())); + } else { + fBuffer.append(field.getElementName()); + } + + if( getFlag( flags, CElementLabels.F_APP_TYPE_SIGNATURE ) && field.exists()) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.DECL_STRING ); + fBuffer.append( field.getTypeName() ); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE); + } + } + + // post qualification + if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + appendTypeLabel( field.getParent(), CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS)); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + IPath path= field.getPath(); + if (path != null) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + + } + } catch (CModelException e) { + CUIPlugin.log(e); + } + } + + /** + * Appends the label for a variable declaration to a StringBuffer. + * @param var a variable declaration + * @param flags any of the F_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} + */ + public void appendVariableLabel(IVariableDeclaration var, long flags ) { + try { + //return type + if( getFlag( flags, CElementLabels.F_PRE_TYPE_SIGNATURE ) && var.exists()) { + fBuffer.append( var.getTypeName() ); + fBuffer.append( ' ' ); + } + + //qualification + if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){ + ICElement parent = var.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED); + fBuffer.append( "::" ); //$NON-NLS-1$ + } + } + + fBuffer.append( var.getElementName() ); + + if( getFlag( flags, CElementLabels.F_APP_TYPE_SIGNATURE ) && var.exists()) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.DECL_STRING ); + fBuffer.append( var.getTypeName() ); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE); + } + } + + // post qualification + if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) { + ICElement parent = var.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + appendTypeLabel( var.getParent(), CElementLabels.T_FULLY_QUALIFIED); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE); + } + } + } + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + int offset= fBuffer.length(); + IPath path= var.getPath(); + if (path != null) { + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + } + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } catch (CModelException e) { + CUIPlugin.log(e); + } + } + + /** + * Appends the label for an enumerator to a StringBuffer. + * @param var an enumerator + * @param flags any of the F_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} + */ + public void appendEnumeratorLabel(IEnumerator var, long flags ) { + //qualification + if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){ + ICElement parent = var.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED); + fBuffer.append( "::" ); //$NON-NLS-1$ + } + } + + fBuffer.append( var.getElementName() ); + + // post qualification + if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) { + ICElement parent = var.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + fBuffer.append( CElementLabels.CONCAT_STRING ); + appendTypeLabel( var.getParent(), CElementLabels.T_FULLY_QUALIFIED); + } + } + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + int offset= fBuffer.length(); + IPath path= var.getPath(); + if (path != null) { + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + } + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } + + /** + * Appends the label for a function declaration to a StringBuffer. + * @param func a function declaration + * @param flags any of the M_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} + */ + public void appendFunctionLabel(IFunctionDeclaration func, long flags) { + //return type + if( getFlag( flags, CElementLabels.M_PRE_RETURNTYPE ) && func.exists()) { + fBuffer.append( func.getReturnType() ); + fBuffer.append( ' ' ); + } + + //qualification + if( getFlag( flags, CElementLabels.M_FULLY_QUALIFIED ) ){ + ICElement parent = func.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED); + fBuffer.append( "::" ); //$NON-NLS-1$ + } + } + + fBuffer.append( func.getElementName() ); + + //template parameters + if (func instanceof ITemplate) { + appendTemplateParameters((ITemplate)func, flags); + } + + //parameters + if( getFlag( flags, CElementLabels.M_PARAMETER_TYPES ) ) { + fBuffer.append('('); + + String[] types = func.getParameterTypes(); + + if (types != null) { + for (int i= 0; i < types.length; i++) { + if (i > 0) { + fBuffer.append( CElementLabels.COMMA_STRING ); + } + fBuffer.append( types[i] ); + } + } + fBuffer.append(')'); + } + + //exceptions + if( getFlag( flags, CElementLabels.M_EXCEPTIONS ) && func.exists() ){ + String [] types = func.getExceptions(); + if (types.length > 0) { + fBuffer.append(" throw( "); //$NON-NLS-1$ + for (int i= 0; i < types.length; i++) { + if (i > 0) { + fBuffer.append(CElementLabels.COMMA_STRING); + } + fBuffer.append( types[i] ); + } + fBuffer.append( " )" ); //$NON-NLS-1$ + } + } + + if( getFlag( flags, CElementLabels.M_APP_RETURNTYPE ) && func.exists()) { + final String typeName= func.getReturnType(); + if (typeName != null && typeName.length() > 0) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.DECL_STRING ); + fBuffer.append(typeName); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE); + } + } + } + + // post qualification + if( getFlag(flags, CElementLabels.M_POST_QUALIFIED)) { + ICElement parent = func.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + fBuffer.append( CElementLabels.CONCAT_STRING ); + appendTypeLabel( func.getParent(), CElementLabels.T_FULLY_QUALIFIED); + } + } + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + IPath path= func.getPath(); + if (path != null) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } + } + + /** + * Appends the label for a type definition to a StringBuffer. + * @param typedef a type definition + * @param flags any of the F_* flags, and CElementLabels.MF_POST_FILE_QUALIFIED + */ + public void appendTypeDefLabel(ITypeDef typedef, long flags ) { + // type + if( getFlag( flags, CElementLabels.F_PRE_TYPE_SIGNATURE ) && typedef.exists()) { + fBuffer.append( typedef.getTypeName() ); + fBuffer.append( ' ' ); + } + + //qualification + if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){ + ICElement parent = typedef.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED); + fBuffer.append( "::" ); //$NON-NLS-1$ + } + } + + fBuffer.append( typedef.getElementName() ); + + if( getFlag( flags, CElementLabels.F_APP_TYPE_SIGNATURE ) && typedef.exists()) { + String typeName= typedef.getTypeName(); + if (typeName != null && typeName.length() > 0) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.DECL_STRING ); + fBuffer.append(typeName); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE); + } + } + } + + // post qualification + if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) { + ICElement parent = typedef.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + fBuffer.append( CElementLabels.CONCAT_STRING ); + appendTypeLabel( typedef.getParent(), CElementLabels.T_FULLY_QUALIFIED); + } + } + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + IPath path= typedef.getPath(); + if (path != null) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } + } + + /** + * Appends the label for a source root to a StringBuffer. + * @param root a source root + * @param flags any of the ROOT_* flags, and PROJECT_POST_QUALIFIED + */ + public void getSourceRootLabel(ISourceRoot root, long flags) { + appendFolderLabel(root, flags); + } + + /** + * Appends the label for a container to a StringBuffer. + * @param container a container + * @param flags any of the ROOT_* flags, and PROJECT_POST_QUALIFIED + */ + public void appendContainerLabel(ICContainer container, long flags) { + appendFolderLabel(container, flags); + } + + private void appendFolderLabel(ICContainer container, long flags) { + IResource resource= container.getResource(); + boolean rootQualified= getFlag(flags, CElementLabels.ROOT_QUALIFIED); + if (rootQualified) { + fBuffer.append(container.getPath().makeRelative().toString()); + } else { + if (CCorePlugin.showSourceRootsAtTopOfProject()) { + fBuffer.append(container.getElementName()); + } + else { + String elementName = container.getElementName(); + IPath path = new Path(elementName); + fBuffer.append(path.lastSegment()); + } + if (getFlag(flags, CElementLabels.ROOT_QUALIFIED)) { + if (resource != null && container instanceof ISourceRoot && isReferenced((ISourceRoot)container)) { + fBuffer.append(CElementLabels.CONCAT_STRING); + fBuffer.append(resource.getProject().getName()); + } else { + fBuffer.append(CElementLabels.CONCAT_STRING); + fBuffer.append(container.getParent().getElementName()); + } + } + } + } + + /** + * Appends the label for a translation unit to a StringBuffer. + * @param tu a translation unit + * @param flags any of the TU_* flags + */ + public void appendTranslationUnitLabel(ITranslationUnit tu, long flags) { + IResource r= tu.getResource(); + IPath path; + if (r != null) { + path= r.getFullPath().makeRelative(); + } + else { + path= tu.getPath(); + } + + if (path == null) { + fBuffer.append(tu.getElementName()); + } + else { + if (getFlag(flags, CElementLabels.TU_QUALIFIED)) { + fBuffer.append(path.toString()); + } + else if (getFlag(flags, CElementLabels.TU_POST_QUALIFIED)) { + fBuffer.append(path.lastSegment()); + fBuffer.append(CElementLabels.CONCAT_STRING); + fBuffer.append(path.removeLastSegments(1).toString()); + } + else { + fBuffer.append(path.lastSegment()); + } + } + } + + /** + * Appends the label for a type to a StringBuffer. + * @param elem a type + * @param flags any of the T_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED} + */ + private void appendTypeLabel(ICElement elem, long flags) { + if (getFlag(flags, CElementLabels.T_FULLY_QUALIFIED)) { + ICElement parent= elem.getParent(); + boolean isQualifier= true; + if (parent != null && parent.exists()) { + switch (parent.getElementType()) { + case ICElement.C_ARCHIVE: + case ICElement.C_BINARY: + case ICElement.C_CCONTAINER: + case ICElement.C_MODEL: + case ICElement.C_PROJECT: + case ICElement.C_UNIT: + case ICElement.C_VCONTAINER: + isQualifier= false; + break; + } + } + // types cannot be qualified in plain c + if (isQualifier && !isCLanguage(parent)) { + long qflags= flags & ~CElementLabels.MF_POST_FILE_QUALIFIED; + appendTypeLabel(parent, qflags); + fBuffer.append("::"); //$NON-NLS-1$ + } + } + + String typeName= elem.getElementName(); + if (typeName.length() == 0) { // anonymous + typeName = CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$ + } + fBuffer.append(typeName); + + if (getFlag(flags, CElementLabels.T_INHERITANCE) && elem instanceof IInheritance) { + IInheritance inheritance= (IInheritance)elem; + String[] superclassNames= inheritance.getSuperClassesNames(); + if (superclassNames != null && superclassNames.length > 0) { + fBuffer.append(CElementLabels.DECL_STRING); + for (int i = 0; i < superclassNames.length; i++) { + if (i> 0) { + fBuffer.append(CElementLabels.COMMA_STRING); + } + String superclass = superclassNames[i]; + String visibility = getVisibility(inheritance.getSuperClassAccess(superclass)); + fBuffer.append(visibility).append(' ').append(superclass); + } + } + } + + //template parameters + if (elem instanceof ITemplate) { + appendTemplateParameters((ITemplate)elem, flags); + } + + if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) { + IPath path= elem.getPath(); + if (path != null) { + int offset= fBuffer.length(); + fBuffer.append( CElementLabels.CONCAT_STRING ); + fBuffer.append(path.toString()); + if (getFlag(flags, CElementLabels.COLORIZE)) { + fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); + } + } + } + } + + private static boolean isCLanguage(ICElement elem) { + while (elem != null) { + elem= elem.getParent(); + if (elem instanceof ITranslationUnit) { + return ((ITranslationUnit) elem).isCLanguage(); + } + } + return false; + } + + /** + * Convert an <code>ASTAccessVisibility</code> into its string representation. + * + * @param access + * @return "public", "protected" or "private" + */ + private static String getVisibility(ASTAccessVisibility access) { + if (access == ASTAccessVisibility.PUBLIC) { + return "public"; //$NON-NLS-1$ + } + if (access == ASTAccessVisibility.PROTECTED) { + return "protected"; //$NON-NLS-1$ + } + return "private"; //$NON-NLS-1$ + } + + private static boolean getFlag(long flags, long flag) { + return (flags & flag) != 0; + } + + + /** + * Returns the source root of <code>ICElement</code>. If the given + * element is already a source root, the element itself is returned. + */ + public static ISourceRoot getSourceRoot(ICElement element) { + ICElement root = element; + while (root != null) { + if (root instanceof ISourceRoot) + return (ISourceRoot)root; + ICElement parent = root.getAncestor(ICElement.C_CCONTAINER); + if (parent == root) + return null; + root = parent; + } + return null; + } + + /** + * Returns <code>true</code> if the given source root is + * referenced. This means it is own by a different project but is referenced + * by the root's parent. Returns <code>false</code> if the given root + * doesn't have an underlying resource. + */ + public static boolean isReferenced(ISourceRoot root) { + IResource resource= root.getResource(); + if (resource != null) { + IProject project= resource.getProject(); + IProject container= root.getCProject().getProject(); + return !container.equals(project); + } + return false; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java index 52abdcaa81c..13655c3d081 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,32 +8,508 @@ * Contributors: * IBM Corp. - Rational Software - initial implementation * Markus Schorn (Wind River Systems) + * Patrick Hofer [bug 325799] *******************************************************************************/ -/* - * Created on Jun 24, 2003 - */ package org.eclipse.cdt.internal.ui.viewsupport; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.osgi.util.TextProcessor; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.core.model.IEnumerator; +import org.eclipse.cdt.core.model.IField; +import org.eclipse.cdt.core.model.IFunctionDeclaration; +import org.eclipse.cdt.core.model.IMacro; +import org.eclipse.cdt.core.model.IMethodDeclaration; +import org.eclipse.cdt.core.model.ITypeDef; +import org.eclipse.cdt.core.model.IVariableDeclaration; + +import org.eclipse.cdt.internal.core.model.CElement; +import org.eclipse.cdt.internal.core.model.CoreModelMessages; +import org.eclipse.cdt.internal.corext.util.Strings; + +/* + * This class is basically a clone of org.eclipse.cdt.core.model.util.CElementLabels + * (refer to bug 325799 for the reasoning) + */ /** - * @author aniefer + * Computes labels for objects of type {@link CElement}. */ -public class CElementLabels extends CElementBaseLabels { +public class CElementLabels { + /** + * Method names contain parameter types. + * e.g. <code>foo(int)</code> + */ + public final static long M_PARAMETER_TYPES= 1L << 0; + + /** + * Method definition names without qualifier. + * e.g. <code>foo(int)</code> + */ + public final static long M_SIMPLE_NAME= 1L << 1; + + /** + * Method names contain thrown exceptions. + * e.g. <code>foo throw( IOException )</code> + */ + public final static long M_EXCEPTIONS= 1L << 2; + + /** + * Method names contain return type (appended) + * e.g. <code>foo : int</code> + */ + public final static long M_APP_RETURNTYPE= 1L << 3; + + /** + * Method names contain return type (appended) + * e.g. <code>int foo</code> + */ + public final static long M_PRE_RETURNTYPE= 1L << 4; + + /** + * Method names are fully qualified. + * e.g. <code>ClassName::size</code> + */ + public final static long M_FULLY_QUALIFIED= 1L << 5; + + /** + * Method names are post qualified. + * e.g. <code>size - ClassName</code> + */ + public final static long M_POST_QUALIFIED= 1L << 6; + + /** + * Templates are qualified with template parameters. + * e.g. <code>ClassName<T></code> + */ + public final static long TEMPLATE_PARAMETERS= 1L << 7; + + /** + * Static field names without qualifier. + * e.g. <code>fHello</code> + */ + public final static long F_SIMPLE_NAME= 1L << 8; + + /** + * Field names contain the declared type (appended) + * e.g. <code>fHello: int</code> + */ + public final static long F_APP_TYPE_SIGNATURE= 1L << 9; + + /** + * Field names contain the declared type (prepended) + * e.g. <code>int fHello</code> + */ + public final static long F_PRE_TYPE_SIGNATURE= 1L << 10; + + /** + * Fields names are fully qualified. + * e.g. <code>ClassName::fField</code> + */ + public final static long F_FULLY_QUALIFIED= 1L << 11; + + /** + * Fields names are post qualified. + * e.g. <code>fField - ClassName</code> + */ + public final static long F_POST_QUALIFIED= 1L << 12; + + /** + * Type names are fully qualified. + * e.g. <code>namespace::ClassName</code> + */ + public final static long T_FULLY_QUALIFIED= 1L << 13; + + /** + * Instances and specializations are qualified with arguments, templates with template parameter names. + * The flag overrides {@link #TEMPLATE_PARAMETERS}. + */ + public final static long TEMPLATE_ARGUMENTS= 1L << 14; + + /** + * Append base class specifications to type names. + * e.g. <code>MyClass : public BaseClass</code> + */ + public final static long T_INHERITANCE= 1L << 16; + + /** + * Translation unit names contain the full path. + * e.g. <code>/MyProject/src/ClassName.cpp</code> + */ + public final static long TU_QUALIFIED= 1L << 20; + + /** + * Translation unit names are post qualified with their path. + * e.g. <code>ClassName.cpp - /MyProject/src</code> + */ + public final static long TU_POST_QUALIFIED= 1L << 21; - public static String getTextLabel(Object obj, int flags) { + /** + * Source roots contain the project name (prepended). + * e.g. <code>MyProject/src</code> + */ + public final static long ROOT_QUALIFIED= 1L << 25; + + /** + * Source roots contain the project name (appended). + * e.g. <code>src - MyProject</code> + */ + public final static long ROOT_POST_QUALIFIED= 1L << 26; + + /** + * Add source root path. + * e.g. <code>func() - MyProject/src</code> + * Option only applies to getElementLabel + */ + public final static long APPEND_ROOT_PATH= 1L << 27; + + /** + * Prepend source root path. + * e.g. <code>MyProject/src - func()</code> + * Option only applies to getElementLabel + */ + public final static long PREPEND_ROOT_PATH= 1L << 28; + + /** + * Post qualify container project. For example + * <code>folder - MyProject</code> if the folder is in project MyProject. + */ + public final static long PROJECT_POST_QUALIFIED= 1L << 30; + + /** + * Post qualify symbols with file. + * e.g. <code>func() - /proj/folder/file.cpp</code> + */ + public final static long MF_POST_FILE_QUALIFIED= 1L << 31; + + /** + * Specifies to apply color styles to labels. This flag only applies to methods taking or returning a {@link StyledString}. + */ + public final static long COLORIZE= 1L << 32; + + /** + * Qualify all elements + */ + public final static long ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED | ROOT_QUALIFIED; + + /** + * Post qualify all elements + */ + public final static long ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED | ROOT_POST_QUALIFIED; + + /** + * Default options (M_PARAMETER_TYPES enabled) + */ + public final static long ALL_DEFAULT= M_PARAMETER_TYPES; + + /** + * Default qualify options (All except Root) + */ + public final static long DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED; + + /** + * Default post qualify options (All except Root) + */ + public final static long DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED; + + /** + * Separator for appending qualifiers + */ + public final static String CONCAT_STRING= CoreModelMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$ + + /** + * Separator for parameters, base classes, exceptions, etc. + */ + public final static String COMMA_STRING = CoreModelMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$ + + /** + * Separator for appending (return) type + */ + public final static String DECL_STRING = CoreModelMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$ + + + + //==================== + + + private CElementLabels() { + } + + /** + * Returns the label of the given object. The object must be of type {@link ICElement} or adapt to {@link IWorkbenchAdapter}. + * If the element type is not known, the empty string is returned. + * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. + * + * @param obj object to get the label for + * @param flags the rendering flags + * @return the label or the empty string if the object type is not supported + */ + public static String getTextLabel(Object obj, long flags) { if (obj instanceof ICElement) { return getElementLabel((ICElement) obj, flags); + + } else if (obj instanceof IResource) { + return BasicElementLabels.getResourceName((IResource) obj); + + } else if (obj instanceof IStorage) { + return BasicElementLabels.getResourceName(((IStorage) obj).getName()); + } else if (obj instanceof IAdaptable) { IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class); if (wbadapter != null) { - return wbadapter.getLabel(obj); + return Strings.markLTR(wbadapter.getLabel(obj)); } } return ""; //$NON-NLS-1$ } + + /** + * Returns the styled label of the given object. The object must be of type {@link ICElement} or adapt to {@link IWorkbenchAdapter}. + * If the element type is not known, the empty string is returned. + * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. + * + * @param obj object to get the label for + * @param flags the rendering flags + * @return the label or the empty string if the object type is not supported + */ + public static StyledString getStyledTextLabel(Object obj, long flags) { + if (obj instanceof ICElement) { + return getStyledElementLabel((ICElement) obj, flags); + + } else if (obj instanceof IResource) { + return getStyledResourceLabel((IResource) obj); + + } else if (obj instanceof IStorage) { + return getStyledStorageLabel((IStorage) obj); + + } else if (obj instanceof IAdaptable) { + IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class); + if (wbadapter != null) { + return Strings.markLTR(new StyledString(wbadapter.getLabel(obj))); + } + } + return new StyledString(); + } + + /** + * Returns the styled string for the given resource. + * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. + * + * @param resource the resource + * @return the styled string + */ + private static StyledString getStyledResourceLabel(IResource resource) { + StyledString result= new StyledString(resource.getName()); + return Strings.markLTR(result); + } + + /** + * Returns the styled string for the given storage. + * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. + * + * @param storage the storage + * @return the styled string + */ + private static StyledString getStyledStorageLabel(IStorage storage) { + StyledString result= new StyledString(storage.getName()); + return Strings.markLTR(result); + } + + + /** + * Returns the label for a Java element with the flags as defined by this class. + * + * @param element the element to render + * @param flags the rendering flags + * @return the label of the Java element + */ + public static String getElementLabel(ICElement element, long flags) { + StringBuffer result= new StringBuffer(); + getElementLabel(element, flags, result); + return Strings.markCElementLabelLTR(result.toString()); + } + + /** + * Returns the styled label for a Java element with the flags as defined by this class. + * + * @param element the element to render + * @param flags the rendering flags + * @return the label of the Java element + * + */ + public static StyledString getStyledElementLabel(ICElement element, long flags) { + StyledString result= new StyledString(); + getElementLabel(element, flags, result); + return Strings.markCElementLabelLTR(result); + } + + /** + * Returns the label for a Java element with the flags as defined by this class. + * + * @param element the element to render + * @param flags the rendering flags + * @param buf the buffer to append the resulting label to + */ + public static void getElementLabel(ICElement element, long flags, StringBuffer buf) { + new CElementLabelComposer(buf).appendElementLabel(element, flags); + } + + /** + * Returns the styled label for a Java element with the flags as defined by this class. + * + * @param element the element to render + * @param flags the rendering flags + * @param result the buffer to append the resulting label to + */ + public static void getElementLabel(ICElement element, long flags, StyledString result) { + new CElementLabelComposer(result).appendElementLabel(element, flags); + } + + /** + * Appends the label for a macro definition to a StringBuffer. + * @param macro a macro definition + * @param flags {@link #MF_POST_FILE_QUALIFIED}, or 0. + * @param buf the buffer to append the label to. + */ + public static void getMacroLabel(IMacro macro, int flags, StringBuffer buf) { + new CElementLabelComposer(buf).appendMacroLabel(macro, flags); + } + + /** + * Appends the label for a macro to a {@link StyledString}. Considers the M_* flags. + * + * @param macro the element to render + * @param flags the rendering flags. Flags with names starting with 'M_' are considered. + * @param result the buffer to append the resulting label to + */ + public static void getMethodLabel(IMacro macro, long flags, StyledString result) { + new CElementLabelComposer(result).appendMacroLabel(macro, flags); + } + + /** + * Appends the label for a method declaration to a StringBuffer. + * @param method a method declaration + * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getMethodLabel( IMethodDeclaration method, int flags, StringBuffer buf ) { + new CElementLabelComposer(buf).appendMethodLabel(method, flags); + } + + /** + * Appends the label for a macro to a {@link StyledString}. Considers the M_* flags. + * + * @param method the element to render + * @param flags the rendering flags. Flags with names starting with 'M_' are considered. + * @param result the buffer to append the resulting label to + */ + public static void getMethodLabel(IMethodDeclaration method, long flags, StyledString result) { + new CElementLabelComposer(result).appendMethodLabel(method, flags); + } + + /** + * Appends the label for a field to a StringBuffer. + * @param field a field + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getFieldLabel(IField field, int flags, StringBuffer buf ) { + new CElementLabelComposer(buf).appendFieldLabel(field, flags); + } + + /** + * Appends the label for a field to a {@link StyledString}. + * @param field a field + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param result the buffer to append the label + */ + public static void getFieldLabel(IField field, int flags, StyledString result ) { + new CElementLabelComposer(result).appendFieldLabel(field, flags); + } + + /** + * Appends the label for a variable declaration to a StringBuffer. + * @param var a variable declaration + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getVariableLabel(IVariableDeclaration var, int flags, StringBuffer buf ) { + new CElementLabelComposer(buf).appendVariableLabel(var, flags); + } + + /** + * Appends the label for a variable declaration to a {@link StyledString}. + * @param var a variable declaration + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param result the buffer to append the label + */ + public static void getVariableLabel(IVariableDeclaration var, int flags, StyledString result ) { + new CElementLabelComposer(result).appendVariableLabel(var, flags); + } + + /** + * Appends the label for an enumerator to a StringBuffer. + * @param var an enumerator + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getEnumeratorLabel(IEnumerator var, int flags, StringBuffer buf ) { + new CElementLabelComposer(buf).appendEnumeratorLabel(var, flags); + } + + /** + * Appends the label for an enumerator to a {@link StyledString}. + * @param var an enumerator + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param result the buffer to append the label + */ + public static void getEnumeratorLabel(IEnumerator var, int flags, StyledString result ) { + new CElementLabelComposer(result).appendEnumeratorLabel(var, flags); + } + + /** + * Appends the label for a function declaration to a StringBuffer. + * @param func a function declaration + * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getFunctionLabel(IFunctionDeclaration func, int flags, StringBuffer buf) { + new CElementLabelComposer(buf).appendFunctionLabel(func, flags); + } + + /** + * Appends the label for a function declaration to a {@link StyledString}. + * @param func a function declaration + * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED + * @param result the buffer to append the label + */ + public static void getFunctionLabel(IFunctionDeclaration func, int flags, StyledString result) { + new CElementLabelComposer(result).appendFunctionLabel(func, flags); + } + + /** + * Appends the label for a type definition to a StringBuffer. + * @param typedef a type definition + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getTypeDefLabel(ITypeDef typedef, int flags, StringBuffer buf ) { + new CElementLabelComposer(buf).appendTypeDefLabel(typedef, flags); + } + + /** + * Appends the label for a type definition to a {@link StyledString}. + * @param typedef a type definition + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param result the buffer to append the label + */ + public static void getTypeDefLabel(ITypeDef typedef, int flags, StyledString result ) { + new CElementLabelComposer(result).appendTypeDefLabel(typedef, flags); + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java index 941638740d3..bb751ac90d3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) + * Patrick Hofer [bug 325799] *******************************************************************************/ package org.eclipse.cdt.internal.ui.viewsupport; @@ -18,16 +19,19 @@ import org.eclipse.jface.viewers.IColorProvider; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.StyledCellLabelProvider; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.cdt.core.model.ISourceReference; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.ui.CUIPlugin; -public class CUILabelProvider extends LabelProvider implements IColorProvider { +public class CUILabelProvider extends LabelProvider implements IColorProvider, IStyledLabelProvider { protected CElementImageProvider fImageLabelProvider; protected StorageLabelProvider fStorageLabelProvider; @@ -35,7 +39,7 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { private ArrayList<ILabelDecorator> fLabelDecorators; private int fImageFlags; - private int fTextFlags; + private long fTextFlags; private Color fInactiveColor; private Color fDefaultColor; @@ -43,17 +47,17 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { * Creates a new label provider with default flags. */ public CUILabelProvider() { - this(CElementBaseLabels.M_PARAMETER_TYPES, CElementImageProvider.OVERLAY_ICONS); + this(CElementLabels.M_PARAMETER_TYPES, CElementImageProvider.OVERLAY_ICONS); } /** - * @param textFlags Flags defined in <code>CElementBaseLabels</code>. + * @param textFlags Flags defined in <code>CElementLabels</code>. * @param imageFlags Flags defined in <code>CElementImageProvider</code>. */ - public CUILabelProvider(int textFlags, int imageFlags) { + public CUILabelProvider(long textFlags, int imageFlags) { fImageLabelProvider= new CElementImageProvider(); - fLabelDecorators= null; - + fLabelDecorators= null; + fStorageLabelProvider= new StorageLabelProvider(); fImageFlags= imageFlags; fTextFlags= textFlags; @@ -61,6 +65,7 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { /** * Adds a decorator to the label provider + * @param decorator the decorator to add */ public void addLabelDecorator(ILabelDecorator decorator) { if (fLabelDecorators == null) { @@ -73,12 +78,12 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { * Sets the textFlags. * @param textFlags The textFlags to set */ - public final void setTextFlags(int textFlags) { + public final void setTextFlags(long textFlags) { fTextFlags= textFlags; } /** - * Sets the imageFlags + * Sets the imageFlags * @param imageFlags The imageFlags to set */ public final void setImageFlags(int imageFlags) { @@ -87,7 +92,7 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { /** * Gets the image flags. - * Can be overwriten by super classes. + * Can be overwritten by super classes. * @return Returns a int */ public final int getImageFlags() { @@ -98,13 +103,14 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { * Gets the text flags. * @return Returns a int */ - public final int getTextFlags() { + public final long getTextFlags() { return fTextFlags; } /** * Evaluates the image flags for a element. - * Can be overwriten by super classes. + * Can be overwritten by super classes. + * @param element the element to compute the image flags for * @return Returns a int */ protected int evaluateImageFlags(Object element) { @@ -112,10 +118,11 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { } /** - * Evaluates the text flags for a element. Can be overwriten by super classes. + * Evaluates the text flags for a element. Can be overwritten by super classes. + * @param element the element to compute the text flags for * @return Returns a int */ - protected int evaluateTextFlags(Object element) { + protected long evaluateTextFlags(Object element) { return getTextFlags(); } @@ -166,6 +173,19 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider { return decorateText(result, element); } + public StyledString getStyledText(Object element) { + StyledString string= CElementLabels.getStyledTextLabel(element, (evaluateTextFlags(element) | CElementLabels.COLORIZE)); + if (string.length() == 0 && (element instanceof IStorage)) { + string= new StyledString(fStorageLabelProvider.getText(element)); + } + String decorated= decorateText(string.getString(), element); + if (decorated != null) { + return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, string); + } + return string; + } + + /* (non-Javadoc) * @see IBaseLabelProvider#dispose */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java index dbf72819054..16842028fc9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,20 +7,20 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Patrick Hofer [bug 325799] *******************************************************************************/ package org.eclipse.cdt.internal.ui.viewsupport; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.swt.graphics.Color; +import org.eclipse.jface.viewers.DecorationContext; import org.eclipse.ui.PlatformUI; -public class DecoratingCLabelProvider extends DecoratingLabelProvider { +public class DecoratingCLabelProvider extends ColoringLabelProvider { /** * Decorating label provider for C/C++. Combines a CUILabelProvider * with problem and override indicator with the workbench decorator (label * decorator extension point). + * @param labelProvider the label provider to decorate */ public DecoratingCLabelProvider(CUILabelProvider labelProvider) { this(labelProvider, true); @@ -30,30 +30,13 @@ public class DecoratingCLabelProvider extends DecoratingLabelProvider { * Decorating label provider for C/C++. Combines a CUILabelProvider * (if enabled with problem indicator) with the workbench * decorator (label decorator extension point). + * @param labelProvider the label provider to decorate + * @param errorTick show error ticks */ public DecoratingCLabelProvider(CUILabelProvider labelProvider, boolean errorTick) { - super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); + super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), DecorationContext.DEFAULT_CONTEXT); if (errorTick) { labelProvider.addLabelDecorator(new ProblemsLabelDecorator(null)); } } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) - */ - @Override - public Color getForeground(Object element) { - // label provider is a JavaUILabelProvider - return ((IColorProvider) getLabelProvider()).getForeground(element); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) - */ - @Override - public Color getBackground(Object element) { - // label provider is a JavaUILabelProvider - return ((IColorProvider) getLabelProvider()).getBackground(element); - } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java index ec0f5811561..7a1060d5ada 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.ui.viewsupport; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.CUIMessages; import org.eclipse.core.resources.IContainer; @@ -30,9 +30,9 @@ import org.eclipse.osgi.util.NLS; */ public class StatusBarUpdater implements ISelectionChangedListener { - private final int LABEL_FLAGS= CElementBaseLabels.DEFAULT_QUALIFIED | CElementBaseLabels.ROOT_POST_QUALIFIED | CElementBaseLabels.APPEND_ROOT_PATH | - CElementBaseLabels.M_PARAMETER_TYPES | CElementBaseLabels.M_APP_RETURNTYPE | CElementBaseLabels.M_EXCEPTIONS | - CElementBaseLabels.F_APP_TYPE_SIGNATURE; + private final long LABEL_FLAGS= CElementLabels.DEFAULT_QUALIFIED | CElementLabels.ROOT_POST_QUALIFIED | CElementLabels.APPEND_ROOT_PATH | + CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.M_EXCEPTIONS | + CElementLabels.F_APP_TYPE_SIGNATURE; private IStatusLineManager fStatusLineManager; @@ -68,13 +68,13 @@ public class StatusBarUpdater implements ISelectionChangedListener { } private String formatCElementMessage(ICElement element) { - return CElementBaseLabels.getElementLabel(element, LABEL_FLAGS); + return CElementLabels.getElementLabel(element, LABEL_FLAGS); } private String formatResourceMessage(IResource element) { IContainer parent= element.getParent(); if (parent != null && parent.getType() != IResource.ROOT) - return element.getName() + CElementBaseLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString(); + return element.getName() + CElementLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString(); return element.getName(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java index b25d6af8340..52ae3e43952 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; @@ -65,8 +65,8 @@ public class CElementLabelProvider extends LabelProvider { public final static int SHOW_QUALIFIED= 0x400; /** - * Flag (bit mask) indicating that Complation Units, Class Files, Types, Declarations and Members - * should be rendered qualified. The qualifcation is appended + * Flag (bit mask) indicating that Compilation Units, Class Files, Types, Declarations and Members + * should be rendered qualified. The qualification is appended * Examples: String - java.lang, size() - java.util.Vector * * @since 2.0 @@ -112,7 +112,7 @@ public class CElementLabelProvider extends LabelProvider { fImageLabelProvider= new CElementImageProvider(); fFlags = flags; - fCElementLabelProvider= new CUILabelProvider(getTextFlags() | CElementBaseLabels.TEMPLATE_PARAMETERS, getImageFlags()); + fCElementLabelProvider= new CUILabelProvider(getTextFlags() | CElementLabels.TEMPLATE_PARAMETERS, getImageFlags()); } @Override @@ -152,7 +152,7 @@ public class CElementLabelProvider extends LabelProvider { /** * Gets the image flags. - * Can be overwriten by super classes. + * Can be overwritten by super classes. * @return Returns a int */ public int getImageFlags() { @@ -167,22 +167,22 @@ public class CElementLabelProvider extends LabelProvider { } /** - * Gets the text flags. Can be overwriten by super classes. + * Gets the text flags. Can be overwritten by super classes. * @return Returns a int */ public int getTextFlags() { fTextFlags = 0; if (getFlag(SHOW_RETURN_TYPE)) { - fTextFlags |= CElementBaseLabels.M_APP_RETURNTYPE; + fTextFlags |= CElementLabels.M_APP_RETURNTYPE; } if (getFlag(SHOW_PARAMETERS)) { - fTextFlags |= CElementBaseLabels.M_PARAMETER_TYPES; + fTextFlags |= CElementLabels.M_PARAMETER_TYPES; } if (getFlag(SHOW_EXCEPTION)) { - fTextFlags |= CElementBaseLabels.M_EXCEPTIONS; + fTextFlags |= CElementLabels.M_EXCEPTIONS; } if (getFlag(SHOW_POST_QUALIFIED)) { - fTextFlags |= CElementBaseLabels.M_POST_QUALIFIED; + fTextFlags |= CElementLabels.M_POST_QUALIFIED; } return fTextFlags; } |