1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-02-21 17:53:22 -08:00
parent 151a5d30c5
commit 0a69302022
13 changed files with 142 additions and 237 deletions

View file

@ -49,7 +49,7 @@ public class NamespaceTests extends PDOMTestBase {
protected void setUp() throws Exception { protected void setUp() throws Exception {
if (pdom == null) { if (pdom == null) {
project = createProject("namespaceTests", true); project = createProject("namespaceTests", true);
pdom = (PDOM)CCoreInternals.getPDOMManager().getPDOM(project); pdom = (PDOM) CCoreInternals.getPDOMManager().getPDOM(project);
} }
pdom.acquireReadLock(); pdom.acquireReadLock();
} }

View file

@ -1,13 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 IBM Corporation and others. * Copyright (c) 2007, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests; package org.eclipse.cdt.internal.pdom.tests;
@ -39,7 +39,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* Test the correctness of C/C++ searches * Test the correctness of C/C++ searches.
* *
* @author Vivian Kong * @author Vivian Kong
*/ */
@ -48,7 +48,8 @@ public class PDOMSearchTest extends PDOMTestBase {
@Override @Override
public int compare(IBinding o1, IBinding o2) { public int compare(IBinding o1, IBinding o2) {
return o1.getName().compareTo(o2.getName()); return o1.getName().compareTo(o2.getName());
}}; }
};
protected ICProject project; protected ICProject project;
protected PDOM pdom; protected PDOM pdom;
@ -75,7 +76,7 @@ public class PDOMSearchTest extends PDOMTestBase {
} }
/** /**
* Test the members inside namespaces * Tests the members inside namespaces
*/ */
public void testNamespaces() throws Exception { public void testNamespaces() throws Exception {
/* Members in the namespace */ /* Members in the namespace */
@ -103,11 +104,11 @@ public class PDOMSearchTest extends PDOMTestBase {
IName[] refs = pdom.findNames(namespace1,IIndex.FIND_REFERENCES); IName[] refs = pdom.findNames(namespace1,IIndex.FIND_REFERENCES);
assertEquals(3, refs.length); assertEquals(3, refs.length);
IASTFileLocation loc = refs[0].getFileLocation(); IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("main.cpp","namespace1::Class1"), loc.getNodeOffset()); //character offset assertEquals(offset("main.cpp", "namespace1::Class1"), loc.getNodeOffset()); //character offset
loc = refs[1].getFileLocation(); loc = refs[1].getFileLocation();
assertEquals(offset("Class1.cpp","namespace1::Class1::~Class1()"), loc.getNodeOffset()); //character offset assertEquals(offset("Class1.cpp", "namespace1::Class1::~Class1()"), loc.getNodeOffset()); //character offset
loc = refs[2].getFileLocation(); loc = refs[2].getFileLocation();
assertEquals(offset("Class1.cpp","namespace1::Class1::Class1()"), loc.getNodeOffset()); //character offset assertEquals(offset("Class1.cpp", "namespace1::Class1::Class1()"), loc.getNodeOffset()); //character offset
/* Namespace declaration */ /* Namespace declaration */
IName[] decls = pdom.findNames(namespace1, IIndex.FIND_DECLARATIONS); IName[] decls = pdom.findNames(namespace1, IIndex.FIND_DECLARATIONS);
@ -117,11 +118,10 @@ public class PDOMSearchTest extends PDOMTestBase {
IName[] defs = pdom.findNames(namespace1, IIndex.FIND_DEFINITIONS); IName[] defs = pdom.findNames(namespace1, IIndex.FIND_DEFINITIONS);
assertEquals(1, defs.length); assertEquals(1, defs.length);
loc = defs[0].getFileLocation(); loc = defs[0].getFileLocation();
assertEquals(offset("Class1.h","namespace namespace1") + 10, loc.getNodeOffset()); //character offset assertEquals(offset("Class1.h", "namespace namespace1") + 10, loc.getNodeOffset()); //character offset
} }
public void testClasses() throws Exception { public void testClasses_160913() throws Exception {
// Bugzilla 160913
// classes and nested classes // classes and nested classes
/* Search for "Class1" */ /* Search for "Class1" */
@ -148,7 +148,7 @@ public class PDOMSearchTest extends PDOMTestBase {
methods = class2.getDeclaredMethods(); methods = class2.getDeclaredMethods();
assertEquals(2, methods.length); assertEquals(2, methods.length);
if (methods[0].getName().equals("~Class1")) { if (methods[0].getName().equals("~Class1")) {
IBinding h= methods[1]; methods[1]= methods[0]; methods[0]=h; IBinding h= methods[1]; methods[1]= methods[0]; methods[0]= h;
} }
assertEquals("Class1", methods[0].getName()); assertEquals("Class1", methods[0].getName());
assertEquals("~Class1", methods[1].getName()); assertEquals("~Class1", methods[1].getName());
@ -219,7 +219,7 @@ public class PDOMSearchTest extends PDOMTestBase {
IName[] defs = pdom.findNames(cls3, IIndex.FIND_DEFINITIONS); IName[] defs = pdom.findNames(cls3, IIndex.FIND_DEFINITIONS);
assertEquals(1, defs.length); assertEquals(1, defs.length);
IASTFileLocation loc = defs[0].getFileLocation(); IASTFileLocation loc = defs[0].getFileLocation();
assertEquals(offset("Class1.h","class Class2 { //namespace1::Class1::Class2") + 6, loc.getNodeOffset()); //character offset assertEquals(offset("Class1.h", "class Class2 { //namespace1::Class1::Class2") + 6, loc.getNodeOffset()); //character offset
} }
public void testFunction() throws Exception { public void testFunction() throws Exception {
@ -263,34 +263,35 @@ public class PDOMSearchTest extends PDOMTestBase {
IName[] refs = pdom.findNames(variables[0], IIndex.FIND_REFERENCES); IName[] refs = pdom.findNames(variables[0], IIndex.FIND_REFERENCES);
assertEquals(1, refs.length); assertEquals(1, refs.length);
IASTFileLocation loc = refs[0].getFileLocation(); IASTFileLocation loc = refs[0].getFileLocation();
assertEquals(offset("main.cpp","var = 0;"), loc.getNodeOffset()); //character offset assertEquals(offset("main.cpp", "var = 0;"), loc.getNodeOffset()); // character offset
/* Variable declaration */ /* Variable declaration */
IName[] decls = pdom.findNames(variables[0], IIndex.FIND_DECLARATIONS_DEFINITIONS); IName[] decls = pdom.findNames(variables[0], IIndex.FIND_DECLARATIONS_DEFINITIONS);
assertEquals(1, decls.length); assertEquals(1, decls.length);
loc = decls[0].getFileLocation(); loc = decls[0].getFileLocation();
assertEquals(offset("main.cpp","int var;") + 4, loc.getNodeOffset()); //character offset assertEquals(offset("main.cpp", "int var;") + 4, loc.getNodeOffset()); // character offset
/* Variable definition */ /* Variable definition */
IName[] defs = pdom.findNames(variables[0], IIndex.FIND_DEFINITIONS); IName[] defs = pdom.findNames(variables[0], IIndex.FIND_DEFINITIONS);
assertEquals(1, defs.length); assertEquals(1, defs.length);
loc = defs[0].getFileLocation(); loc = defs[0].getFileLocation();
assertEquals(offset("main.cpp","int var;") + 4, loc.getNodeOffset()); //character offset assertEquals(offset("main.cpp", "int var;") + 4, loc.getNodeOffset()); // character offset
} }
/** /**
* Get the fully qualified name for a given PDOMBinding * Returns the fully qualified name for a given PDOMBinding
* *
* @param pdomBinding * @param pdomBinding
* @return binding's fully qualified name * @return binding's fully qualified name
* @throws CoreException * @throws CoreException
*/ */
private String getBindingQualifiedName(PDOMBinding pdomBinding) throws CoreException { private static String getBindingQualifiedName(PDOMBinding pdomBinding) throws CoreException {
StringBuffer buf = new StringBuffer(pdomBinding.getName()); StringBuilder buf = new StringBuilder(pdomBinding.getName());
PDOMNode parent = pdomBinding.getParentNode(); PDOMNode parent = pdomBinding.getParentNode();
while (parent != null) { while (parent != null) {
if (parent instanceof PDOMBinding) { if (parent instanceof PDOMBinding) {
buf.insert(0, ((PDOMBinding) parent).getName() + "::"); String name = ((PDOMBinding) parent).getName();
buf.insert(0, name + "::");
} }
parent = parent.getParentNode(); parent = parent.getParentNode();
} }

View file

@ -91,7 +91,7 @@ public class PDOMTestBase extends BaseTestCase {
try { try {
importOp.run(monitor); importOp.run(monitor);
} catch (Exception e) { } catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, 0, "Import Interrupted", e)); throw new CoreException(new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, 0, "Import interrupted", e));
} }
cprojects[0] = cproject; cprojects[0] = cproject;

View file

@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IPath;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ITypeReference { public interface ITypeReference {
/** /**
* Returns the full, absolute path of this reference * Returns the full, absolute path of this reference
* relative to the workspace, or null if no path can be * relative to the workspace, or null if no path can be
@ -30,7 +29,7 @@ public interface ITypeReference {
*/ */
public IPath getPath(); public IPath getPath();
/** /**
* Returns the absolute path in the local file system * Returns the absolute path in the local file system
* to this reference, or null if no path can be * to this reference, or null if no path can be
* determined. * determined.

View file

@ -85,14 +85,12 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
try { try {
elementType = IndexModelUtil.getElementType(binding); elementType = IndexModelUtil.getElementType(binding);
if (binding instanceof ICPPBinding) { if (binding instanceof ICPPBinding) {
fqn= ((ICPPBinding)binding).getQualifiedName(); fqn= ((ICPPBinding) binding).getQualifiedName();
} } else if (binding instanceof IField) {
else if (binding instanceof IField) {
IField field= (IField) binding; IField field= (IField) binding;
ICompositeType owner= field.getCompositeTypeOwner(); ICompositeType owner= field.getCompositeTypeOwner();
fqn= new String[] {owner.getName(), field.getName()}; fqn= new String[] {owner.getName(), field.getName()};
} } else {
else {
fqn= new String[] {binding.getName()}; fqn= new String[] {binding.getName()};
} }
try { try {
@ -109,7 +107,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return new IndexTypeInfo(fqn, flsq, elementType, index, paramTypes, returnType, null); return new IndexTypeInfo(fqn, flsq, elementType, index, paramTypes, returnType, null);
} }
} catch (DOMException e) { } catch (DOMException e) {
// index bindings don't throw DOMExceptions. // Index bindings don't throw DOMExceptions.
throw new AssertionError(); throw new AssertionError();
} }
@ -128,12 +126,12 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
String[] params= null; String[] params= null;
if (ps != null) { if (ps != null) {
params= new String[ps.length]; params= new String[ps.length];
int i=-1; int i= -1;
for (char[] p : ps) { for (char[] p : ps) {
params[++i]= new String(p); params[++i]= new String(p);
} }
} }
return new IndexTypeInfo(new String[] {new String(name)}, ICElement.C_MACRO, params, null, index); return new IndexTypeInfo(new String[] { new String(name) }, ICElement.C_MACRO, params, null, index);
} }
/** /**
@ -143,7 +141,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return new IndexTypeInfo(rhs, ref); return new IndexTypeInfo(rhs, ref);
} }
private IndexTypeInfo(String[] fqn, IIndexFileLocation fileLocal, int elementType, IIndex index, String[] params, String returnType, ITypeReference reference) { private IndexTypeInfo(String[] fqn, IIndexFileLocation fileLocal, int elementType, IIndex index,
String[] params, String returnType, ITypeReference reference) {
Assert.isTrue(index != null); Assert.isTrue(index != null);
this.fqn= fqn; this.fqn= fqn;
this.fileLocal= fileLocal; this.fileLocal= fileLocal;
@ -169,9 +168,9 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
@Override @Override
public ICProject getEnclosingProject() { public ICProject getEnclosingProject() {
if(getResolvedReference()!=null) { if (getResolvedReference() != null) {
IProject project = reference.getProject(); IProject project = reference.getProject();
if(project!=null) { if (project != null) {
return CCorePlugin.getDefault().getCoreModel().getCModel().getCProject(project.getName()); return CCorePlugin.getDefault().getCoreModel().getCModel().getCProject(project.getName());
} }
} }
@ -180,7 +179,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
@Override @Override
public String getName() { public String getName() {
return fqn[fqn.length-1]; return fqn[fqn.length - 1];
} }
@Override @Override
@ -188,17 +187,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return new QualifiedTypeName(fqn); return new QualifiedTypeName(fqn);
} }
/*
* @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getParameters()
*/
@Override @Override
public String[] getParameters() { public String[] getParameters() {
return params; return params;
} }
/*
* @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getReturnType()
*/
@Override @Override
public String getReturnType() { public String getReturnType() {
return returnType; return returnType;
@ -232,8 +225,9 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (fileLocal == null) { if (fileLocal == null) {
if (other.fileLocal != null) if (other.fileLocal != null)
return false; return false;
} else if (!fileLocal.equals(other.fileLocal)) } else if (!fileLocal.equals(other.fileLocal)) {
return false; return false;
}
if (!Arrays.equals(fqn, other.fqn)) if (!Arrays.equals(fqn, other.fqn))
return false; return false;
if (!Arrays.equals(params, other.params)) if (!Arrays.equals(params, other.params))
@ -250,7 +244,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
@Override @Override
public ITypeReference getResolvedReference() { public ITypeReference getResolvedReference() {
if(reference==null) { if (reference == null) {
if (elementType == ICElement.C_MACRO) { if (elementType == ICElement.C_MACRO) {
return createMacroReference(); return createMacroReference();
} }
@ -262,7 +256,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
} }
try { try {
IIndexBinding[] ibs = findBindings(); IIndexBinding[] ibs = findBindings();
if(ibs.length>0) { if (ibs.length > 0) {
IIndexName[] names; IIndexName[] names;
names= index.findNames(ibs[0], IIndex.FIND_DEFINITIONS); names= index.findNames(ibs[0], IIndex.FIND_DEFINITIONS);
if (names.length == 0) { if (names.length == 0) {
@ -275,8 +269,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
} }
} }
} }
} catch(CoreException ce) { } catch(CoreException e) {
CCorePlugin.log(ce); CCorePlugin.log(e);
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
} }
@ -286,13 +280,14 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
private IIndexBinding[] findBindings() throws CoreException { private IIndexBinding[] findBindings() throws CoreException {
char[][] cfqn = new char[fqn.length][]; char[][] cfqn = new char[fqn.length][];
for(int i=0; i<fqn.length; i++) for (int i= 0; i < fqn.length; i++) {
cfqn[i] = fqn[i].toCharArray(); cfqn[i] = fqn[i].toCharArray();
}
IIndexBinding[] ibs = index.findBindings(cfqn, new IndexFilter() { IIndexBinding[] ibs = index.findBindings(cfqn, new IndexFilter() {
@Override @Override
public boolean acceptBinding(IBinding binding) { public boolean acceptBinding(IBinding binding) {
if (!IndexModelUtil.bindingHasCElementType(binding, new int[]{elementType})) { if (!IndexModelUtil.bindingHasCElementType(binding, new int[] {elementType})) {
return false; return false;
} }
try { try {
@ -300,22 +295,19 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (((IIndexBinding) binding).isFileLocal()) { if (((IIndexBinding) binding).isFileLocal()) {
return false; return false;
} }
} } else {
else {
IIndexFile localToFile= ((IIndexBinding) binding).getLocalToFile(); IIndexFile localToFile= ((IIndexBinding) binding).getLocalToFile();
if (localToFile == null || !fileLocal.equals(localToFile.getLocation())) { if (localToFile == null || !fileLocal.equals(localToFile.getLocation())) {
return false; return false;
} }
} }
if (binding instanceof IFunction && params != null) { if (binding instanceof IFunction && params != null) {
String[]otherParams= IndexModelUtil.extractParameterTypes((IFunction)binding); String[] otherParams= IndexModelUtil.extractParameterTypes((IFunction) binding);
if (!Arrays.equals(params, otherParams)) { if (!Arrays.equals(params, otherParams)) {
return false; return false;
} }
} }
} catch (CoreException e) { } catch (CoreException | DOMException e) {
CCorePlugin.log(e);
} catch (DOMException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
return true; return true;
@ -333,7 +325,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
} }
try { try {
IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor()); IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
if(macros.length>0) { if (macros.length > 0) {
for (IIndexMacro macro : macros) { for (IIndexMacro macro : macros) {
reference= createReference(macro); reference= createReference(macro);
if (reference != null) { if (reference != null) {
@ -341,8 +333,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
} }
} }
} }
} catch(CoreException ce) { } catch(CoreException e) {
CCorePlugin.log(ce); CCorePlugin.log(e);
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
} }
@ -382,7 +374,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return getMacroReferences(); return getMacroReferences();
} }
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>(); List<IndexTypeReference> references= new ArrayList<>();
try { try {
index.acquireReadLock(); index.acquireReadLock();
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
@ -391,7 +383,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
} }
try { try {
IIndexBinding[] ibs= findBindings(); IIndexBinding[] ibs= findBindings();
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>(); HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<>();
for (IIndexBinding binding : ibs) { for (IIndexBinding binding : ibs) {
IIndexName[] names; IIndexName[] names;
names= index.findNames(binding, IIndex.FIND_DEFINITIONS); names= index.findNames(binding, IIndex.FIND_DEFINITIONS);
@ -415,9 +407,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return references.toArray(new IndexTypeReference[references.size()]); return references.toArray(new IndexTypeReference[references.size()]);
} }
private ITypeReference[] getMacroReferences() { private ITypeReference[] getMacroReferences() {
List<IndexTypeReference> references= new ArrayList<IndexTypeReference>(); List<IndexTypeReference> references= new ArrayList<>();
try { try {
index.acquireReadLock(); index.acquireReadLock();
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -429,7 +420,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
IIndexMacro[] ibs = index.findMacros(cfn, IndexFilter.ALL_DECLARED, new NullProgressMonitor()); IIndexMacro[] ibs = index.findMacros(cfn, IndexFilter.ALL_DECLARED, new NullProgressMonitor());
// in case a file is represented multiple times in the index then we take references from // in case a file is represented multiple times in the index then we take references from
// one of those, only. // one of those, only.
HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>(); HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<>();
for (IIndexMacro macro : ibs) { for (IIndexMacro macro : ibs) {
if (checkParameters(macro.getParameterList())) { if (checkParameters(macro.getParameterList())) {
if (checkFile(iflMap, macro.getFile())) { if (checkFile(iflMap, macro.getFile())) {
@ -440,8 +431,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
} }
} }
} }
} catch(CoreException ce) { } catch (CoreException e) {
CCorePlugin.log(ce); CCorePlugin.log(e);
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
} }
@ -566,7 +557,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** /**
* @deprecated * @deprecated
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.
@ -588,7 +578,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** /**
* @deprecated * @deprecated
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.

View file

@ -43,26 +43,27 @@ public class IndexModelUtil {
/** /**
* Returns whether the binding is of any of the specified CElement type constants * Returns whether the binding is of any of the specified CElement type constants
*
* @param binding * @param binding
* @param kinds * @param kinds
* @return whether the binding is of any of the specified CElement type constants * @return whether the binding is of any of the specified CElement type constants
*/ */
public static boolean bindingHasCElementType(IBinding binding, int[] kinds) { public static boolean bindingHasCElementType(IBinding binding, int[] kinds) {
for (int kind : kinds) { for (int kind : kinds) {
switch(kind) { switch (kind) {
case ICElement.C_STRUCT: case ICElement.C_STRUCT:
if (binding instanceof ICompositeType if (binding instanceof ICompositeType
&& ((ICompositeType)binding).getKey() == ICompositeType.k_struct) && ((ICompositeType) binding).getKey() == ICompositeType.k_struct)
return true; return true;
break; break;
case ICElement.C_UNION: case ICElement.C_UNION:
if (binding instanceof ICompositeType if (binding instanceof ICompositeType
&& ((ICompositeType)binding).getKey() == ICompositeType.k_union) && ((ICompositeType) binding).getKey() == ICompositeType.k_union)
return true; return true;
break; break;
case ICElement.C_CLASS: case ICElement.C_CLASS:
if (binding instanceof ICompositeType if (binding instanceof ICompositeType
&& ((ICompositeType)binding).getKey() == ICPPClassType.k_class) && ((ICompositeType) binding).getKey() == ICPPClassType.k_class)
return true; return true;
break; break;
case ICElement.C_NAMESPACE: case ICElement.C_NAMESPACE:

View file

@ -877,7 +877,8 @@ public class PDOM extends PlatformObject implements IPDOM {
return findBindings(names, true, filter, monitor); return findBindings(names, true, filter, monitor);
} }
public IIndexFragmentBinding[] findBindings(char[][] names, boolean caseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { public IIndexFragmentBinding[] findBindings(char[][] names, boolean caseSensitive, IndexFilter filter,
IProgressMonitor monitor) throws CoreException {
if (names.length == 0) { if (names.length == 0) {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY; return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
} }
@ -885,7 +886,7 @@ public class PDOM extends PlatformObject implements IPDOM {
return findBindings(names[0], true, caseSensitive, filter, monitor); return findBindings(names[0], true, caseSensitive, filter, monitor);
} }
IIndexFragmentBinding[] candidates = findBindings(names[names.length-1], false, caseSensitive, filter, monitor); IIndexFragmentBinding[] candidates = findBindings(names[names.length - 1], false, caseSensitive, filter, monitor);
int j= 0; int j= 0;
for (int i = 0; i < candidates.length; i++) { for (int i = 0; i < candidates.length; i++) {
IIndexFragmentBinding cand = candidates[i]; IIndexFragmentBinding cand = candidates[i];
@ -893,12 +894,11 @@ public class PDOM extends PlatformObject implements IPDOM {
candidates[j++]= cand; candidates[j++]= cand;
} }
} }
return ArrayUtil.trimAt(IIndexFragmentBinding.class, candidates, j-1); return ArrayUtil.trimAt(IIndexFragmentBinding.class, candidates, j - 1);
} }
private boolean matches(IIndexFragmentBinding cand, char[][] names, boolean caseSensitive) { private boolean matches(IIndexFragmentBinding cand, char[][] names, boolean caseSensitive) {
int i= names.length-1; for (int i= names.length; --i >= 0; cand= cand.getOwner()) {
while(i >= 0) {
if (cand == null) if (cand == null)
return false; return false;
@ -913,8 +913,6 @@ public class PDOM extends PlatformObject implements IPDOM {
return false; return false;
} }
} }
cand= cand.getOwner();
i--;
} }
return cand == null; return cand == null;
} }
@ -1210,8 +1208,7 @@ public class PDOM extends PlatformObject implements IPDOM {
names.add(name); names.add(name);
} }
} }
IPDOMIterator<PDOMName> iterator = pdomBinding.getExternalReferences(); for (IPDOMIterator<PDOMName> iterator = pdomBinding.getExternalReferences(); iterator.hasNext();) {
while(iterator.hasNext()) {
name = iterator.next(); name = iterator.next();
if (isCommitted(name)) if (isCommitted(name))
names.add(name); names.add(name);

View file

@ -18,7 +18,6 @@ import org.eclipse.core.runtime.CoreException;
* a way to remove elements. * a way to remove elements.
*/ */
public interface IPDOMIterator<T> { public interface IPDOMIterator<T> {
/** /**
* Return true if the next call to #next will yield a value and false otherwise. * Return true if the next call to #next will yield a value and false otherwise.
* *

View file

@ -70,7 +70,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
* The last used prefix to query the index. <code>null</code> means * The last used prefix to query the index. <code>null</code> means
* the query result should be empty. * the query result should be empty.
*/ */
private volatile char[] fCurrentPrefix = null; private volatile char[] fCurrentPrefix;
public UpdateElementsJob(String name) { public UpdateElementsJob(String name) {
super(name); super(name);
@ -134,7 +134,8 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
if (!shell.isDisposed() && fDone) { if (!shell.isDisposed() && fDone) {
fMonitor.done(); fMonitor.done();
} }
}}; }
};
shell.getDisplay().asyncExec(update); shell.getDisplay().asyncExec(update);
} }
} }
@ -150,7 +151,8 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
if (!shell.isDisposed() && !fDone) { if (!shell.isDisposed() && !fDone) {
fMonitor.beginTask(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_inProgress, IProgressMonitor.UNKNOWN); fMonitor.beginTask(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_inProgress, IProgressMonitor.UNKNOWN);
} }
}}; }
};
shell.getDisplay().asyncExec(update); shell.getDisplay().asyncExec(update);
} }
} }
@ -164,7 +166,8 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
@Override @Override
public boolean isConflicting(ISchedulingRule rule) { public boolean isConflicting(ISchedulingRule rule) {
return rule == this; return rule == this;
}}; }
};
private UpdateElementsJob fUpdateJob; private UpdateElementsJob fUpdateJob;
private boolean fAllowEmptyPrefix= true; private boolean fAllowEmptyPrefix= true;
@ -175,6 +178,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
/** /**
* Constructs an instance of <code>OpenTypeDialog</code>. * Constructs an instance of <code>OpenTypeDialog</code>.
*
* @param parent the parent shell. * @param parent the parent shell.
*/ */
public ElementSelectionDialog(Shell parent) { public ElementSelectionDialog(Shell parent) {
@ -185,9 +189,6 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
fUpdateJob.setRule(SINGLE_INSTANCE_RULE); fUpdateJob.setRule(SINGLE_INSTANCE_RULE);
} }
/*
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create()
*/
@Override @Override
public void create() { public void create() {
super.create(); super.create();
@ -195,9 +196,6 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
scheduleUpdate(getFilter()); scheduleUpdate(getFilter());
} }
/*
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#close()
*/
@Override @Override
public boolean close() { public boolean close() {
fUpdateJob.cancel(); fUpdateJob.cancel();
@ -205,7 +203,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
/** /**
* Configure the help context id for this dialog. * Configures the help context id for this dialog.
* *
* @param helpContextId * @param helpContextId
*/ */
@ -214,9 +212,6 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
setHelpAvailable(fHelpContextId != null); setHelpAvailable(fHelpContextId != null);
} }
/*
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#setMatchEmptyString(boolean)
*/
@Override @Override
public void setMatchEmptyString(boolean matchEmptyString) { public void setMatchEmptyString(boolean matchEmptyString) {
super.setMatchEmptyString(matchEmptyString); super.setMatchEmptyString(matchEmptyString);
@ -227,7 +222,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
/** /**
* Set whether an empty prefix should be allowed for queries. * Sets whether an empty prefix should be allowed for queries.
* *
* @param allowEmptyPrefix * @param allowEmptyPrefix
*/ */
@ -235,27 +230,18 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
fAllowEmptyPrefix = allowEmptyPrefix; fAllowEmptyPrefix = allowEmptyPrefix;
} }
/*
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#showLowLevelFilter()
*/
@Override @Override
protected boolean showLowLevelFilter() { protected boolean showLowLevelFilter() {
// the low-level filter is useless for us // The low-level filter is useless for us.
return false; return false;
} }
/*
* @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
public Control createDialogArea(Composite parent) { public Control createDialogArea(Composite parent) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, fHelpContextId); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, fHelpContextId);
return super.createDialogArea(parent); return super.createDialogArea(parent);
} }
/*
* @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createLowerList(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
protected Table createLowerList(Composite parent) { protected Table createLowerList(Composite parent) {
Table table= super.createLowerList(parent); Table table= super.createLowerList(parent);
@ -264,8 +250,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
/** /**
* Create the control for progress reporting. * Creates the control for progress reporting.
* @param parent
*/ */
private void createProgressMonitorPart(Composite parent) { private void createProgressMonitorPart(Composite parent) {
fProgressMonitorPart= new ProgressMonitorPart(parent, new GridLayout(2, false)); fProgressMonitorPart= new ProgressMonitorPart(parent, new GridLayout(2, false));
@ -281,16 +266,13 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} }
/** /**
* Query the elements for the given prefix. * Queries the elements for the given prefix.
*
* @param prefix
* @param monitor
*/ */
protected ITypeInfo[] getElementsByPrefix(char[] prefix, IProgressMonitor monitor) { protected ITypeInfo[] getElementsByPrefix(char[] prefix, IProgressMonitor monitor) {
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
return null; return null;
} }
HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>(); HashSet<IndexTypeInfo> types = new HashSet<>();
if (prefix != null) { if (prefix != null) {
final IndexFilter filter= new IndexFilter() { final IndexFilter filter= new IndexFilter() {
@Override @Override
@ -327,9 +309,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
} }
} catch (CoreException e) { } catch (CoreException | InterruptedException e) {
CUIPlugin.log(e);
} catch (InterruptedException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
} }
@ -345,9 +325,6 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleElementsChanged()
*/
@Override @Override
protected void handleElementsChanged() { protected void handleElementsChanged() {
updateOkState(); updateOkState();

View file

@ -41,18 +41,12 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class OpenTypeAction implements IWorkbenchWindowActionDelegate { public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow fWorkbenchWindow; private IWorkbenchWindow fWorkbenchWindow;
public OpenTypeAction() { public OpenTypeAction() {
super(); super();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override @Override
public void run(IAction action) { public void run(IAction action) {
ElementSelectionDialog dialog = new ElementSelectionDialog(getShell()); ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
@ -67,12 +61,12 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
ITypeReference location = info.getResolvedReference(); ITypeReference location = info.getResolvedReference();
if (location == null) { if (location == null) {
// could not resolve location // Could not resolve location.
String title = OpenTypeMessages.OpenTypeAction_errorTitle; String title = OpenTypeMessages.OpenTypeAction_errorTitle;
String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorTypeNotFound, info.getQualifiedTypeName().toString()); String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorTypeNotFound, info.getQualifiedTypeName().toString());
MessageDialog.openError(getShell(), title, message); MessageDialog.openError(getShell(), title, message);
} else if (!openTypeInEditor(location)) { } else if (!openTypeInEditor(location)) {
// error opening editor // Error opening editor.
String title = OpenTypeMessages.OpenTypeAction_errorTitle; String title = OpenTypeMessages.OpenTypeAction_errorTitle;
String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorOpenEditor, location.getPath().toString()); String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorOpenEditor, location.getPath().toString());
MessageDialog.openError(getShell(), title, message); MessageDialog.openError(getShell(), title, message);
@ -91,7 +85,7 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection(); ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
if (sel instanceof ITextSelection) { if (sel instanceof ITextSelection) {
String txt= ((ITextSelection) sel).getText(); String txt= ((ITextSelection) sel).getText();
if (txt.length() > 0 && txt.length() < 80) { if (!txt.isEmpty() && txt.length() < 80) {
dialog.setFilter(txt, true); dialog.setFilter(txt, true);
} }
} }
@ -108,7 +102,7 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
* Opens an editor and displays the selected type. * Opens an editor and displays the selected type.
* *
* @param info Type to display. * @param info Type to display.
* @return true if succesfully displayed. * @return true if successfully displayed.
*/ */
private boolean openTypeInEditor(ITypeReference location) { private boolean openTypeInEditor(ITypeReference location) {
ICElement[] cElements= location.getCElements(); ICElement[] cElements= location.getCElements();
@ -124,11 +118,11 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
if (unit != null) if (unit != null)
editorPart = EditorUtility.openInEditor(unit); editorPart = EditorUtility.openInEditor(unit);
if (editorPart == null) { if (editorPart == null) {
// open as external file // Open as external file.
editorPart = EditorUtility.openInEditor(location.getLocation(), null); editorPart = EditorUtility.openInEditor(location.getLocation(), null);
} }
// highlight the type in the editor // Highlight the type in the editor.
if (editorPart != null && editorPart instanceof ITextEditor) { if (editorPart != null && editorPart instanceof ITextEditor) {
ITextEditor editor = (ITextEditor) editorPart; ITextEditor editor = (ITextEditor) editorPart;
if( location.isLineNumber() ) if( location.isLineNumber() )
@ -160,32 +154,16 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
return false; return false;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
@Override @Override
public void dispose() { public void dispose() {
fWorkbenchWindow= null; fWorkbenchWindow= null;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
@Override @Override
public void init(IWorkbenchWindow window) { public void init(IWorkbenchWindow window) {
fWorkbenchWindow= window; fWorkbenchWindow= window;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* org.eclipse.jface.viewers.ISelection)
*/
@Override @Override
public void selectionChanged(IAction action, ISelection selection) { public void selectionChanged(IAction action, ISelection selection) {
} }

View file

@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.ui.browser.opentype;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
/** /**
* A dialog to select a type from a list of types. * A dialog to select a type from a list of types.
* *
@ -25,7 +24,6 @@ import org.eclipse.swt.widgets.Shell;
*/ */
@Deprecated @Deprecated
public class OpenTypeDialog extends ElementSelectionDialog { public class OpenTypeDialog extends ElementSelectionDialog {
/** /**
* Constructs an instance of <code>OpenTypeDialog</code>. * Constructs an instance of <code>OpenTypeDialog</code>.
* @param parent the parent shell. * @param parent the parent shell.

View file

@ -17,9 +17,6 @@ import org.eclipse.osgi.util.NLS;
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public final class OpenTypeMessages extends NLS { public final class OpenTypeMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages";//$NON-NLS-1$
private OpenTypeMessages() { private OpenTypeMessages() {
// Do not instantiate // Do not instantiate
} }
@ -33,6 +30,6 @@ public final class OpenTypeMessages extends NLS {
public static String ElementSelectionDialog_UpdateElementsJob_inProgress; public static String ElementSelectionDialog_UpdateElementsJob_inProgress;
static { static {
NLS.initializeMessages(BUNDLE_NAME, OpenTypeMessages.class); NLS.initializeMessages(OpenTypeMessages.class.getName(), OpenTypeMessages.class);
} }
} }

View file

@ -56,19 +56,15 @@ import org.eclipse.cdt.internal.ui.util.StringMatcher;
public class TypeSelectionDialog extends TwoPaneElementSelector { public class TypeSelectionDialog extends TwoPaneElementSelector {
private static class TypeFilterMatcher implements FilteredList.FilterMatcher { private static class TypeFilterMatcher implements FilteredList.FilterMatcher {
private static final char END_SYMBOL = '<'; private static final char END_SYMBOL = '<';
private static final char ANY_STRING = '*'; private static final char ANY_STRING = '*';
private StringMatcher fNameMatcher = null; private StringMatcher fNameMatcher;
private StringMatcher[] fSegmentMatchers = null; private StringMatcher[] fSegmentMatchers;
private boolean fMatchGlobalNamespace = false; private boolean fMatchGlobalNamespace;
private Collection<Integer> fVisibleTypes = new HashSet<Integer>(); private Collection<Integer> fVisibleTypes = new HashSet<Integer>();
private boolean fShowLowLevelTypes = false; private boolean fShowLowLevelTypes;
/*
* @see FilteredList.FilterMatcher#setFilter(String, boolean)
*/
@Override @Override
public void setFilter(String pattern, boolean ignoreCase, boolean ignoreWildCards) { public void setFilter(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
// parse pattern into segments // parse pattern into segments
@ -77,7 +73,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
int length = segments.length; int length = segments.length;
// append wildcard to innermost segment // append wildcard to innermost segment
segments[length-1] = adjustPattern(segments[length-1]); segments[length - 1] = adjustPattern(segments[length - 1]);
fMatchGlobalNamespace = false; fMatchGlobalNamespace = false;
fSegmentMatchers = new StringMatcher[length]; fSegmentMatchers = new StringMatcher[length];
@ -121,9 +117,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
return fShowLowLevelTypes; return fShowLowLevelTypes;
} }
/*
* @see FilteredList.FilterMatcher#match(Object)
*/
@Override @Override
public boolean match(Object element) { public boolean match(Object element) {
if (!(element instanceof ITypeInfo)) if (!(element instanceof ITypeInfo))
@ -151,7 +144,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
if (fMatchGlobalNamespace) { if (fMatchGlobalNamespace) {
// must match global namespace (eg ::foo) // must match global namespace (eg ::foo)
if (qualifiedName.segment(0).length() > 0) if (!qualifiedName.segment(0).isEmpty())
return false; return false;
} }
@ -172,10 +165,10 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
int length = pattern.length(); int length = pattern.length();
if (length > 0) { if (length > 0) {
switch (pattern.charAt(length - 1)) { switch (pattern.charAt(length - 1)) {
case END_SYMBOL: case END_SYMBOL:
return pattern.substring(0, length - 1); return pattern.substring(0, length - 1);
case ANY_STRING: case ANY_STRING:
return pattern; return pattern;
} }
} }
return pattern + ANY_STRING; return pattern + ANY_STRING;
@ -290,9 +283,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
fDialogSection = section + "Settings"; //$NON-NLS-1$ fDialogSection = section + "Settings"; //$NON-NLS-1$
} }
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#createFilterText(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
protected Text createFilterText(Composite parent) { protected Text createFilterText(Composite parent) {
fTextWidget = super.createFilterText(parent); fTextWidget = super.createFilterText(parent);
@ -303,9 +293,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
return fTextWidget; return fTextWidget;
} }
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#createFilteredList(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
protected FilteredList createFilteredList(Composite parent) { protected FilteredList createFilteredList(Composite parent) {
fNewFilteredList = super.createFilteredList(parent); fNewFilteredList = super.createFilteredList(parent);
@ -325,9 +312,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
return fNewFilteredList; return fNewFilteredList;
} }
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#create()
*/
@Override @Override
public void create() { public void create() {
super.create(); super.create();
@ -335,18 +319,12 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
fTextWidget.selectAll(); fTextWidget.selectAll();
} }
/*
* @see Window#close()
*/
@Override @Override
public boolean close() { public boolean close() {
writeSettings(getDialogSettings()); writeSettings(getDialogSettings());
return super.close(); return super.close();
} }
/*
* @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
readSettings(getDialogSettings()); readSettings(getDialogSettings());
@ -360,38 +338,38 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
String name; String name;
int type = typeObject.intValue(); int type = typeObject.intValue();
switch (type) { switch (type) {
case ICElement.C_NAMESPACE: case ICElement.C_NAMESPACE:
name = TypeInfoMessages.TypeSelectionDialog_filterNamespaces; name = TypeInfoMessages.TypeSelectionDialog_filterNamespaces;
break; break;
case ICElement.C_CLASS: case ICElement.C_CLASS:
name = TypeInfoMessages.TypeSelectionDialog_filterClasses; name = TypeInfoMessages.TypeSelectionDialog_filterClasses;
break; break;
case ICElement.C_STRUCT: case ICElement.C_STRUCT:
name = TypeInfoMessages.TypeSelectionDialog_filterStructs; name = TypeInfoMessages.TypeSelectionDialog_filterStructs;
break; break;
case ICElement.C_TYPEDEF: case ICElement.C_TYPEDEF:
name = TypeInfoMessages.TypeSelectionDialog_filterTypedefs; name = TypeInfoMessages.TypeSelectionDialog_filterTypedefs;
break; break;
case ICElement.C_ENUMERATION: case ICElement.C_ENUMERATION:
name = TypeInfoMessages.TypeSelectionDialog_filterEnums; name = TypeInfoMessages.TypeSelectionDialog_filterEnums;
break; break;
case ICElement.C_UNION: case ICElement.C_UNION:
name = TypeInfoMessages.TypeSelectionDialog_filterUnions; name = TypeInfoMessages.TypeSelectionDialog_filterUnions;
break; break;
case ICElement.C_FUNCTION: case ICElement.C_FUNCTION:
name = TypeInfoMessages.TypeSelectionDialog_filterFunctions; name = TypeInfoMessages.TypeSelectionDialog_filterFunctions;
break; break;
case ICElement.C_VARIABLE: case ICElement.C_VARIABLE:
name = TypeInfoMessages.TypeSelectionDialog_filterVariables; name = TypeInfoMessages.TypeSelectionDialog_filterVariables;
break; break;
case ICElement.C_ENUMERATOR: case ICElement.C_ENUMERATOR:
name = TypeInfoMessages.TypeSelectionDialog_filterEnumerators; name = TypeInfoMessages.TypeSelectionDialog_filterEnumerators;
break; break;
case ICElement.C_MACRO: case ICElement.C_MACRO:
name = TypeInfoMessages.TypeSelectionDialog_filterMacros; name = TypeInfoMessages.TypeSelectionDialog_filterMacros;
break; break;
default: default:
return; return;
} }
Image icon = TypeInfoLabelProvider.getTypeIcon(type); Image icon = TypeInfoLabelProvider.getTypeIcon(type);
@ -625,9 +603,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
return true; return true;
} }
/* (non-Cdoc)
* @see org.eclipse.jface.window.Window#getInitialSize()
*/
@Override @Override
protected Point getInitialSize() { protected Point getInitialSize() {
Point result = super.getInitialSize(); Point result = super.getInitialSize();
@ -641,9 +616,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
return result; return result;
} }
/* (non-Cdoc)
* @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
*/
@Override @Override
protected Point getInitialLocation(Point initialSize) { protected Point getInitialLocation(Point initialSize) {
Point result = super.getInitialLocation(initialSize); Point result = super.getInitialLocation(initialSize);
@ -663,23 +635,20 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
return result; return result;
} }
/*
* @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
*/
@Override @Override
protected void computeResult() { protected void computeResult() {
ITypeInfo selection = (ITypeInfo) getLowerSelectedElement(); ITypeInfo selection = (ITypeInfo) getLowerSelectedElement();
if (selection == null) if (selection == null)
return; return;
List<ITypeInfo> result = new ArrayList<ITypeInfo>(1); List<ITypeInfo> result = new ArrayList<>(1);
result.add(selection); result.add(selection);
setResult(result); setResult(result);
} }
@Override @Override
public Object[] getFoldedElements(int index) { public Object[] getFoldedElements(int index) {
ArrayList<IndexTypeInfo> result= new ArrayList<IndexTypeInfo>(); ArrayList<IndexTypeInfo> result= new ArrayList<>();
Object[] typeInfos= super.getFoldedElements(index); Object[] typeInfos= super.getFoldedElements(index);
if (typeInfos != null) { if (typeInfos != null) {
for (Object typeInfo : typeInfos) { for (Object typeInfo : typeInfos) {