1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-03-21 11:38:29 -07:00
parent 2ac9121791
commit 51e56e5a8b
9 changed files with 40 additions and 35 deletions

View file

@ -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;

View file

@ -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() {

View file

@ -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;
}

View file

@ -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();
}

View file

@ -26,7 +26,7 @@ public interface IIndexFragmentInclude extends IIndexInclude {
IIndexFragment getFragment();
/**
* Returns the file that is included by this include. May return <code>null</code> 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;

View file

@ -69,7 +69,7 @@ abstract class LocationCtx implements ILocationCtx {
* child-contexts behind the given offset, you need to set checkChildren to <code>true</code>.
*/
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<IASTNodeLocation> sofar);
public abstract void collectLocations(int sequenceNumber, int length,
ArrayList<IASTNodeLocation> sofar);
/**
* Support for the dependency tree, add inclusion statements found in this context.

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
/**
* Base class for all location contexts that can contain children.
* <p>
*
* @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;

View file

@ -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);

View file

@ -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<Task> tasks = new ArrayList<Task>();
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);