1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-05-17 18:06:47 -07:00
parent 7e77be0d90
commit 6052044cdc
6 changed files with 150 additions and 180 deletions

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -26,10 +26,10 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplate {
public static final ICPPClassTemplatePartialSpecialization[] EMPTY_PARTIAL_SPECIALIZATION_ARRAY = new ICPPClassTemplatePartialSpecialization[0];
public static final ICPPClassTemplatePartialSpecialization[] EMPTY_PARTIAL_SPECIALIZATION_ARRAY = {};
/**
* get the ICPPTemplateDefinition which this is a specialization of
* Returns the ICPPTemplateDefinition which this is a specialization of
*/
public ICPPClassTemplate getPrimaryClassTemplate();

View file

@ -154,7 +154,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
int prop= getProperty(newPar);
for (int j = 0; j < props.length; j++) {
if (props[j] == prop) {
// reuse param
// Reuse param
result[i]= j;
props[j]= -1;
allParams[j].update(linkage, newPar);
@ -226,7 +226,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
return partials.toArray(new ICPPClassTemplatePartialSpecialization[partials.size()]);
} catch (CoreException e) {
CCorePlugin.log(e);
return new ICPPClassTemplatePartialSpecialization[0];
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
}
@ -243,11 +243,11 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
}
}
// need a class template
// Need a class template.
if (type instanceof ICPPClassTemplate == false || type instanceof ProblemBinding)
return false;
// exclude other kinds of class templates
// Exclude other kinds of class templates.
if (type instanceof ICPPClassTemplatePartialSpecialization ||
type instanceof ICPPTemplateTemplateParameter ||
type instanceof ICPPClassSpecialization) {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
@ -18,9 +18,8 @@ import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.cdt.internal.ui.editor.CEditor;
public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public CppTypeHierarchyTest(String name) {
super(name);
}
@ -56,68 +55,65 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("Simple1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
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());
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("Simple2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("Simple3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("Simple4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "Simple4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4 : int", "method4() : int"});
}
@ -149,68 +145,65 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("field1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
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());
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("method2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "Simple4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4 : int", "method4() : int"});
}
@ -239,11 +232,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multi.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("Multi1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -251,17 +244,16 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Multi1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("Multi2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -272,22 +264,21 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item3= checkTreeNode(item2, 0, "Multi3");
assertEquals(1, item2.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("Multi3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
item2= checkTreeNode(tree, 1, "Multi2");
item2= checkTreeNode(tree, 1, "Multi2");
assertEquals(2, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
@ -302,15 +293,14 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("Multi4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
item2= checkTreeNode(tree, 1, "Multi2");
item2= checkTreeNode(tree, 1, "Multi2");
assertEquals(2, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
@ -350,11 +340,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multimem.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("field1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -362,17 +352,16 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Multi1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("method2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -383,22 +372,21 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item3= checkTreeNode(item2, 0, "Multi3");
assertEquals(1, item2.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
item2= checkTreeNode(tree, 1, "Multi2");
item2= checkTreeNode(tree, 1, "Multi2");
assertEquals(2, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
@ -413,15 +401,14 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
item2= checkTreeNode(tree, 1, "Multi2");
item2= checkTreeNode(tree, 1, "Multi2");
assertEquals(2, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
@ -461,11 +448,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamond.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("Diamond1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -473,11 +460,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
item3= checkTreeNode(item1, 1, "Diamond3");
assertEquals(2, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
@ -488,7 +475,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("Diamond2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -496,17 +482,16 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("Diamond3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -514,17 +499,16 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Diamond3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Diamond4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("Diamond4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -532,11 +516,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
item3= checkTreeNode(item1, 1, "Diamond3");
assertEquals(2, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
@ -546,8 +530,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4 : int", "method4() : int"});
}
}
// class Diamond1 {
// public:
// int field1;
@ -572,11 +556,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamondmem.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("field1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -584,11 +568,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
item3= checkTreeNode(item1, 1, "Diamond3");
assertEquals(2, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
@ -599,7 +583,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("method2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -607,17 +590,16 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -625,17 +607,16 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Diamond3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Diamond4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
@ -643,11 +624,11 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
item3= checkTreeNode(item1, 1, "Diamond3");
assertEquals(2, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
@ -657,7 +638,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4 : int", "method4() : int"});
}
}
// class ViaTypedef1 {
// public:
@ -680,72 +661,69 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("ViaTypedef1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
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());
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {});
editor.selectAndReveal(content.indexOf("ViaTypedef3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("ViaTypedef4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "ViaTypedef4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4 : int", "method4() : int"});
}
@ -771,72 +749,69 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("field1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
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());
checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {});
editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "ViaTypedef4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4 : int", "method4() : int"});
}
@ -850,15 +825,15 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("SimpleTemplate"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "SimpleTemplate");
assertEquals(1, tree.getItemCount());
assertEquals(0, item1.getItemCount());

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
@ -43,8 +43,6 @@ import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
import org.eclipse.cdt.internal.ui.typehierarchy.TypeHierarchyUI;
public class TypeHierarchyBaseTest extends BaseUITestCase {
protected static final int INDEXER_WAIT_TIME = 8000;
protected ICProject fCProject;
protected IIndex fIndex;
@ -110,7 +108,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
runEventQueue(0);
THViewPart th= null;
for (int i=0; i<50; i++) {
for (int i= 0; i < 50; i++) {
th= (THViewPart)page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
if (th != null)
break;
@ -123,7 +121,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
protected Tree getQuickTypeHierarchyViewer(CEditor editor) {
runEventQueue(0);
THViewPart th= null;
for (int i=0; i<50; i++) {
for (int i= 0; i < 50; i++) {
Control focus= editor.getSite().getShell().getDisplay().getFocusControl();
if (focus instanceof Text) {
Composite parent= focus.getParent();
@ -143,7 +141,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
runEventQueue(0);
THViewPart th= null;
for (int i=0; i<50; i++) {
for (int i= 0; i < 50; i++) {
th= (THViewPart)page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
if (th != null)
break;
@ -156,16 +154,15 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
protected TreeItem checkTreeNode(TreeItem root, int i1, String label) {
TreeItem item= null;
try {
for (int i=0; i<200; i++) {
for (int i= 0; i < 200; i++) {
item= root.getItem(i1);
try {
if ("".equals(item.getText())) {
if (item.getText().isEmpty()) {
TreeItem parent= item.getParentItem();
if (!parent.getExpanded()) {
expandTreeItem(parent);
}
}
else if (!"...".equals(item.getText())) {
} else if (!"...".equals(item.getText())) {
break;
}
} catch (SWTException e) {

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;

View file

@ -8,7 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Ed Swartz (Nokia)
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
import java.util.ArrayList;
@ -93,7 +93,7 @@ import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
public class IndexUI {
private static final ICElementHandle[] EMPTY_ELEMENTS = new ICElementHandle[0];
private static final ICElementHandle[] EMPTY_ELEMENT_ARRAY = {};
public static IIndexBinding elementToBinding(IIndex index, ICElement element) throws CoreException {
return elementToBinding(index, element, -1);
@ -110,7 +110,7 @@ public class IndexUI {
}
} else {
String name= element.getElementName();
name= name.substring(name.lastIndexOf(':')+1);
name= name.substring(name.lastIndexOf(':') + 1);
IIndexBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.ALL, new NullProgressMonitor());
for (IIndexBinding binding : bindings) {
if (checkBinding(binding, element)) {
@ -130,24 +130,24 @@ public class IndexUI {
return binding instanceof ICPPNamespace;
case ICElement.C_STRUCT_DECLARATION:
case ICElement.C_STRUCT:
return binding instanceof ICompositeType &&
return binding instanceof ICompositeType &&
((ICompositeType) binding).getKey() == ICompositeType.k_struct;
case ICElement.C_CLASS:
case ICElement.C_CLASS_DECLARATION:
return binding instanceof ICPPClassType &&
return binding instanceof ICPPClassType &&
((ICompositeType) binding).getKey() == ICPPClassType.k_class;
case ICElement.C_UNION:
case ICElement.C_UNION_DECLARATION:
return binding instanceof ICompositeType &&
return binding instanceof ICompositeType &&
((ICompositeType) binding).getKey() == ICompositeType.k_union;
case ICElement.C_TYPEDEF:
return binding instanceof ITypedef;
case ICElement.C_METHOD:
case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION:
return binding instanceof ICPPMethod;
case ICElement.C_FIELD:
return binding instanceof IField;
case ICElement.C_FUNCTION:
case ICElement.C_FUNCTION:
case ICElement.C_FUNCTION_DECLARATION:
return binding instanceof ICPPFunction && !(binding instanceof ICPPMethod);
case ICElement.C_VARIABLE:
@ -177,7 +177,7 @@ public class IndexUI {
public static IIndexName elementToName(IIndex index, ICElement element) throws CoreException {
return elementToName(index, element, -1);
}
public static IIndexName elementToName(IIndex index, ICElement element, int linkageID) throws CoreException {
if (element instanceof ISourceReference) {
ISourceReference sf = ((ISourceReference)element);
@ -221,7 +221,7 @@ public class IndexUI {
}
return false;
}
private static IRegion getConvertedRegion(ITranslationUnit tu, IIndexFile file, int pos,
int length) throws CoreException {
IRegion region= new Region(pos, length);
@ -232,7 +232,7 @@ public class IndexUI {
}
return region;
}
public static IIndexInclude elementToInclude(IIndex index, IInclude include) throws CoreException {
if (include != null) {
ITranslationUnit tu= include.getTranslationUnit();
@ -267,11 +267,10 @@ public class IndexUI {
return null;
}
public static ICElementHandle[] findRepresentative(IIndex index, IBinding binding) throws CoreException {
ICElementHandle[] defs = IndexUI.findAllDefinitions(index, binding);
ICElementHandle[] defs = findAllDefinitions(index, binding);
if (defs.length == 0) {
ICElementHandle elem = IndexUI.findAnyDeclaration(index, null, binding);
ICElementHandle elem = findAnyDeclaration(index, null, binding);
if (elem != null) {
defs = new ICElementHandle[] { elem };
}
@ -292,7 +291,7 @@ public class IndexUI {
}
return result.toArray(new ICElementHandle[result.size()]);
}
return EMPTY_ELEMENTS;
return EMPTY_ELEMENT_ARRAY;
}
/**
@ -303,7 +302,7 @@ public class IndexUI {
* @param declName
* @return the ICElementHandle or <code>null</code>.
*/
public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IASTName declName)
public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IASTName declName)
throws CoreException {
assert !declName.isReference();
IBinding binding= declName.resolveBinding();
@ -323,7 +322,7 @@ public class IndexUI {
}
return null;
}
public static ITranslationUnit getTranslationUnit(ICProject cproject, IASTName name) {
return getTranslationUnit(cproject, name.getFileLocation());
}
@ -349,7 +348,7 @@ public class IndexUI {
return null;
}
public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IIndexName declName)
public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IIndexName declName)
throws CoreException {
assert !declName.isReference();
ITranslationUnit tu= getTranslationUnit(preferProject, declName);
@ -359,14 +358,14 @@ public class IndexUI {
return null;
}
public static ICElementHandle getCElementForName(ITranslationUnit tu, IIndex index, IIndexName declName)
public static ICElementHandle getCElementForName(ITranslationUnit tu, IIndex index, IIndexName declName)
throws CoreException {
IRegion region= new Region(declName.getNodeOffset(), declName.getNodeLength());
long timestamp= declName.getFile().getTimestamp();
return CElementHandleFactory.create(tu, index.findBinding(declName), declName.isDefinition(), region, timestamp);
}
public static ICElementHandle getCElementForMacro(ICProject preferProject, IIndex index, IIndexMacro macro)
public static ICElementHandle getCElementForMacro(ICProject preferProject, IIndex index, IIndexMacro macro)
throws CoreException {
ITranslationUnit tu= getTranslationUnit(preferProject, macro.getFileLocation());
if (tu != null) {
@ -380,7 +379,7 @@ public class IndexUI {
return null;
}
public static ICElementHandle findAnyDeclaration(IIndex index, ICProject preferProject, IBinding binding)
public static ICElementHandle findAnyDeclaration(IIndex index, ICProject preferProject, IBinding binding)
throws CoreException {
if (binding != null) {
IIndexName[] names= index.findNames(binding, IIndex.FIND_DECLARATIONS);
@ -406,7 +405,7 @@ public class IndexUI {
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
if (workingCopy == null)
return null;
final IASTName[] result= {null};
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
@Override
@ -458,10 +457,10 @@ public class IndexUI {
}
if (tu == null) {
return NLS.bind(Messages.IndexUI_infoNotInSource, input.getElementName());
}
}
String msg= NLS.bind(Messages.IndexUI_infoNotInIndex, tu.getElementName());
IResource res= tu.getResource();
if (res != null) {
Properties props= IndexerPreferences.getProperties(res.getProject());
@ -469,7 +468,7 @@ public class IndexUI {
(!"true".equals(props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG)) && //$NON-NLS-1$
!"true".equals(props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG)))) { //$NON-NLS-1$
msg= msg + " " + Messages.IndexUI_infoSelectIndexAllFiles; //$NON-NLS-1$
}
}
}
return msg;
}
@ -478,16 +477,16 @@ public class IndexUI {
if (input instanceof ICElementHandle) {
return input;
}
IIndexName name= IndexUI.elementToName(index, input);
IIndexName name= elementToName(index, input);
if (name != null) {
ICElement handle= getCElementForName(input.getCProject(), index, name);
if (handle != null) {
return handle;
}
}
}
return input;
}
/**
* Searches for all specializations that depend on the definition of the given binding.
*/
@ -536,8 +535,7 @@ public class IndexUI {
}
}
}
if (result != null) {
return result;
}