1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 02:36:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-06-02 15:35:47 -07:00
parent dd77e62e1a
commit 68d17bbd55
2 changed files with 20 additions and 19 deletions

View file

@ -65,6 +65,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
@ -245,13 +246,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
@Override @Override
public IInclude[] getIncludes() throws CModelException { public IInclude[] getIncludes() throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>(); ArrayList<ICElement> includes = new ArrayList<>();
for (ICElement celement : celements) { for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_INCLUDE) { if (celement.getElementType() == ICElement.C_INCLUDE) {
aList.add(celement); includes.add(celement);
} }
} }
return aList.toArray(new IInclude[0]); return includes.toArray(new IInclude[includes.size()]);
} }
@Override @Override
@ -273,13 +274,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
@Override @Override
public IUsing[] getUsings() throws CModelException { public IUsing[] getUsings() throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>(); ArrayList<ICElement> usings = new ArrayList<>();
for (ICElement celement : celements) { for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_USING) { if (celement.getElementType() == ICElement.C_USING) {
aList.add(celement); usings.add(celement);
} }
} }
return aList.toArray(new IUsing[0]); return usings.toArray(new IUsing[usings.size()]);
} }
@Override @Override
@ -314,13 +315,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
@Override @Override
public INamespace[] getNamespaces() throws CModelException { public INamespace[] getNamespaces() throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
ArrayList<ICElement> elementList = new ArrayList<ICElement>(); ArrayList<ICElement> namespaces = new ArrayList<>();
for (ICElement celement : celements) { for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_NAMESPACE) { if (celement.getElementType() == ICElement.C_NAMESPACE) {
elementList.add(celement); namespaces.add(celement);
} }
} }
return elementList.toArray(new INamespace[0]); return namespaces.toArray(new INamespace[namespaces.size()]);
} }
protected void setLocationURI(URI loc) { protected void setLocationURI(URI loc) {
@ -470,7 +471,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
IBuffer buffer = this.getBuffer(); IBuffer buffer = this.getBuffer();
return buffer == null ? null : buffer.getCharacters(); return buffer == null ? null : buffer.getCharacters();
} catch (CModelException e) { } catch (CModelException e) {
return new char[0]; return CharArrayUtils.EMPTY_CHAR_ARRAY;
} }
} }
@ -611,9 +612,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
InputStream stream= null; InputStream stream= null;
try { try {
stream = new FileInputStream(file); stream = new FileInputStream(file);
buffer.setContents(Util.getInputStreamAsCharArray(stream, (int)file.length(), null)); buffer.setContents(Util.getInputStreamAsCharArray(stream, (int) file.length(), null));
} catch (IOException e) { } catch (IOException e) {
buffer.setContents(new char[0]); buffer.setContents(CharArrayUtils.EMPTY_CHAR_ARRAY);
} finally { } finally {
if (stream != null) { if (stream != null) {
try { try {
@ -623,7 +624,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
} }
} else { } else {
buffer.setContents(new char[0]); buffer.setContents(CharArrayUtils.EMPTY_CHAR_ARRAY);
} }
} }
} }
@ -942,7 +943,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
public static IIndexFile getParsedInContext(IIndexFile indexFile) throws CoreException { public static IIndexFile getParsedInContext(IIndexFile indexFile) throws CoreException {
HashSet<IIndexFile> visited= new HashSet<IIndexFile>(); HashSet<IIndexFile> visited= new HashSet<>();
// Bug 199412, may recurse. // Bug 199412, may recurse.
while (visited.add(indexFile)) { while (visited.add(indexFile)) {
IIndexInclude include= indexFile.getParsedInContext(); IIndexInclude include= indexFile.getParsedInContext();
@ -1109,7 +1110,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
// optional: parameters // optional: parameters
String[] mementoParams= {}; String[] mementoParams= {};
if (memento.hasMoreTokens()) { if (memento.hasMoreTokens()) {
List<String> params= new ArrayList<String>(); List<String> params= new ArrayList<>();
do { do {
token= memento.nextToken(); token= memento.nextToken();
if (token.charAt(0) != CEM_PARAMETER) { if (token.charAt(0) != CEM_PARAMETER) {

View file

@ -59,7 +59,7 @@ public class CRenameProcessor extends RenameProcessor {
private final CRefactory fManager; private final CRefactory fManager;
private final ASTManager fAstManager; private final ASTManager fAstManager;
private IIndex fIndex; private IIndex fIndex;
private int indexLockCount; private int fIndexLockCount;
private RefactoringStatus fInitialConditionsStatus; private RefactoringStatus fInitialConditionsStatus;
private Change fChange; private Change fChange;
@ -303,7 +303,7 @@ public class CRenameProcessor extends RenameProcessor {
} }
public void lockIndex() throws CoreException, InterruptedException { public void lockIndex() throws CoreException, InterruptedException {
if (indexLockCount == 0) { if (fIndexLockCount == 0) {
if (fIndex == null) { if (fIndex == null) {
ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects(); ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
fIndex = CCorePlugin.getIndexManager().getIndex(projects, fIndex = CCorePlugin.getIndexManager().getIndex(projects,
@ -311,11 +311,11 @@ public class CRenameProcessor extends RenameProcessor {
} }
fIndex.acquireReadLock(); fIndex.acquireReadLock();
} }
indexLockCount++; fIndexLockCount++;
} }
public void unlockIndex() { public void unlockIndex() {
if (--indexLockCount <= 0) { if (--fIndexLockCount <= 0) {
if (fAstManager != null) { if (fAstManager != null) {
fAstManager.dispose(); fAstManager.dispose();
} }