diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java index ab606fcd606..94175fac895 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerInfo.java @@ -11,14 +11,13 @@ *******************************************************************************/ package org.eclipse.cdt.core.testplugin; -import java.util.HashMap; +import java.util.Collections; import java.util.Map; import org.eclipse.cdt.core.parser.IExtendedScannerInfo; public class TestScannerInfo implements IExtendedScannerInfo { - private static final String[] EMPTY = new String[0]; - private static final Map EMPTY_MAP = new HashMap(0); + private static final String[] EMPTY = {}; private String[] fIncludes; private String[] fIncludeFiles; private String[] fMacroFiles; @@ -28,23 +27,27 @@ public class TestScannerInfo implements IExtendedScannerInfo { fIncludeFiles= includeFiles; fMacroFiles= macroFiles; } + @Override public Map getDefinedSymbols() { - return EMPTY_MAP; + return Collections.emptyMap(); } @Override public String[] getIncludePaths() { return fIncludes == null ? EMPTY : fIncludes; } + @Override public String[] getIncludeFiles() { return fIncludeFiles == null ? EMPTY: fIncludeFiles; } + @Override public String[] getLocalIncludePath() { return null; } + @Override public String[] getMacroFiles() { return fMacroFiles == null ? EMPTY: fMacroFiles; diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java index b6cb6705ec2..d1f0fbac1c0 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/TestScannerProvider.java @@ -18,10 +18,9 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.core.resources.IResource; public class TestScannerProvider extends AbstractCExtension implements IScannerInfoProvider { - - public static String[] sIncludes= null; - public static String[] sIncludeFiles= null; - public static String[] sMacroFiles= null; + public static String[] sIncludes; + public static String[] sIncludeFiles; + public static String[] sMacroFiles; public final static String SCANNER_ID = CTestPlugin.PLUGIN_ID + ".TestScanner"; public static void clear() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java index 5857fe00dbe..eae48674ff2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java @@ -153,16 +153,16 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements @Deprecated @Override public IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.parser.CodeReader reader, - IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, - IParserLogService log, int offset) throws CoreException { - return getCompletionNode(FileContent.adapt(reader), scanInfo, IncludeFileContentProvider - .adapt(fileCreator), index, log, offset); + IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, + IIndex index, IParserLogService log, int offset) throws CoreException { + return getCompletionNode(FileContent.adapt(reader), scanInfo, + IncludeFileContentProvider.adapt(fileCreator), index, log, offset); } @Override public IASTCompletionNode getCompletionNode(FileContent reader, IScannerInfo scanInfo, - IncludeFileContentProvider fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { - + IncludeFileContentProvider fileCreator, IIndex index, IParserLogService log, int offset) + throws CoreException { IScanner scanner= createScanner(reader, scanInfo, fileCreator, log); scanner.setContentAssistMode(offset); @@ -244,7 +244,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements @Override public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { - // use default model builder + // Use default model builder. return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java index e170a19afa0..c3d77948b91 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java @@ -24,16 +24,18 @@ import java.net.URI; */ public interface IIndexFileLocation { /** - * The URI of the indexed file - * @return the URI of the indexed file (non-null) + * The URI of the indexed file. + * + * @return the URI of the indexed file (non-{@code null}) */ public URI getURI(); /** - * Return the workspace relative path of the indexed file or null if the file - * is not in the workspace + * Returns the workspace relative path of the indexed file or {@code null} if the file + * is not in the workspace. + * * @return the workspace relative path of the file in the index, or null if the - * file is not in the workspace + * file is not in the workspace */ public String getFullPath(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java index f6c73bbc0fb..5d4f0d95a59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java @@ -26,7 +26,7 @@ public interface IIndexFragmentInclude extends IIndexInclude { IIndexFragment getFragment(); /** - * Returns the file that is included by this include. May return null in case + * Returns the file that is included by this include. May return {@code null} in case * the included file is not part of this fragment. */ IIndexFragmentFile getIncludes() throws CoreException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtx.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtx.java index 3c62af24107..24def9e728f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtx.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtx.java @@ -69,7 +69,7 @@ abstract class LocationCtx implements ILocationCtx { * child-contexts behind the given offset, you need to set checkChildren to true. */ public int getSequenceNumberForOffset(int offset, boolean checkChildren) { - return fSequenceNumber+offset; + return fSequenceNumber + offset; } /** @@ -130,7 +130,8 @@ abstract class LocationCtx implements ILocationCtx { * Returns the sequence of file locations spanning the given range. * Assumes that the range starts within this context. */ - public abstract void collectLocations(int sequenceNumber, int length, ArrayList sofar); + public abstract void collectLocations(int sequenceNumber, int length, + ArrayList sofar); /** * Support for the dependency tree, add inclusion statements found in this context. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java index 4e11a04c5fe..59a6f5c5c54 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationCtxContainer.java @@ -22,7 +22,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; /** * Base class for all location contexts that can contain children. - *

+ * * @since 5.0 */ class LocationCtxContainer extends LocationCtx { @@ -76,8 +76,8 @@ class LocationCtxContainer extends LocationCtx { if (checkChildren && fChildren != null) { for (int i= fChildren.size() - 1; i >= 0; i--) { final LocationCtx child= fChildren.get(i); - if (child.fEndOffsetInParent > offset) { // child was inserted behind the offset, adjust sequence number - result-= child.getSequenceLength(); + if (child.fEndOffsetInParent > offset) { // Child was inserted behind the offset, adjust sequence number + result -= child.getSequenceLength(); } else { return result; } @@ -88,14 +88,14 @@ class LocationCtxContainer extends LocationCtx { @Override public void addChildSequenceLength(int childLength) { - fChildSequenceLength+= childLength; + fChildSequenceLength += childLength; } @Override public final LocationCtx findSurroundingContext(int sequenceNumber, int length) { int testEnd= length > 1 ? sequenceNumber + length - 1 : sequenceNumber; final LocationCtx child= findChildLessOrEqualThan(sequenceNumber, false); - if (child != null && child.fSequenceNumber+child.getSequenceLength() > testEnd) { + if (child != null && child.fSequenceNumber + child.getSequenceLength() > testEnd) { return child.findSurroundingContext(sequenceNumber, length); } return this; @@ -105,7 +105,7 @@ class LocationCtxContainer extends LocationCtx { public final LocationCtxMacroExpansion findEnclosingMacroExpansion(int sequenceNumber, int length) { int testEnd= length > 1 ? sequenceNumber + length - 1 : sequenceNumber; final LocationCtx child= findChildLessOrEqualThan(sequenceNumber, true); - if (child != null && child.fSequenceNumber+child.getSequenceLength() > testEnd) { + if (child != null && child.fSequenceNumber + child.getSequenceLength() > testEnd) { return child.findEnclosingMacroExpansion(sequenceNumber, length); } return null; @@ -212,7 +212,7 @@ class LocationCtxContainer extends LocationCtx { LocationCtx child= fChildren.get(middle); int childSequenceNumber= child.fSequenceNumber; if (beforeReplacedChars) { - childSequenceNumber-= child.fEndOffsetInParent - child.fOffsetInParent; + childSequenceNumber -= child.fEndOffsetInParent - child.fOffsetInParent; } if (childSequenceNumber <= sequenceNumber) { lower= middle + 1; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java index fdcc094188a..4f27d33d3aa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/IndexerInputAdapter.java @@ -67,7 +67,7 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver { /** * Checks whether the given file should be indexed unconditionally. - * @param location The Location of the file. + * @param location the location of the file. * @return {@code true} if the file should be indexed unconditionally. */ public abstract boolean isIndexedUnconditionally(IIndexFileLocation location); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TodoTaskParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TodoTaskParser.java index eeffbe9ecc7..fb5a294a74f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TodoTaskParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TodoTaskParser.java @@ -8,7 +8,6 @@ * Contributors: * Sergey Prigogin (Google) - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.indexer; import java.util.ArrayList; @@ -20,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.internal.core.CharOperation; public class TodoTaskParser { - private static final Task[] EMPTY_TASK_ARRAY = new Task[0]; + private static final Task[] EMPTY_TASK_ARRAY = {}; private final char[][] tags; private final int[] priorities; @@ -58,11 +57,12 @@ public class TodoTaskParser { List tasks = new ArrayList(); for (IASTComment comment : comments) { IASTFileLocation location = comment.getFileLocation(); - if (location != null) { // be defensive, bug 213307 + if (location != null) { // Be defensive, bug 213307 final String fileName = location.getFileName(); final int nodeOffset = location.getNodeOffset(); final String key= fileName + ':' + nodeOffset; - // full indexer can yield duplicate comments, make sure to handle each comment only once (bug 287181) + // Full indexer can yield duplicate comments, make sure to handle each comment only + // once (bug 287181). if (locKeys.add(key)) { parse(comment.getComment(), fileName, nodeOffset, location.getStartingLineNumber(), tasks);