From 8ce322ad37f7b4938b203e2d884aeb25ecb4e200 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 21 Apr 2014 10:41:37 -0700 Subject: [PATCH] Cosmetics. --- .../cdt/core/parser/util/HashTable.java | 3 +-- .../AbstractCPPClassSpecializationScope.java | 5 ++-- .../core/dom/parser/cpp/CPPClassTemplate.java | 2 +- .../cdt/internal/core/pdom/db/Chunk.java | 4 +-- .../cdt/internal/core/pdom/db/Database.java | 20 +++++++------- .../core/pdom/dom/cpp/PDOMCPPClassScope.java | 27 ++++++++++--------- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/HashTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/HashTable.java index d884ba5e140..7484ecee46f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/HashTable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/HashTable.java @@ -8,7 +8,6 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.core.parser.util; import java.util.Comparator; @@ -24,7 +23,7 @@ public class HashTable implements Cloneable { return currEntry == -1; } - final public int size() { + public final int size() { return currEntry + 1; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java index 068e56c8d96..09f0f95235a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java @@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; * For safe usage in index bindings, all fields need to be final or volatile. */ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializationScope { - final private ICPPClassSpecialization specialClass; + private final ICPPClassSpecialization specialClass; private volatile ICPPBase[] fBases; // Used by the pdom bindings, needs to be volatile. public AbstractCPPClassSpecializationScope(ICPPClassSpecialization specialization) { @@ -79,7 +79,8 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat ICPPClassType specialized = specialClass.getSpecializedBinding(); IScope classScope = specialized.getCompositeScope(); - IBinding[] bindings = classScope != null ? classScope.getBindings(new ScopeLookupData(name, resolve, false)) : null; + IBinding[] bindings = classScope != null ? + classScope.getBindings(new ScopeLookupData(name, resolve, false)) : null; if (bindings == null) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index 3b56410dd6b..dc04f2b9a31 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -87,7 +87,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass while (parent instanceof IASTName) parent = parent.getParent(); if (parent instanceof ICPPASTCompositeTypeSpecifier) { - ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier)parent; + ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) parent; return compSpec.getScope(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java index a7d5e4ea432..3753c0744bc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java @@ -40,7 +40,7 @@ final class Chunk { void read() throws CoreException { try { final ByteBuffer buf= ByteBuffer.wrap(fBuffer); - fDatabase.read(buf, (long) fSequenceNumber*Database.CHUNK_SIZE); + fDatabase.read(buf, (long) fSequenceNumber * Database.CHUNK_SIZE); } catch (IOException e) { throw new CoreException(new DBStatus(e)); } @@ -49,7 +49,7 @@ final class Chunk { void flush() throws CoreException { try { final ByteBuffer buf= ByteBuffer.wrap(fBuffer); - fDatabase.write(buf, (long) fSequenceNumber*Database.CHUNK_SIZE); + fDatabase.write(buf, (long) fSequenceNumber * Database.CHUNK_SIZE); } catch (IOException e) { throw new CoreException(new DBStatus(e)); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java index eb73d630605..9d743880a00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java @@ -14,14 +14,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.db; -import com.ibm.icu.text.MessageFormat; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.util.NLS; - import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -32,6 +24,14 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.util.ArrayList; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.util.NLS; + +import com.ibm.icu.text.MessageFormat; + /** * Database encapsulates access to a flat binary format file with a memory-manager-like API for * obtaining and releasing areas of storage (memory). @@ -668,7 +668,7 @@ public class Database { public void giveUpExclusiveLock(final boolean flush) throws CoreException { if (fExclusiveLock) { try { - ArrayList dirtyChunks= new ArrayList(); + ArrayList dirtyChunks= new ArrayList<>(); synchronized (fCache) { for (int i= 1; i < fChunksUsed; i++) { Chunk chunk= fChunks[i]; @@ -716,7 +716,7 @@ public class Database { } // Be careful as other readers may access chunks concurrently. - ArrayList dirtyChunks= new ArrayList(); + ArrayList dirtyChunks= new ArrayList<>(); synchronized (fCache) { for (int i= 1; i < fChunksUsed ; i++) { Chunk chunk= fChunks[i]; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java index a3a8017e8da..f767b47d185 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassScope.java @@ -6,12 +6,12 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (QNX) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Andrew Ferguson (Symbian) - * Bryan Wilkinson (QNX) - * Sergey Prigogin (Google) - * Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion) + * Doug Schaefer (QNX) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) + * Bryan Wilkinson (QNX) + * Sergey Prigogin (Google) + * Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -60,6 +60,7 @@ import org.eclipse.core.runtime.CoreException; class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { private static final class PopulateMap implements IPDOMVisitor { private final CharArrayMap> fResult; + private PopulateMap(CharArrayMap> result) { fResult = result; } @@ -71,7 +72,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { final char[] nchars = binding.getNameCharArray(); List list= fResult.get(nchars); if (list == null) { - list= new ArrayList(); + list= new ArrayList<>(); fResult.put(nchars, list); } list.add(binding); @@ -126,7 +127,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { try { final char[] nameChars = name.getSimpleID(); if (CharArrayUtils.equals(fBinding.getNameCharArray(), nameChars)) { - //9.2 ... The class-name is also inserted into the scope of the class itself + // 9.2 ... The class-name is also inserted into the scope of the class itself return getClassNameBinding(); } @@ -165,7 +166,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { } return fBinding.getConstructors(); } - return new IBinding[] {getClassNameBinding()}; + return new IBinding[] { getClassNameBinding() }; } return getBindingsViaCache(fBinding, nameChars, IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE); } @@ -244,8 +245,8 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { CharArrayMap> map= cached == null ? null : cached.get(); if (map == null) { - // there is no cache, build it: - map= new CharArrayMap>(); + // There is no cache, build it: + map= new CharArrayMap<>(); IPDOMVisitor visitor= new PopulateMap(map); visitor.visit(ct); ct.acceptUncached(visitor); @@ -256,7 +257,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { @Override public IBinding[] find(String name) { - return CPPSemantics.findBindings( this, name, false ); + return CPPSemantics.findBindings(this, name, false); } @Override @@ -271,7 +272,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope { acceptViaCache(fBinding, methods, false); return methods.getMethods(); } catch (CoreException e) { - return new ICPPMethod[0]; + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } }