1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-12-30 13:17:36 -08:00
parent 0dc04bfd99
commit 613cb84eef
26 changed files with 235 additions and 255 deletions

View file

@ -6,11 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* An image location explains how a name made it into the translation unit.
* @since 5.0
@ -19,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTImageLocation extends IASTFileLocation {
/**
* The image is part of the code that has not been modified by the preprocessor.
*/
@ -34,8 +32,8 @@ public interface IASTImageLocation extends IASTFileLocation {
final int ARGUMENT_TO_MACRO_EXPANSION= 3;
/**
* Returns the kind of image-location, one of {@link #REGULAR_CODE}, {@link #MACRO_DEFINITION} or
* {@link #ARGUMENT_TO_MACRO_EXPANSION}.
* Returns the kind of image-location, one of {@link #REGULAR_CODE}, {@link #MACRO_DEFINITION}
* or {@link #ARGUMENT_TO_MACRO_EXPANSION}.
*/
public int getLocationKind();
}

View file

@ -57,7 +57,7 @@ public interface IASTName extends IASTNode, IName {
/**
* Get the role of this name. If the name needs to be resolved to determine that and
* <code>allowResolution</code> is set to <code>false</code>, then {@link IASTNameOwner#r_unclear}
* {@code allowResolution} is set to {@code false}, then {@link IASTNameOwner#r_unclear}
* is returned.
*
* @param allowResolution whether or not resolving the name is allowed.
@ -80,21 +80,24 @@ public interface IASTName extends IASTNode, IName {
public ILinkage getLinkage();
/**
* Returns the image location for this name or <code>null</code> if the information is not available.
* Returns the image location for this name or <code>null</code> if the information is not
* available.
* <p>
* An image location can be computed when the name is either found directly in the code, is (part of)
* an argument to a macro expansion or is (part of) a macro definition found in the source code.
* An image location can be computed when the name is either found directly in the code, is
* (part of) an argument to a macro expansion or is (part of) a macro definition found in
* the source code.
* <p>
* The image location is <code>null</code>, when the name consists of multiple tokens (qualified names)
* and the tokens are not found side by side in the code, or if the name is the result of
* a token-paste operation or the name is found in the definition of a built-in macro.
* The image location is <code>null</code>, when the name consists of multiple tokens
* (qualified names) and the tokens are not found side by side in the code, or if the name is
* the result of a token-paste operation or the name is found in the definition of a built-in
* macro.
* @since 5.0
*/
public IASTImageLocation getImageLocation();
/**
* For convenience this method returns the last name of a qualified name or this if this is not a
* qualified name.
* For convenience this method returns the last name of a qualified name or this if this is not
* a qualified name.
* @since 5.1
*/
public IASTName getLastName();

View file

@ -27,19 +27,20 @@ public interface IASTNodeSelector {
IASTName findName(int offset, int length);
/**
* Returns the smallest name enclosing the given range, or <code>null</code> if there is no such node.
* Will not return an implicit name.
* Returns the smallest name enclosing the given range, or <code>null</code> if there is
* no such node. Will not return an implicit name.
*/
IASTName findEnclosingName(int offset, int length);
/**
* Returns the first name contained in the given range, or <code>null</code> if there is no such node.
* Will not return an implicit name.
* Returns the first name contained in the given range, or <code>null</code> if there is
* no such node. Will not return an implicit name.
*/
IASTName findFirstContainedName(int offset, int length);
/**
* Returns the implicit name for the exact given range, or <code>null</code> if there is no such node.
* Returns the implicit name for the exact given range, or <code>null</code> if there is
* no such node.
*
* Note that there can be more than one implicit name in the same location.
* The implicit name's parent can be used to get all the names at the location.
@ -61,41 +62,45 @@ public interface IASTNodeSelector {
/**
* Returns the node for the exact given range, or <code>null</code> if there is no such node.
* <p>
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
* over c/c++-nodes and children are preferred over their parents.
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
* are preferred over c/c++-nodes and children are preferred over their parents.
*/
IASTNode findNode(int offset, int length);
/**
* Returns the smallest node enclosing the given range, or <code>null</code> if there is no such node.
* Returns the smallest node enclosing the given range, or <code>null</code> if there is
* no such node.
* <p>
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
* over c/c++-nodes nodes and children are preferred over their parents.
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
* are preferred over c/c++-nodes nodes and children are preferred over their parents.
*/
IASTNode findEnclosingNode(int offset, int length);
/**
* Returns the smallest node strictly enclosing the given range, or <code>null</code> if there is no such node.
* Returns the smallest node strictly enclosing the given range, or <code>null</code> if there
* is no such node.
* <p>
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
* over c/c++-nodes nodes and children are preferred over their parents.
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
* are preferred over c/c++-nodes nodes and children are preferred over their parents.
* @since 5.3
*/
IASTNode findStrictlyEnclosingNode(int offset, int length);
/**
* Returns the first node contained in the given range, or <code>null</code> if there is no such node.
* Returns the first node contained in the given range, or <code>null</code> if there is
* no such node.
* <p>
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
* over c/c++-nodes nodes and children are preferred over their parents.
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
* are preferred over c/c++-nodes nodes and children are preferred over their parents.
*/
IASTNode findFirstContainedNode(int offset, int length);
/**
* Returns the node for the exact given range, or <code>null</code> if there is no such node.
* <p>
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or the name for
* an expansion. Rather than that the expansion itself is searched for a matching node.
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or
* the name for an expansion. Rather than that the expansion itself is searched for a matching
* node.
* @since 5.1
*/
IASTNode findNodeInExpansion(int offset, int length);
@ -103,17 +108,20 @@ public interface IASTNodeSelector {
/**
* Returns the smallest node enclosing the range, or <code>null</code> if there is no such node.
* <p>
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or the name for
* an expansion. Rather than that the expansion itself is searched for a matching node.
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or
* the name for an expansion. Rather than that the expansion itself is searched for a matching
* node.
* @since 5.1
*/
IASTNode findEnclosingNodeInExpansion(int offset, int length);
/**
* Returns the first node contained in the given expansion, or <code>null</code> if there is no such node.
* Returns the first node contained in the given expansion, or <code>null</code> if there is
* no such node.
* <p>
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or the name for
* an expansion. Rather than that the expansion itself is searched for a matching node.
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or
* the name for an expansion. Rather than that the expansion itself is searched for a matching
* node.
* @since 5.1
*/
IASTNode findFirstContainedNodeInExpansion(int offset, int length);

View file

@ -6,18 +6,17 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* John Camelon (IBM Rational Software) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* This node represents a null statement. ';'
* This node represents a null statement, ';'
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTNullStatement extends IASTStatement {
/**
* @since 5.1
*/

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -20,9 +20,9 @@ package org.eclipse.cdt.core.dom.ast;
public interface IASTPreprocessorMacroExpansion extends IASTNode {
public static final IASTPreprocessorMacroExpansion[] EMPTY_ARRAY = {};
public static final ASTNodeProperty EXPANSION_NAME=
new ASTNodeProperty("IASTPreprocessorMacroExpansion.EXPANSION_NAME - macro name"); //$NON-NLS-1$
new ASTNodeProperty("IASTPreprocessorMacroExpansion.EXPANSION_NAME - macro name"); //$NON-NLS-1$
public static final ASTNodeProperty NESTED_EXPANSION_NAME=
new ASTNodeProperty("IASTPreprocessorMacroExpansion.NESTED_EXPANSION_NAME - nested macro name"); //$NON-NLS-1$
new ASTNodeProperty("IASTPreprocessorMacroExpansion.NESTED_EXPANSION_NAME - nested macro name"); //$NON-NLS-1$
/**
* Returns the macro definition used for the expansion.

View file

@ -254,24 +254,22 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi
/**
* Return the set of files that have been skipped because they have been part of the index
* prior to creating this AST, or <code>null</code> if not available.
* Applies only, if AST was created with an index and the option to skip headers found in the
* index.
* Applies only, if AST was created with an index and the option to skip headers found in
* the index.
* @since 5.1
*/
IIndexFileSet getIndexFileSet();
/**
* Return the set of files in the index that are superseded by this AST,
* or <code>null</code> if not available.
* Applies only, if AST was created with an index.
* Return the set of files in the index that are superseded by this AST, or <code>null</code>
* if not available. Applies only, if AST was created with an index.
* @since 5.3
*/
IIndexFileSet getASTFileSet();
/**
* In case the AST was created in a way that supports comment parsing,
* all comments of the translation unit are returned. Otherwise an
* empty array will be supplied.
* In case the AST was created in a way that supports comment parsing, all comments of
* the translation unit are returned. Otherwise an empty array will be supplied.
*
* @return <code>IASTComment[]</code>
* @since 4.0

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
/**
@ -18,7 +17,6 @@ package org.eclipse.cdt.internal.core.parser.scanner;
* @since 5.0
*/
public interface ILocationCtx {
/**
* If this is a file context the filename of this context is returned,
* otherwise the filename of the first enclosing context that is a file context is returned.

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
@ -23,20 +23,19 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.internal.core.dom.parser.ASTNodeSpecification;
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
/**
* Interface between the ast and the location-resolver for resolving offsets.
* Interface between the AST and the location-resolver for resolving offsets.
* @since 5.0
*/
public interface ILocationResolver {
/**
* Introduces the ast translation unit to the location resolver. Must be called before any tokens from the
* scanner are obtained.
* Introduces the AST translation unit to the location resolver. Must be called before any
* tokens from the scanner are obtained.
*/
void setRootNode(IASTTranslationUnit tu);
@ -103,15 +102,17 @@ public interface ILocationResolver {
/**
* Returns the smallest file location, that encloses the given global range. In case the range
* spans over multiple files, the files are mapped to include statements until all of them are
* found in the same file. So the resulting location contains the include directives that actually
* cause the range to be part of the AST.
* found in the same file. So the resulting location contains the include directives that
* actually cause the range to be part of the AST.
* @param offset sequence number as stored in the ASTNodes.
* @param length
*/
IASTFileLocation getMappedFileLocation(int offset, int length);
/**
* Returns an array of locations. This is a sequence of file locations and macro-expansion locations.
* Returns an array of locations. This is a sequence of file locations and macro-expansion
* locations.
*
* @param offset sequence number as stored in the ast nodes.
* @param length
* @return and array of locations.
@ -124,8 +125,8 @@ public interface ILocationResolver {
IASTImageLocation getImageLocation(int offset, int length);
/**
* Returns the sequence-number for the given file-path and offset, or <code>-1</code> if this file
* is not part of the translation-unit.
* Returns the sequence-number for the given file-path and offset, or <code>-1</code> if this
* file is not part of the translation-unit.
* @param filePath a file path or <code>null</code> to specify the root of the translation unit.
* @param fileOffset an offset into the source of the file, or <code>-1</code>.
*/
@ -158,7 +159,8 @@ public interface ILocationResolver {
boolean isPartOfSourceFile(int sequenceNumber);
/**
* Same as {@link #getMappedFileLocation(int, int)} for the given array of consecutive node locations.
* Same as {@link #getMappedFileLocation(int, int)} for the given array of consecutive node
* locations.
*/
IASTFileLocation flattenLocations(IASTNodeLocation[] nodeLocations);

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
@ -15,13 +15,13 @@ import org.eclipse.cdt.core.dom.ast.IASTImageLocation;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
/**
* Information needed for computing image-locations. An image location exists for a name and describes where the name
* came from. This can be: source code, macro-expansion, parameter to macro-expansion or synthetic.
* Information needed for computing image-locations. An image location exists for a name and
* describes where the name came from. This can be: source code, macro-expansion, parameter to
* macro-expansion or synthetic.
*
* @since 5.0
*/
public abstract class ImageLocationInfo {
public static final ImageLocationInfo[] NO_LOCATION_INFOS= {};
int fTokenOffsetInExpansion= -1;
@ -33,6 +33,7 @@ public abstract class ImageLocationInfo {
private final ObjectStyleMacro fMacro;
private final int fOffset;
private final int fEndOffset;
public MacroImageLocationInfo(ObjectStyleMacro macro, int offset, int endOffset) {
fMacro= macro;
fOffset= offset;
@ -66,14 +67,16 @@ public abstract class ImageLocationInfo {
public static class ParameterImageLocationInfo extends ImageLocationInfo {
public int fSequenceNumber;
public int fSequenceEndNumber;
public ParameterImageLocationInfo(int sequenceNumber, int sequenceEndNumber) {
fSequenceNumber= sequenceNumber;
fSequenceEndNumber= sequenceEndNumber;
}
@Override
public IASTImageLocation createLocation(LocationMap lm, ImageLocationInfo upto) {
int sequenceEnd= ((ParameterImageLocationInfo) upto).fSequenceEndNumber;
IASTFileLocation loc= lm.getMappedFileLocation(fSequenceNumber, sequenceEnd-fSequenceNumber);
IASTFileLocation loc= lm.getMappedFileLocation(fSequenceNumber, sequenceEnd - fSequenceNumber);
if (loc != null) {
return new ASTImageLocation(IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION,
loc.getFileName(), loc.getNodeOffset(), loc.getNodeLength());

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;

View file

@ -7,7 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
import java.util.ArrayList;
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTIncl
/**
* Various location contexts which are suitable for interpreting local offsets. These offsets are
* converted in a global sequence-number to make all ast nodes comparable with each other.
* converted in a global sequence-number to make all AST nodes comparable with each other.
* @since 5.0
*/
abstract class LocationCtx implements ILocationCtx {
@ -29,11 +29,13 @@ abstract class LocationCtx implements ILocationCtx {
*/
final int fSequenceNumber;
/**
* The offset of the denotation of this context in the parent's source. This is no sequence number.
* The offset of the denotation of this context in the parent's source. This is no sequence
* number.
*/
final int fOffsetInParent;
/**
* The end-offset of the denotation of this context in the parent's source. This is no sequence number.
* The end-offset of the denotation of this context in the parent's source. This is no sequence
* number.
*/
final int fEndOffsetInParent;
@ -46,40 +48,41 @@ abstract class LocationCtx implements ILocationCtx {
parent.addChild(this);
}
}
@Override
public String getFilePath() {
return fParent.getFilePath();
}
@Override
final public ILocationCtx getParent() {
return fParent;
}
/**
* Returns the amount of sequence numbers occupied by this context including its children.
*/
public abstract int getSequenceLength();
/**
* Converts an offset within this context to the sequence number. In case there are child-contexts
* behind the given offset, you need to set checkChildren to <code>true</code>.
* Converts an offset within this context to the sequence number. In case there are
* 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;
}
/**
* When a child-context is finished it reports its total sequence length, such that offsets in this
* context can be converted to sequence numbers.
* When a child-context is finished it reports its total sequence length, such that offsets in
* this context can be converted to sequence numbers.
*/
public void addChildSequenceLength(int childLength) {
assert false;
}
/**
* Returns the line number for an offset within this context. Not all contexts support line numbers,
* so this may return 0.
* Returns the line number for an offset within this context. Not all contexts support line
* numbers, so this may return 0.
*/
public int getLineNumber(int offset) {
return 0;
@ -109,7 +112,7 @@ abstract class LocationCtx implements ILocationCtx {
}
/**
* Returns the minimal file location containing the specified sequence number range, assuming
* Returns the minimal file location containing the specified sequence number range, assuming
* that it is contained in this context.
*/
public ASTFileLocation findMappedFileLocation(int sequenceNumber, int length) {
@ -124,8 +127,8 @@ abstract class LocationCtx implements ILocationCtx {
}
/**
* Returns the sequence of file locations spanning the given range.
* Assumes that the range starts within this context.
* Returns the sequence of file locations spanning the given range.
* Assumes that the range starts within this context.
*/
public abstract boolean collectLocations(int sequenceNumber, int length, ArrayList<IASTNodeLocation> sofar);
@ -136,7 +139,8 @@ abstract class LocationCtx implements ILocationCtx {
}
/**
* Support for the dependency tree, returns inclusion statement that created this context, or <code>null</code>.
* Support for the dependency tree, returns inclusion statement that created this context,
* or <code>null</code>.
*/
@Override
public ASTInclusionStatement getInclusionStatement() {

View file

@ -35,7 +35,8 @@ class LocationCtxContainer extends LocationCtx {
private AbstractCharArray fSource;
private int[] fLineOffsets;
public LocationCtxContainer(LocationCtxContainer parent, AbstractCharArray source, int parentOffset, int parentEndOffset, int sequenceNumber) {
public LocationCtxContainer(LocationCtxContainer parent, AbstractCharArray source,
int parentOffset, int parentEndOffset, int sequenceNumber) {
super(parent, parentOffset, parentEndOffset, sequenceNumber);
fSource= source;
}

View file

@ -79,7 +79,7 @@ class LocationCtxMacroExpansion extends LocationCtx {
if (length == 0) {
return null;
}
final int end= offset+length;
final int end= offset + length;
int nextToCheck= offset;
ImageLocationInfo firstInfo= null;
ImageLocationInfo lastInfo= null;

View file

@ -152,7 +152,7 @@ public class MacroDefinitionParser {
if (length > 0) {
char[] lastParam= paramList[length-1];
final int lpl = lastParam.length;
switch(lpl) {
switch (lpl) {
case 0: case 1: case 2:
break;
case 3:
@ -258,7 +258,7 @@ public class MacroDefinitionParser {
fExpansionOffset= fExpansionEndOffset= candidate.getOffset();
loop: while(true) {
switch(candidate.getType()) {
switch (candidate.getType()) {
case IToken.tCOMPLETION:
throw new OffsetLimitReachedException(ORIGIN_PREPROCESSOR_DIRECTIVE, candidate);
case IToken.tEND_OF_INPUT:

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
@ -139,7 +139,8 @@ public class MacroExpander {
private ScannerContext fReportMacros;
private boolean fReportUndefined;
public MacroExpander(ILexerLog log, CharArrayMap<PreprocessorMacro> macroDictionary, LocationMap locationMap, LexerOptions lexOptions) {
public MacroExpander(ILexerLog log, CharArrayMap<PreprocessorMacro> macroDictionary,
LocationMap locationMap, LexerOptions lexOptions) {
fDictionary= macroDictionary;
fLocationMap= locationMap;
fDefinitionParser= new MacroDefinitionParser();
@ -185,7 +186,7 @@ public class MacroExpander {
result= expandAll(input, forbidden, protectDefined, null);
} catch (CompletionInMacroExpansionException e) {
// for content assist in macro expansions, we return the list of tokens of the
// For content assist in macro expansions, we return the list of tokens of the
// parameter at the current cursor position and hope that they make sense if
// they are inserted at the position of the expansion.
// For a better solution one would have to perform the expansion with artificial
@ -201,7 +202,8 @@ public class MacroExpander {
* Method for tracking macro expansions.
* @since 5.0
*/
public void expand(String beforeExpansion, MacroExpansionTracker tracker, String filePath, int lineNumber, boolean protectDefinedConstructs) {
public void expand(String beforeExpansion, MacroExpansionTracker tracker, String filePath,
int lineNumber, boolean protectDefinedConstructs) {
fImplicitMacroExpansions.clear();
fImageLocationInfos.clear();
fFixedInput= beforeExpansion.toCharArray();
@ -227,7 +229,8 @@ public class MacroExpander {
fStartOffset= identifier.getOffset();
fEndOffset= identifier.getEndOffset();
fCompletionMode= false;
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden= new IdentityHashMap<PreprocessorMacro, PreprocessorMacro>();
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden=
new IdentityHashMap<PreprocessorMacro, PreprocessorMacro>();
// setup input sequence
TokenSource input= new TokenSource(lexer);
@ -245,15 +248,15 @@ public class MacroExpander {
}
/**
* Expects that the identifier of the macro expansion has been consumed. Expands the macro consuming
* tokens from the input (to read the parameters) and stores the resulting tokens together
* with boundary markers in the result token list.
* Returns the last token of the expansion.
* Expects that the identifier of the macro expansion has been consumed. Expands the macro
* consuming tokens from the input (to read the parameters) and stores the resulting tokens
* together with boundary markers in the result token list.
* @return the last token of the expansion.
* @throws AbortMacroExpansionException
*/
private Token expandOne(Token lastConsumed, PreprocessorMacro macro,
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden, TokenSource input, TokenList result,
MacroExpansionTracker tracker)
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden, TokenSource input,
TokenList result, MacroExpansionTracker tracker)
throws OffsetLimitReachedException {
if (fReportMacros != null)
fReportMacros.significantMacro(macro);
@ -290,8 +293,8 @@ public class MacroExpander {
TokenList[] expandedArgs= new TokenList[paramCount];
for (int i = 0; i < paramCount; i++) {
final TokenSource argInput = argInputs[i];
final boolean needCopy= paramUsage.get(2*i);
final boolean needExpansion = paramUsage.get(2*i+1);
final boolean needCopy= paramUsage.get(2 * i);
final boolean needExpansion = paramUsage.get(2 * i + 1);
clonedArgs[i]= needCopy ? argInput.cloneTokens() : EMPTY_TOKEN_LIST;
expandedArgs[i]= needExpansion ? expandAll(argInput, forbidden, false, tracker) : EMPTY_TOKEN_LIST;
if (!needExpansion) {
@ -354,7 +357,7 @@ public class MacroExpander {
Token l= null;
Token t= input.removeFirst();
while(t != null) {
switch(t.getType()) {
switch (t.getType()) {
case CPreprocessor.tSCOPE_MARKER:
((ExpansionBoundary) t).execute(forbidden);
break;
@ -451,8 +454,10 @@ public class MacroExpander {
/**
* Expects that the identifier has been consumed.
*/
private Token parseArguments(TokenSource input, FunctionStyleMacro macro, IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden,
TokenSource[] result, MacroExpansionTracker tracker) throws OffsetLimitReachedException, AbortMacroExpansionException {
private Token parseArguments(TokenSource input, FunctionStyleMacro macro,
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden,
TokenSource[] result, MacroExpansionTracker tracker)
throws OffsetLimitReachedException, AbortMacroExpansionException {
final int argCount= macro.getParameterPlaceholderList().length;
final boolean hasVarargs= macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS;
final int requiredArgs= hasVarargs ? argCount-1 : argCount;
@ -475,7 +480,7 @@ public class MacroExpander {
break loop;
}
if (tracker != null) {
switch(t.getType()) {
switch (t.getType()) {
case IToken.tEND_OF_INPUT:
case IToken.tCOMPLETION:
case CPreprocessor.tSCOPE_MARKER:
@ -487,7 +492,7 @@ public class MacroExpander {
}
}
lastToken= t;
switch(t.getType()) {
switch (t.getType()) {
case IToken.tEND_OF_INPUT:
assert nesting >= 0;
if (fCompletionMode) {
@ -564,7 +569,6 @@ public class MacroExpander {
isFirstOfArg= false;
}
if (missingRParenthesis) {
handleProblem(IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST, macro.getNameCharArray());
throw new AbortMacroExpansionException();
@ -572,7 +576,7 @@ public class MacroExpander {
if (tooManyArgs) {
handleProblem(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, macro.getNameCharArray());
} else if (idx+1 < requiredArgs) {
} else if (idx + 1 < requiredArgs) {
handleProblem(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, macro.getNameCharArray());
}
return lastToken;
@ -591,7 +595,7 @@ public class MacroExpander {
for (Token t= replacement.first(); t != null; l=t, t=n) {
n= (Token) t.getNext();
switch(t.getType()) {
switch (t.getType()) {
case CPreprocessor.tMACRO_PARAMETER:
int idx= ((TokenParameterReference) t).getIndex();
if (idx < args.length) { // be defensive
@ -750,7 +754,7 @@ public class MacroExpander {
}
private boolean isKind(final IToken t, final int kind) {
return t!=null && t.getType() == kind;
return t != null && t.getType() == kind;
}
private BitSet getParamUsage(PreprocessorMacro macro) {
@ -759,11 +763,11 @@ public class MacroExpander {
Token l= null;
Token n;
for (Token t= replacement.first(); t != null; l=t, t=n) {
for (Token t= replacement.first(); t != null; l= t, t= n) {
n= (Token) t.getNext();
switch(t.getType()) {
switch (t.getType()) {
case CPreprocessor.tMACRO_PARAMETER:
int idx= 2*((TokenParameterReference) t).getIndex();
int idx= 2 * ((TokenParameterReference) t).getIndex();
if (!isKind(n, IToken.tPOUNDPOUND)) {
idx++;
}
@ -773,7 +777,7 @@ public class MacroExpander {
case IToken.tPOUND:
if (isKind(n, CPreprocessor.tMACRO_PARAMETER)) {
idx= ((TokenParameterReference) n).getIndex();
result.set(2*idx);
result.set(2 * idx);
t= n; n= (Token) n.getNext();
}
break;
@ -783,10 +787,10 @@ public class MacroExpander {
idx= ((TokenParameterReference) n).getIndex();
// gcc-extension
if (isKind(l, IToken.tCOMMA) && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
idx == macro.getParameterPlaceholderList().length-1 && !isKind(n.getNext(), IToken.tPOUNDPOUND)) {
result.set(2*idx+1);
idx == macro.getParameterPlaceholderList().length - 1 && !isKind(n.getNext(), IToken.tPOUNDPOUND)) {
result.set(2 * idx + 1);
} else {
result.set(2*idx);
result.set(2 * idx);
}
t= n; n= (Token) n.getNext();
}
@ -802,10 +806,10 @@ public class MacroExpander {
Token l= null;
Token n;
Token pasteArg1= null;
for (Token t= replacement.first(); t != null; l=t, t=n) {
for (Token t= replacement.first(); t != null; l= t, t= n) {
n= (Token) t.getNext();
switch(t.getType()) {
switch (t.getType()) {
case IToken.tPOUNDPOUND:
if (pasteArg1 != null) {
Token pasteArg2= null;
@ -857,7 +861,7 @@ public class MacroExpander {
final char[] image2= arg2.getCharImage();
final int l1 = image1.length;
final int l2 = image2.length;
final char[] image= new char[l1+l2];
final char[] image= new char[l1 + l2];
System.arraycopy(image1, 0, image, 0, l1);
System.arraycopy(image2, 0, image, l1, l2);
Lexer lex= new Lexer(image, fLexOptions, ILexerLog.NULL, null);
@ -882,13 +886,13 @@ public class MacroExpander {
Token l= null;
Token n;
boolean space= false;
for (; t != null; l=t, t=n) {
for (; t != null; l= t, t= n) {
n= (Token) t.getNext();
if (!space && hasImplicitSpace(l, t)) {
buf.append(' ');
space= true;
}
switch(t.getType()) {
switch (t.getType()) {
case IToken.tSTRING:
case IToken.tLSTRING:
case IToken.tUTF16STRING:
@ -941,8 +945,8 @@ public class MacroExpander {
final boolean createImageLocations= fLexOptions.fCreateImageLocations;
int offset= 0;
Token l= null;
for (Token t= replacement.first(); t!=null; t= (Token) t.getNext()) {
switch(t.getType()) {
for (Token t= replacement.first(); t != null; t= (Token) t.getNext()) {
switch (t.getType()) {
case CPreprocessor.tEXPANDED_IDENTIFIER:
t.setType(IToken.tIDENTIFIER);
if (createImageLocations) {
@ -970,8 +974,8 @@ public class MacroExpander {
continue;
case IToken.tCOMPLETION:
// we need to preserve the length of the completion token.
t.setOffset(offset, offset+t.getLength());
// We need to preserve the length of the completion token.
t.setOffset(offset, offset + t.getLength());
t.setNext(null);
return;
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
@ -116,8 +116,7 @@ public class MacroExpansionTracker {
toString(result, lexInput, replacementText, replacementText, replacementText);
fPreStep= new String(lexInput);
fReplacement= new ReplaceEdit(0, endOffset, replacementText.toString());
}
else {
} else {
// the regular case the result contains the text before the step
StringBuilder before= new StringBuilder();
StringBuilder replace= new StringBuilder();
@ -142,7 +141,8 @@ public class MacroExpansionTracker {
fReplacement= new ReplaceEdit(0, 0, ""); //$NON-NLS-1$
}
private void toString(TokenList tokenList, char[] rootInput, StringBuilder before, StringBuilder replace, StringBuilder after) {
private void toString(TokenList tokenList, char[] rootInput, StringBuilder before,
StringBuilder replace, StringBuilder after) {
StringBuilder buf= before;
Token t= tokenList.first();
if (t == null) {
@ -150,17 +150,16 @@ public class MacroExpansionTracker {
}
Token l= null;
Token n;
for (; t != null; l=t, t=n) {
for (; t != null; l= t, t= n) {
n= (Token) t.getNext();
if (l != null && MacroExpander.hasImplicitSpace(l, t)) {
char[] input= getInputForSource(l.fSource, rootInput);
if (input == null) {
buf.append(' ');
}
else {
} else {
final int from = l.getEndOffset();
final int to = t.getOffset();
buf.append(input, from, to-from);
buf.append(input, from, to - from);
}
}
if (t == fReplaceFrom) {
@ -169,8 +168,7 @@ public class MacroExpansionTracker {
char[] input= getInputForSource(t.fSource, rootInput);
if (input == null) {
buf.append(t.getCharImage());
}
else {
} else {
buf.append(input, t.getOffset(), t.getLength());
}
if (t == fReplaceTo) {
@ -244,7 +242,7 @@ public class MacroExpansionTracker {
Token n;
Token l= null;
for (Token t = minfo.fMacroCall.first(); t != null; l=t, t=n) {
for (Token t = minfo.fMacroCall.first(); t != null; l= t, t= n) {
n = (Token) t.getNext();
switch (t.getType()) {
case IToken.tLPAREN:
@ -324,7 +322,8 @@ public class MacroExpansionTracker {
* @param replacement the replacement
* @param result a list to store the macro in.
*/
public void storeObjectStyleMacroReplacement(PreprocessorMacro macro, Token identifier, TokenList replacement, TokenList result) {
public void storeObjectStyleMacroReplacement(PreprocessorMacro macro, Token identifier,
TokenList replacement, TokenList result) {
fMacroDefinition= macro;
fReplaceFrom= fReplaceTo= identifier;
result.append(identifier);

View file

@ -31,9 +31,6 @@ public class Scanner extends SimpleScanner {
setSplitPreprocessor(false);
}
/*
* @see org.eclipse.cdt.internal.formatter.scanner.SimpleScanner#init(java.io.Reader, java.lang.String)
*/
@Override
protected void init(Reader reader, String filename) {
// not allowed
@ -148,7 +145,7 @@ public class Scanner extends SimpleScanner {
do {
getChar();
++diff;
} while(diff < 0);
} while (diff < 0);
} else if (diff == 0) {
// no-op
} else if (diff > fTokenBuffer.length()) {

View file

@ -51,7 +51,6 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
public class AbstractSemanticHighlightingTest extends TestCase {
protected static class SemanticHighlightingTestSetup extends TestSetup {
private ICProject fCProject;
private final String fTestFilename;
private File fExternalFile;

View file

@ -13,7 +13,6 @@
* Sergey Prigogin (Google)
* Tomasz Wesolowski
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
@ -27,7 +26,6 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
* @noextend This interface is not intended to be extended by clients.
*/
public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
/**
* Action definition ID of the source -> toggle comment action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.comment"</code>).

View file

@ -1,15 +1,14 @@
/*******************************************************************************
* Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
@ -42,12 +41,10 @@ import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
* @since 4.0
*/
public class SemanticHighlightingManager implements IPropertyChangeListener {
/**
* Highlighting style.
*/
public static class HighlightingStyle {
/** Text attribute */
private TextAttribute fTextAttribute;
/** Enabled state */
@ -96,7 +93,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* Highlighted Positions.
*/
public static class HighlightedPosition extends Position {
/** Highlighting of the position */
private HighlightingStyle fStyle;
@ -169,9 +165,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
}
/*
* @see org.eclipse.jface.text.Position#setLength(int)
*/
@Override
public void setLength(int length) {
synchronized (fLock) {
@ -179,9 +172,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
}
/*
* @see org.eclipse.jface.text.Position#setOffset(int)
*/
@Override
public void setOffset(int offset) {
synchronized (fLock) {
@ -189,9 +179,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
}
/*
* @see org.eclipse.jface.text.Position#delete()
*/
@Override
public void delete() {
synchronized (fLock) {
@ -199,9 +186,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
}
/*
* @see org.eclipse.jface.text.Position#undelete()
*/
@Override
public void undelete() {
synchronized (fLock) {
@ -314,14 +298,16 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
/**
* Install the semantic highlighting on the given source viewer infrastructure. No reconciliation will be performed.
* Installs the semantic highlighting on the given source viewer infrastructure.
* No reconciliation will be performed.
*
* @param sourceViewer the source viewer
* @param colorManager the color manager
* @param preferenceStore the preference store
* @param hardcodedRanges the hard-coded ranges to be highlighted
*/
public void install(CSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore, HighlightedRange[][] hardcodedRanges) {
public void install(CSourceViewer sourceViewer, IColorManager colorManager,
IPreferenceStore preferenceStore, HighlightedRange[][] hardcodedRanges) {
fHardcodedRanges= hardcodedRanges;
install(null, sourceViewer, colorManager, preferenceStore);
}
@ -383,7 +369,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
/**
* Uninstall the semantic highlighting
* Uninstalls the semantic highlighting
*/
public void uninstall() {
disable();
@ -402,7 +388,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
/**
* Disable semantic highlighting.
* Disables semantic highlighting.
*/
private void disable() {
if (fReconciler != null) {
@ -427,7 +413,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
/**
* Initialize semantic highlightings.
* Initializes semantic highlightings.
*/
protected void initializeHighlightings() {
fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
@ -460,7 +446,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
/**
* Dispose the semantic highlightings.
* Disposes the semantic highlightings.
*/
protected void disposeHighlightings() {
for (int i= 0, n= fSemanticHighlightings.length; i < n; i++)
@ -470,9 +456,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
fHighlightings= null;
}
/*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent event) {
handlePropertyChangeEvent(event);
@ -626,7 +609,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
}
/**
* Force refresh of highlighting.
* Forces refresh of highlighting.
*/
public void refresh() {
if (fReconciler != null) {

View file

@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
@ -37,7 +36,6 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.Highlighte
import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle;
import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
/**
* Semantic highlighting presenter - UI thread implementation.
* Cloned from JDT.
@ -45,12 +43,10 @@ import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
* @since 4.0
*/
public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener {
/**
* Semantic highlighting position updater.
*/
private class HighlightingPositionUpdater implements IPositionUpdater {
/** The position category. */
private final String fCategory;
@ -63,12 +59,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
fCategory= category;
}
/*
* @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
*/
@Override
public void update(DocumentEvent event) {
int eventOffset= event.getOffset();
int eventOldLength= event.getLength();
int eventEnd= eventOffset + eventOldLength;
@ -77,10 +69,10 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
Position[] positions= event.getDocument().getPositions(fCategory);
for (int i= 0; i != positions.length; i++) {
HighlightedPosition position= (HighlightedPosition) positions[i];
// Also update deleted positions because they get deleted by the background thread and removed/invalidated only in the UI runnable
// Also update deleted positions because they get deleted by the background
// thread and removed/invalidated only in the UI runnable.
// if (position.isDeleted())
// continue;
@ -88,18 +80,19 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
int length= position.getLength();
int end= offset + length;
if (offset > eventEnd)
if (offset > eventEnd) {
updateWithPrecedingEvent(position, event);
else if (end < eventOffset)
} else if (end < eventOffset) {
updateWithSucceedingEvent(position, event);
else if (offset <= eventOffset && end >= eventEnd)
} else if (offset <= eventOffset && end >= eventEnd) {
updateWithIncludedEvent(position, event);
else if (offset <= eventOffset)
} else if (offset <= eventOffset) {
updateWithOverEndEvent(position, event);
else if (end >= eventEnd)
} else if (end >= eventEnd) {
updateWithOverStartEvent(position, event);
else
} else {
updateWithIncludingEvent(position, event);
}
}
} catch (BadPositionCategoryException e) {
// ignore and return
@ -107,7 +100,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Update the given position with the given event. The event precedes the position.
* Updates the given position with the given event. The event precedes the position.
*
* @param position The position
* @param event The event
@ -121,7 +114,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Update the given position with the given event. The event succeeds the position.
* Updates the given position with the given event. The event succeeds the position.
*
* @param position The position
* @param event The event
@ -130,7 +123,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Update the given position with the given event. The event is included by the position.
* Updates the given position with the given event. The event is included by the position.
*
* @param position The position
* @param event The event
@ -151,9 +144,9 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
int includedLength= 0;
while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
includedLength++;
if (includedLength == eventNewLength)
if (includedLength == eventNewLength) {
position.setLength(length + deltaLength);
else {
} else {
int newLeftLength= eventOffset - offset + includedLength;
int excludedLength= eventNewLength;
@ -176,7 +169,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Update the given position with the given event. The event overlaps with the end of the position.
* Updates the given position with the given event. The event overlaps with the end of
* the position.
*
* @param position The position
* @param event The event
@ -194,7 +188,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Update the given position with the given event. The event overlaps with the start of the position.
* Updates the given position with the given event. The event overlaps with the start of
* the position.
*
* @param position The position
* @param event The event
@ -353,12 +348,14 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Invalidate the presentation of the positions based on the given added positions and the existing deleted positions.
* Also unregisters the deleted positions from the document and patches the positions of this presenter.
* Invalidates the presentation of the positions based on the given added positions and
* the existing deleted positions. Also unregisters the deleted positions from the document
* and patches the positions of this presenter.
* <p>
* NOTE: Indirectly called from background thread by UI runnable.
* </p>
* @param textPresentation the text presentation or <code>null</code>, if the presentation should computed in the UI thread
* @param textPresentation the text presentation or <code>null</code>, if the presentation
* should computed in the UI thread
* @param addedPositions the added positions
* @param removedPositions the removed positions
*/
@ -398,7 +395,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
HighlightedPosition position= null;
HighlightedPosition addedPosition= null;
for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length; i < n || position != null || j < m || addedPosition != null;) {
for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length;
i < n || position != null || j < m || addedPosition != null;) {
// loop variant: i + j < old(i + j)
// a) find the next non-deleted Position from the old list
@ -489,7 +487,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Insert the given position in <code>fPositions</code>, s.t. the offsets remain in linear order.
* Inserts the given position in <code>fPositions</code>, s.t. the offsets remain in linear order.
*
* @param position The position for insertion
*/
@ -540,13 +538,11 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
return j;
}
/*
* @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
*/
@Override
public void applyTextPresentation(TextPresentation textPresentation) {
IRegion region= textPresentation.getExtent();
int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
int i= computeIndexAtOffset(fPositions, region.getOffset());
int n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
if (n - i > 2) {
List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
for (; i < n; i++) {
@ -566,9 +562,6 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
}
/*
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
*/
@Override
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
setCanceled(true);
@ -576,25 +569,16 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
resetState();
}
/*
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
*/
@Override
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
manageDocument(newInput);
}
/*
* @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
*/
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
setCanceled(true);
}
/*
* @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
*/
@Override
public void documentChanged(DocumentEvent event) {
}
@ -664,7 +648,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
}
/**
* Uninstall this presenter.
* Uninstalls this presenter.
*/
public void uninstall() {
setCanceled(true);

View file

@ -81,7 +81,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
@Override
public int visit(IASTTranslationUnit tu) {
// visit macro definitions
// Visit macro definitions.
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
if (macroDef.isPartOfTranslationUnitFile()) {
@ -90,7 +90,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
fMinLocation= -1;
// visit macro expansions
// Visit macro expansions.
IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
if (macroExp.isPartOfTranslationUnitFile()) {
@ -104,7 +104,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
fMinLocation= -1;
// visit ordinary code
// Visit ordinary code.
return super.visit(tu);
}
@ -130,9 +130,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
return PROCESS_CONTINUE;
}
/*
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
*/
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
if (!namespace.isPartOfTranslationUnitFile()) {
@ -172,7 +169,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) {
if (node instanceof IASTName) {
addNameLocation((IASTName)node, fJobHighlightings[i]);
addNameLocation((IASTName) node, fJobHighlightings[i]);
} else {
addNodeLocation(node.getFileLocation(), fJobHighlightings[i]);
}
@ -197,14 +194,14 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
int offset= imageLocation.getNodeOffset();
if (offset >= fMinLocation) {
int length= imageLocation.getNodeLength();
if (offset > -1 && length > 0) {
if (offset >= 0 && length > 0) {
fMinLocation= offset + length;
addPosition(offset, length, highlightingStyle);
}
}
}
} else {
// Fallback in case no image location available
// Fallback in case no image location available.
IASTNodeLocation[] nodeLocations= name.getNodeLocations();
if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
addNodeLocation(nodeLocations[0], highlightingStyle);
@ -213,7 +210,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
/**
* Add the a location range for the given highlighting.
* Adds the a location range for the given highlighting.
*
* @param nodeLocation The node location
* @param highlighting The highlighting
@ -233,7 +230,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
/**
* Add a position with the given range and highlighting iff it does not exist already.
* Adds a position with the given range and highlighting iff it does not exist already.
*
* @param offset The range offset
* @param length The range length
@ -290,11 +287,20 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
*/
private boolean fIsReconciling= false;
/** The semantic highlighting presenter - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
/**
* The semantic highlighting presenter - cache for background thread, only valid during
* {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)}
*/
protected SemanticHighlightingPresenter fJobPresenter;
/** Semantic highlightings - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
/**
* Semantic highlightings - cache for background thread, only valid during
* {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)}
*/
protected SemanticHighlighting[] fJobSemanticHighlightings;
/** Highlightings - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
/**
* Highlightings - cache for background thread, only valid during
* {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)}
*/
private HighlightingStyle[] fJobHighlightings;
@Override
@ -304,7 +310,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
@Override
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
// Ensure at most one thread can be reconciling at any time
// Ensure at most one thread can be reconciling at any time.
synchronized (fReconcileLock) {
if (fIsReconciling)
return;
@ -359,7 +365,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
/**
* Start reconciling positions.
* Starts reconciling positions.
*/
protected void startReconcilingPositions() {
fJobPresenter.addAllPositions(fRemovedPositions);
@ -367,7 +373,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
/**
* Reconcile positions based on the AST.
* Reconciles positions based on the AST.
*
* @param ast the AST
* @param visitor the AST visitor
@ -392,7 +398,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
/**
* Update the presentation.
* Updates the presentation.
*
* @param textPresentation the text presentation
* @param addedPositions the added positions
@ -452,7 +458,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
}
/**
* Uninstalsl this reconciler from the editor
* Uninstalls this reconciler from the editor
*/
public void uninstall() {
if (fPresenter != null)

View file

@ -67,7 +67,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
* @since 4.0
*/
public class SemanticHighlightings {
private static final RGB RGB_BLACK = new RGB(0, 0, 0);
/**

View file

@ -29,7 +29,7 @@ public final class SemanticToken {
/** Binding */
private IBinding fBinding;
/** Is the binding resolved? */
private boolean fIsBindingResolved= false;
private boolean fIsBindingResolved;
/** AST root */
private IASTTranslationUnit fRoot;
@ -69,7 +69,7 @@ public final class SemanticToken {
}
/**
* Update this token with the given AST node.
* Updates this token with the given AST node.
* <p>
* NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
* </p>

View file

@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text;
import org.eclipse.jface.text.IDocument;
@ -17,7 +16,6 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.presentation.PresentationReconciler;
/**
* Presentation reconciler, adding functionality for operation without a viewer.
* Cloned from JDT.
@ -25,7 +23,6 @@ import org.eclipse.jface.text.presentation.PresentationReconciler;
* @since 4.0
*/
public class CPresentationReconciler extends PresentationReconciler {
/** Last used document */
private IDocument fLastDocument;