1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +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

@ -26,10 +26,10 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplate { 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(); public ICPPClassTemplate getPrimaryClassTemplate();

View file

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

View file

@ -18,7 +18,6 @@ import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CEditor;
public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public CppTypeHierarchyTest(String name) { public CppTypeHierarchyTest(String name) {
@ -76,7 +75,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("Simple2"), 1); editor.selectAndReveal(content.indexOf("Simple2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -92,7 +90,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"}); checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("Simple3"), 1); editor.selectAndReveal(content.indexOf("Simple3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -108,7 +105,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("Simple4"), 1); editor.selectAndReveal(content.indexOf("Simple4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -169,7 +165,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("method2"), 1); editor.selectAndReveal(content.indexOf("method2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -185,7 +180,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"}); checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("field3"), 1); editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -201,7 +195,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1); editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -261,7 +254,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("Multi2"), 1); editor.selectAndReveal(content.indexOf("Multi2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -279,7 +271,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"}); checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("Multi3"), 1); editor.selectAndReveal(content.indexOf("Multi3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -302,7 +293,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("Multi4"), 1); editor.selectAndReveal(content.indexOf("Multi4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -372,7 +362,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("method2"), 1); editor.selectAndReveal(content.indexOf("method2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -390,7 +379,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2 : int", "method2() : int"}); checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("field3"), 1); editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -413,7 +401,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1); editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -488,7 +475,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("Diamond2"), 1); editor.selectAndReveal(content.indexOf("Diamond2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -506,7 +492,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field2 : int", "method2() : int"}); checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("Diamond3"), 1); editor.selectAndReveal(content.indexOf("Diamond3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -524,7 +509,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("Diamond4"), 1); editor.selectAndReveal(content.indexOf("Diamond4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -599,7 +583,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("method2"), 1); editor.selectAndReveal(content.indexOf("method2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -617,7 +600,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field2 : int", "method2() : int"}); checkMethodTable(new String[] {"field2 : int", "method2() : int"});
editor.selectAndReveal(content.indexOf("field3"), 1); editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -635,7 +617,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1); editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -704,7 +685,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1); editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -720,7 +700,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {}); checkMethodTable(new String[] {});
editor.selectAndReveal(content.indexOf("ViaTypedef3"), 1); editor.selectAndReveal(content.indexOf("ViaTypedef3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -736,7 +715,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("ViaTypedef4"), 1); editor.selectAndReveal(content.indexOf("ViaTypedef4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -795,7 +773,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item4.getItemCount()); assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1 : int", "method1() : int"}); checkMethodTable(new String[] {"field1 : int", "method1() : int"});
editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1); editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -811,7 +788,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {}); checkMethodTable(new String[] {});
editor.selectAndReveal(content.indexOf("field3"), 1); editor.selectAndReveal(content.indexOf("field3"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();
@ -827,7 +803,6 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
assertEquals(0, item3.getItemCount()); assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3 : int", "method3() : int"}); checkMethodTable(new String[] {"field3 : int", "method3() : int"});
editor.selectAndReveal(content.indexOf("method4"), 1); editor.selectAndReveal(content.indexOf("method4"), 1);
openTypeHierarchy(editor); openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree(); tree= getHierarchyViewer().getTree();

View file

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

View file

@ -93,7 +93,7 @@ import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.cdt.internal.ui.editor.ASTProvider; import org.eclipse.cdt.internal.ui.editor.ASTProvider;
public class IndexUI { 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 { public static IIndexBinding elementToBinding(IIndex index, ICElement element) throws CoreException {
return elementToBinding(index, element, -1); return elementToBinding(index, element, -1);
@ -110,7 +110,7 @@ public class IndexUI {
} }
} else { } else {
String name= element.getElementName(); 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()); IIndexBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.ALL, new NullProgressMonitor());
for (IIndexBinding binding : bindings) { for (IIndexBinding binding : bindings) {
if (checkBinding(binding, element)) { if (checkBinding(binding, element)) {
@ -267,11 +267,10 @@ public class IndexUI {
return null; return null;
} }
public static ICElementHandle[] findRepresentative(IIndex index, IBinding binding) throws CoreException { 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) { if (defs.length == 0) {
ICElementHandle elem = IndexUI.findAnyDeclaration(index, null, binding); ICElementHandle elem = findAnyDeclaration(index, null, binding);
if (elem != null) { if (elem != null) {
defs = new ICElementHandle[] { elem }; defs = new ICElementHandle[] { elem };
} }
@ -292,7 +291,7 @@ public class IndexUI {
} }
return result.toArray(new ICElementHandle[result.size()]); return result.toArray(new ICElementHandle[result.size()]);
} }
return EMPTY_ELEMENTS; return EMPTY_ELEMENT_ARRAY;
} }
/** /**
@ -478,7 +477,7 @@ public class IndexUI {
if (input instanceof ICElementHandle) { if (input instanceof ICElementHandle) {
return input; return input;
} }
IIndexName name= IndexUI.elementToName(index, input); IIndexName name= elementToName(index, input);
if (name != null) { if (name != null) {
ICElement handle= getCElementForName(input.getCProject(), index, name); ICElement handle= getCElementForName(input.getCProject(), index, name);
if (handle != null) { if (handle != null) {
@ -537,7 +536,6 @@ public class IndexUI {
} }
} }
if (result != null) { if (result != null) {
return result; return result;
} }