Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2015-02-22 01:53:22 +0000
committerSergey Prigogin2015-02-24 00:27:54 +0000
commit0a693020228cc45826a5e4245a25a1f7f4e72e33 (patch)
tree3f11266ae692de67d9449854221c12a1b4c3daaf /core/org.eclipse.cdt.core/browser
parent151a5d30c519a4a185b2008c3fd1ea1f35022253 (diff)
downloadorg.eclipse.cdt-0a693020228cc45826a5e4245a25a1f7f4e72e33.tar.gz
org.eclipse.cdt-0a693020228cc45826a5e4245a25a1f7f4e72e33.tar.xz
org.eclipse.cdt-0a693020228cc45826a5e4245a25a1f7f4e72e33.zip
Cosmetics.
Diffstat (limited to 'core/org.eclipse.cdt.core/browser')
-rw-r--r--core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java3
-rw-r--r--core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java75
-rw-r--r--core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java9
3 files changed, 38 insertions, 49 deletions
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java
index 1704fcffc5e..ed827c1934f 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java
+++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/ITypeReference.java
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IPath;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ITypeReference {
-
/**
* Returns the full, absolute path of this reference
* relative to the workspace, or null if no path can be
@@ -30,7 +29,7 @@ public interface ITypeReference {
*/
public IPath getPath();
- /**
+ /**
* Returns the absolute path in the local file system
* to this reference, or null if no path can be
* determined.
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java
index 76c201a9858..f0a29e9e90c 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java
+++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java
@@ -85,14 +85,12 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
try {
elementType = IndexModelUtil.getElementType(binding);
if (binding instanceof ICPPBinding) {
- fqn= ((ICPPBinding)binding).getQualifiedName();
- }
- else if (binding instanceof IField) {
+ fqn= ((ICPPBinding) binding).getQualifiedName();
+ } else if (binding instanceof IField) {
IField field= (IField) binding;
ICompositeType owner= field.getCompositeTypeOwner();
fqn= new String[] {owner.getName(), field.getName()};
- }
- else {
+ } else {
fqn= new String[] {binding.getName()};
}
try {
@@ -109,7 +107,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return new IndexTypeInfo(fqn, flsq, elementType, index, paramTypes, returnType, null);
}
} catch (DOMException e) {
- // index bindings don't throw DOMExceptions.
+ // Index bindings don't throw DOMExceptions.
throw new AssertionError();
}
@@ -128,12 +126,12 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
String[] params= null;
if (ps != null) {
params= new String[ps.length];
- int i=-1;
+ int i= -1;
for (char[] p : ps) {
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);
}
- 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);
this.fqn= fqn;
this.fileLocal= fileLocal;
@@ -169,9 +168,9 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
@Override
public ICProject getEnclosingProject() {
- if(getResolvedReference()!=null) {
+ if (getResolvedReference() != null) {
IProject project = reference.getProject();
- if(project!=null) {
+ if (project != null) {
return CCorePlugin.getDefault().getCoreModel().getCModel().getCProject(project.getName());
}
}
@@ -180,7 +179,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
@Override
public String getName() {
- return fqn[fqn.length-1];
+ return fqn[fqn.length - 1];
}
@Override
@@ -188,17 +187,11 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return new QualifiedTypeName(fqn);
}
- /*
- * @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getParameters()
- */
@Override
public String[] getParameters() {
return params;
}
- /*
- * @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getReturnType()
- */
@Override
public String getReturnType() {
return returnType;
@@ -232,8 +225,9 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (fileLocal == null) {
if (other.fileLocal != null)
return false;
- } else if (!fileLocal.equals(other.fileLocal))
+ } else if (!fileLocal.equals(other.fileLocal)) {
return false;
+ }
if (!Arrays.equals(fqn, other.fqn))
return false;
if (!Arrays.equals(params, other.params))
@@ -250,7 +244,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
@Override
public ITypeReference getResolvedReference() {
- if(reference==null) {
+ if (reference == null) {
if (elementType == ICElement.C_MACRO) {
return createMacroReference();
}
@@ -262,7 +256,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
try {
IIndexBinding[] ibs = findBindings();
- if(ibs.length>0) {
+ if (ibs.length > 0) {
IIndexName[] names;
names= index.findNames(ibs[0], IIndex.FIND_DEFINITIONS);
if (names.length == 0) {
@@ -275,8 +269,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
}
}
- } catch(CoreException ce) {
- CCorePlugin.log(ce);
+ } catch(CoreException e) {
+ CCorePlugin.log(e);
} finally {
index.releaseReadLock();
}
@@ -286,13 +280,14 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
private IIndexBinding[] findBindings() throws CoreException {
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();
+ }
IIndexBinding[] ibs = index.findBindings(cfqn, new IndexFilter() {
@Override
public boolean acceptBinding(IBinding binding) {
- if (!IndexModelUtil.bindingHasCElementType(binding, new int[]{elementType})) {
+ if (!IndexModelUtil.bindingHasCElementType(binding, new int[] {elementType})) {
return false;
}
try {
@@ -300,22 +295,19 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
if (((IIndexBinding) binding).isFileLocal()) {
return false;
}
- }
- else {
+ } else {
IIndexFile localToFile= ((IIndexBinding) binding).getLocalToFile();
if (localToFile == null || !fileLocal.equals(localToFile.getLocation())) {
return false;
}
}
if (binding instanceof IFunction && params != null) {
- String[]otherParams= IndexModelUtil.extractParameterTypes((IFunction)binding);
+ String[] otherParams= IndexModelUtil.extractParameterTypes((IFunction) binding);
if (!Arrays.equals(params, otherParams)) {
return false;
}
}
- } catch (CoreException e) {
- CCorePlugin.log(e);
- } catch (DOMException e) {
+ } catch (CoreException | DOMException e) {
CCorePlugin.log(e);
}
return true;
@@ -333,7 +325,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
try {
IIndexMacro[] macros = index.findMacros(fqn[0].toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
- if(macros.length>0) {
+ if (macros.length > 0) {
for (IIndexMacro macro : macros) {
reference= createReference(macro);
if (reference != null) {
@@ -341,8 +333,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
}
}
- } catch(CoreException ce) {
- CCorePlugin.log(ce);
+ } catch(CoreException e) {
+ CCorePlugin.log(e);
} finally {
index.releaseReadLock();
}
@@ -382,7 +374,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return getMacroReferences();
}
- List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
+ List<IndexTypeReference> references= new ArrayList<>();
try {
index.acquireReadLock();
} catch (InterruptedException ie) {
@@ -391,7 +383,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
try {
IIndexBinding[] ibs= findBindings();
- HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
+ HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<>();
for (IIndexBinding binding : ibs) {
IIndexName[] names;
names= index.findNames(binding, IIndex.FIND_DEFINITIONS);
@@ -415,9 +407,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
return references.toArray(new IndexTypeReference[references.size()]);
}
-
private ITypeReference[] getMacroReferences() {
- List<IndexTypeReference> references= new ArrayList<IndexTypeReference>();
+ List<IndexTypeReference> references= new ArrayList<>();
try {
index.acquireReadLock();
} catch (InterruptedException e) {
@@ -429,7 +420,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
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
// one of those, only.
- HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>();
+ HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<>();
for (IIndexMacro macro : ibs) {
if (checkParameters(macro.getParameterList())) {
if (checkFile(iflMap, macro.getFile())) {
@@ -440,8 +431,8 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
}
}
}
- } catch(CoreException ce) {
- CCorePlugin.log(ce);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
} finally {
index.releaseReadLock();
}
@@ -566,7 +557,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
throw new UnsupportedOperationException();
}
-
/**
* @deprecated
* @noreference This method is not intended to be referenced by clients.
@@ -588,7 +578,6 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
throw new UnsupportedOperationException();
}
-
/**
* @deprecated
* @noreference This method is not intended to be referenced by clients.
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java
index eeeb4b3d474..1df5c1a718f 100644
--- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java
+++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/internal/core/browser/IndexModelUtil.java
@@ -43,26 +43,27 @@ public class IndexModelUtil {
/**
* Returns whether the binding is of any of the specified CElement type constants
+ *
* @param binding
* @param kinds
* @return whether the binding is of any of the specified CElement type constants
*/
public static boolean bindingHasCElementType(IBinding binding, int[] kinds) {
for (int kind : kinds) {
- switch(kind) {
+ switch (kind) {
case ICElement.C_STRUCT:
if (binding instanceof ICompositeType
- && ((ICompositeType)binding).getKey() == ICompositeType.k_struct)
+ && ((ICompositeType) binding).getKey() == ICompositeType.k_struct)
return true;
break;
case ICElement.C_UNION:
if (binding instanceof ICompositeType
- && ((ICompositeType)binding).getKey() == ICompositeType.k_union)
+ && ((ICompositeType) binding).getKey() == ICompositeType.k_union)
return true;
break;
case ICElement.C_CLASS:
if (binding instanceof ICompositeType
- && ((ICompositeType)binding).getKey() == ICPPClassType.k_class)
+ && ((ICompositeType) binding).getKey() == ICPPClassType.k_class)
return true;
break;
case ICElement.C_NAMESPACE:

Back to the top