mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
0dc04bfd99
commit
613cb84eef
26 changed files with 235 additions and 255 deletions
|
@ -6,11 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An image location explains how a name made it into the translation unit.
|
* An image location explains how a name made it into the translation unit.
|
||||||
* @since 5.0
|
* @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.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTImageLocation extends IASTFileLocation {
|
public interface IASTImageLocation extends IASTFileLocation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The image is part of the code that has not been modified by the preprocessor.
|
* 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;
|
final int ARGUMENT_TO_MACRO_EXPANSION= 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the kind of image-location, one of {@link #REGULAR_CODE}, {@link #MACRO_DEFINITION} or
|
* Returns the kind of image-location, one of {@link #REGULAR_CODE}, {@link #MACRO_DEFINITION}
|
||||||
* {@link #ARGUMENT_TO_MACRO_EXPANSION}.
|
* or {@link #ARGUMENT_TO_MACRO_EXPANSION}.
|
||||||
*/
|
*/
|
||||||
public int getLocationKind();
|
public int getLocationKind();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* 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.
|
* is returned.
|
||||||
*
|
*
|
||||||
* @param allowResolution whether or not resolving the name is allowed.
|
* @param allowResolution whether or not resolving the name is allowed.
|
||||||
|
@ -80,21 +80,24 @@ public interface IASTName extends IASTNode, IName {
|
||||||
public ILinkage getLinkage();
|
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>
|
* <p>
|
||||||
* An image location can be computed when the name is either found directly in the code, is (part of)
|
* An image location can be computed when the name is either found directly in the code, is
|
||||||
* an argument to a macro expansion or is (part of) a macro definition found in the source code.
|
* (part of) an argument to a macro expansion or is (part of) a macro definition found in
|
||||||
|
* the source code.
|
||||||
* <p>
|
* <p>
|
||||||
* The image location is <code>null</code>, when the name consists of multiple tokens (qualified names)
|
* The image location is <code>null</code>, when the name consists of multiple tokens
|
||||||
* and the tokens are not found side by side in the code, or if the name is the result of
|
* (qualified names) and the tokens are not found side by side in the code, or if the name is
|
||||||
* a token-paste operation or the name is found in the definition of a built-in macro.
|
* the result of a token-paste operation or the name is found in the definition of a built-in
|
||||||
|
* macro.
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public IASTImageLocation getImageLocation();
|
public IASTImageLocation getImageLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For convenience this method returns the last name of a qualified name or this if this is not a
|
* For convenience this method returns the last name of a qualified name or this if this is not
|
||||||
* qualified name.
|
* a qualified name.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public IASTName getLastName();
|
public IASTName getLastName();
|
||||||
|
|
|
@ -27,19 +27,20 @@ public interface IASTNodeSelector {
|
||||||
IASTName findName(int offset, int length);
|
IASTName findName(int offset, int length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smallest name enclosing the given range, or <code>null</code> if there is no such node.
|
* Returns the smallest name enclosing the given range, or <code>null</code> if there is
|
||||||
* Will not return an implicit name.
|
* no such node. Will not return an implicit name.
|
||||||
*/
|
*/
|
||||||
IASTName findEnclosingName(int offset, int length);
|
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.
|
* Returns the first name contained in the given range, or <code>null</code> if there is
|
||||||
* Will not return an implicit name.
|
* no such node. Will not return an implicit name.
|
||||||
*/
|
*/
|
||||||
IASTName findFirstContainedName(int offset, int length);
|
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.
|
* 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.
|
* 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.
|
* Returns the node for the exact given range, or <code>null</code> if there is no such node.
|
||||||
* <p>
|
* <p>
|
||||||
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
|
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
|
||||||
* over c/c++-nodes and children are preferred over their parents.
|
* are preferred over c/c++-nodes and children are preferred over their parents.
|
||||||
*/
|
*/
|
||||||
IASTNode findNode(int offset, int length);
|
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>
|
* <p>
|
||||||
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
|
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
|
||||||
* over c/c++-nodes nodes and children are preferred over their parents.
|
* are preferred over c/c++-nodes nodes and children are preferred over their parents.
|
||||||
*/
|
*/
|
||||||
IASTNode findEnclosingNode(int offset, int length);
|
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>
|
* <p>
|
||||||
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
|
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
|
||||||
* over c/c++-nodes nodes and children are preferred over their parents.
|
* are preferred over c/c++-nodes nodes and children are preferred over their parents.
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
IASTNode findStrictlyEnclosingNode(int offset, int length);
|
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>
|
* <p>
|
||||||
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion}) are preferred
|
* For nodes with the same location, macro-expansions ({@link IASTPreprocessorMacroExpansion})
|
||||||
* over c/c++-nodes nodes and children are preferred over their parents.
|
* are preferred over c/c++-nodes nodes and children are preferred over their parents.
|
||||||
*/
|
*/
|
||||||
IASTNode findFirstContainedNode(int offset, int length);
|
IASTNode findFirstContainedNode(int offset, int length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the node for the exact given range, or <code>null</code> if there is no such node.
|
* Returns the node for the exact given range, or <code>null</code> if there is no such node.
|
||||||
* <p>
|
* <p>
|
||||||
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or the name for
|
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or
|
||||||
* an expansion. Rather than that the expansion itself is searched for a matching node.
|
* the name for an expansion. Rather than that the expansion itself is searched for a matching
|
||||||
|
* node.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
IASTNode findNodeInExpansion(int offset, int length);
|
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.
|
* Returns the smallest node enclosing the range, or <code>null</code> if there is no such node.
|
||||||
* <p>
|
* <p>
|
||||||
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or the name for
|
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or
|
||||||
* an expansion. Rather than that the expansion itself is searched for a matching node.
|
* the name for an expansion. Rather than that the expansion itself is searched for a matching
|
||||||
|
* node.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
IASTNode findEnclosingNodeInExpansion(int offset, int length);
|
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>
|
* <p>
|
||||||
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or the name for
|
* The method never returns a macro expansion ({@link IASTPreprocessorMacroExpansion}) or
|
||||||
* an expansion. Rather than that the expansion itself is searched for a matching node.
|
* the name for an expansion. Rather than that the expansion itself is searched for a matching
|
||||||
|
* node.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
IASTNode findFirstContainedNodeInExpansion(int offset, int length);
|
IASTNode findFirstContainedNodeInExpansion(int offset, int length);
|
||||||
|
|
|
@ -6,18 +6,17 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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;
|
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.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTNullStatement extends IASTStatement {
|
public interface IASTNullStatement extends IASTStatement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
public interface IASTPreprocessorMacroExpansion extends IASTNode {
|
public interface IASTPreprocessorMacroExpansion extends IASTNode {
|
||||||
public static final IASTPreprocessorMacroExpansion[] EMPTY_ARRAY = {};
|
public static final IASTPreprocessorMacroExpansion[] EMPTY_ARRAY = {};
|
||||||
public static final ASTNodeProperty EXPANSION_NAME=
|
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=
|
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.
|
* Returns the macro definition used for the expansion.
|
||||||
|
|
|
@ -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
|
* 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.
|
* 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
|
* Applies only, if AST was created with an index and the option to skip headers found in
|
||||||
* index.
|
* the index.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
IIndexFileSet getIndexFileSet();
|
IIndexFileSet getIndexFileSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the set of files in the index that are superseded by this AST,
|
* Return the set of files in the index that are superseded by this AST, or <code>null</code>
|
||||||
* or <code>null</code> if not available.
|
* if not available. Applies only, if AST was created with an index.
|
||||||
* Applies only, if AST was created with an index.
|
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
IIndexFileSet getASTFileSet();
|
IIndexFileSet getASTFileSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In case the AST was created in a way that supports comment parsing,
|
* In case the AST was created in a way that supports comment parsing, all comments of
|
||||||
* all comments of the translation unit are returned. Otherwise an
|
* the translation unit are returned. Otherwise an empty array will be supplied.
|
||||||
* empty array will be supplied.
|
|
||||||
*
|
*
|
||||||
* @return <code>IASTComment[]</code>
|
* @return <code>IASTComment[]</code>
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +17,6 @@ package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public interface ILocationCtx {
|
public interface ILocationCtx {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this is a file context the filename of this context is returned,
|
* 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.
|
* otherwise the filename of the first enclosing context that is a file context is returned.
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
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.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
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.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.dom.parser.ASTNodeSpecification;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
|
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
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public interface ILocationResolver {
|
public interface ILocationResolver {
|
||||||
/**
|
/**
|
||||||
* Introduces the ast translation unit to the location resolver. Must be called before any tokens from the
|
* Introduces the AST translation unit to the location resolver. Must be called before any
|
||||||
* scanner are obtained.
|
* tokens from the scanner are obtained.
|
||||||
*/
|
*/
|
||||||
void setRootNode(IASTTranslationUnit tu);
|
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
|
* 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
|
* 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
|
* found in the same file. So the resulting location contains the include directives that
|
||||||
* cause the range to be part of the AST.
|
* actually cause the range to be part of the AST.
|
||||||
* @param offset sequence number as stored in the ASTNodes.
|
* @param offset sequence number as stored in the ASTNodes.
|
||||||
* @param length
|
* @param length
|
||||||
*/
|
*/
|
||||||
IASTFileLocation getMappedFileLocation(int offset, int 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 offset sequence number as stored in the ast nodes.
|
||||||
* @param length
|
* @param length
|
||||||
* @return and array of locations.
|
* @return and array of locations.
|
||||||
|
@ -124,8 +125,8 @@ public interface ILocationResolver {
|
||||||
IASTImageLocation getImageLocation(int offset, int length);
|
IASTImageLocation getImageLocation(int offset, int length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sequence-number for the given file-path and offset, or <code>-1</code> if this file
|
* Returns the sequence-number for the given file-path and offset, or <code>-1</code> if this
|
||||||
* is not part of the translation-unit.
|
* 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 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>.
|
* @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);
|
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);
|
IASTFileLocation flattenLocations(IASTNodeLocation[] nodeLocations);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
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;
|
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
|
* Information needed for computing image-locations. An image location exists for a name and
|
||||||
* came from. This can be: source code, macro-expansion, parameter to macro-expansion or synthetic.
|
* describes where the name came from. This can be: source code, macro-expansion, parameter to
|
||||||
|
* macro-expansion or synthetic.
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public abstract class ImageLocationInfo {
|
public abstract class ImageLocationInfo {
|
||||||
|
|
||||||
public static final ImageLocationInfo[] NO_LOCATION_INFOS= {};
|
public static final ImageLocationInfo[] NO_LOCATION_INFOS= {};
|
||||||
|
|
||||||
int fTokenOffsetInExpansion= -1;
|
int fTokenOffsetInExpansion= -1;
|
||||||
|
@ -33,6 +33,7 @@ public abstract class ImageLocationInfo {
|
||||||
private final ObjectStyleMacro fMacro;
|
private final ObjectStyleMacro fMacro;
|
||||||
private final int fOffset;
|
private final int fOffset;
|
||||||
private final int fEndOffset;
|
private final int fEndOffset;
|
||||||
|
|
||||||
public MacroImageLocationInfo(ObjectStyleMacro macro, int offset, int endOffset) {
|
public MacroImageLocationInfo(ObjectStyleMacro macro, int offset, int endOffset) {
|
||||||
fMacro= macro;
|
fMacro= macro;
|
||||||
fOffset= offset;
|
fOffset= offset;
|
||||||
|
@ -66,14 +67,16 @@ public abstract class ImageLocationInfo {
|
||||||
public static class ParameterImageLocationInfo extends ImageLocationInfo {
|
public static class ParameterImageLocationInfo extends ImageLocationInfo {
|
||||||
public int fSequenceNumber;
|
public int fSequenceNumber;
|
||||||
public int fSequenceEndNumber;
|
public int fSequenceEndNumber;
|
||||||
|
|
||||||
public ParameterImageLocationInfo(int sequenceNumber, int sequenceEndNumber) {
|
public ParameterImageLocationInfo(int sequenceNumber, int sequenceEndNumber) {
|
||||||
fSequenceNumber= sequenceNumber;
|
fSequenceNumber= sequenceNumber;
|
||||||
fSequenceEndNumber= sequenceEndNumber;
|
fSequenceEndNumber= sequenceEndNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTImageLocation createLocation(LocationMap lm, ImageLocationInfo upto) {
|
public IASTImageLocation createLocation(LocationMap lm, ImageLocationInfo upto) {
|
||||||
int sequenceEnd= ((ParameterImageLocationInfo) upto).fSequenceEndNumber;
|
int sequenceEnd= ((ParameterImageLocationInfo) upto).fSequenceEndNumber;
|
||||||
IASTFileLocation loc= lm.getMappedFileLocation(fSequenceNumber, sequenceEnd-fSequenceNumber);
|
IASTFileLocation loc= lm.getMappedFileLocation(fSequenceNumber, sequenceEnd - fSequenceNumber);
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
return new ASTImageLocation(IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION,
|
return new ASTImageLocation(IASTImageLocation.ARGUMENT_TO_MACRO_EXPANSION,
|
||||||
loc.getFileName(), loc.getNodeOffset(), loc.getNodeLength());
|
loc.getFileName(), loc.getNodeOffset(), loc.getNodeLength());
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
|
|
@ -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
|
* 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
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
abstract class LocationCtx implements ILocationCtx {
|
abstract class LocationCtx implements ILocationCtx {
|
||||||
|
@ -29,11 +29,13 @@ abstract class LocationCtx implements ILocationCtx {
|
||||||
*/
|
*/
|
||||||
final int fSequenceNumber;
|
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;
|
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;
|
final int fEndOffsetInParent;
|
||||||
|
|
||||||
|
@ -56,30 +58,31 @@ abstract class LocationCtx implements ILocationCtx {
|
||||||
final public ILocationCtx getParent() {
|
final public ILocationCtx getParent() {
|
||||||
return fParent;
|
return fParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of sequence numbers occupied by this context including its children.
|
* Returns the amount of sequence numbers occupied by this context including its children.
|
||||||
*/
|
*/
|
||||||
public abstract int getSequenceLength();
|
public abstract int getSequenceLength();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an offset within this context to the sequence number. In case there are child-contexts
|
* Converts an offset within this context to the sequence number. In case there are
|
||||||
* behind the given offset, you need to set checkChildren to <code>true</code>.
|
* child-contexts behind the given offset, you need to set checkChildren to <code>true</code>.
|
||||||
*/
|
*/
|
||||||
public int getSequenceNumberForOffset(int offset, boolean checkChildren) {
|
public int getSequenceNumberForOffset(int offset, boolean checkChildren) {
|
||||||
return fSequenceNumber+offset;
|
return fSequenceNumber+offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a child-context is finished it reports its total sequence length, such that offsets in this
|
* When a child-context is finished it reports its total sequence length, such that offsets in
|
||||||
* context can be converted to sequence numbers.
|
* this context can be converted to sequence numbers.
|
||||||
*/
|
*/
|
||||||
public void addChildSequenceLength(int childLength) {
|
public void addChildSequenceLength(int childLength) {
|
||||||
assert false;
|
assert false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the line number for an offset within this context. Not all contexts support line numbers,
|
* Returns the line number for an offset within this context. Not all contexts support line
|
||||||
* so this may return 0.
|
* numbers, so this may return 0.
|
||||||
*/
|
*/
|
||||||
public int getLineNumber(int offset) {
|
public int getLineNumber(int offset) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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
|
@Override
|
||||||
public ASTInclusionStatement getInclusionStatement() {
|
public ASTInclusionStatement getInclusionStatement() {
|
||||||
|
|
|
@ -35,7 +35,8 @@ class LocationCtxContainer extends LocationCtx {
|
||||||
private AbstractCharArray fSource;
|
private AbstractCharArray fSource;
|
||||||
private int[] fLineOffsets;
|
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);
|
super(parent, parentOffset, parentEndOffset, sequenceNumber);
|
||||||
fSource= source;
|
fSource= source;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class LocationCtxMacroExpansion extends LocationCtx {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final int end= offset+length;
|
final int end= offset + length;
|
||||||
int nextToCheck= offset;
|
int nextToCheck= offset;
|
||||||
ImageLocationInfo firstInfo= null;
|
ImageLocationInfo firstInfo= null;
|
||||||
ImageLocationInfo lastInfo= null;
|
ImageLocationInfo lastInfo= null;
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class MacroDefinitionParser {
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
char[] lastParam= paramList[length-1];
|
char[] lastParam= paramList[length-1];
|
||||||
final int lpl = lastParam.length;
|
final int lpl = lastParam.length;
|
||||||
switch(lpl) {
|
switch (lpl) {
|
||||||
case 0: case 1: case 2:
|
case 0: case 1: case 2:
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -258,7 +258,7 @@ public class MacroDefinitionParser {
|
||||||
fExpansionOffset= fExpansionEndOffset= candidate.getOffset();
|
fExpansionOffset= fExpansionEndOffset= candidate.getOffset();
|
||||||
|
|
||||||
loop: while(true) {
|
loop: while(true) {
|
||||||
switch(candidate.getType()) {
|
switch (candidate.getType()) {
|
||||||
case IToken.tCOMPLETION:
|
case IToken.tCOMPLETION:
|
||||||
throw new OffsetLimitReachedException(ORIGIN_PREPROCESSOR_DIRECTIVE, candidate);
|
throw new OffsetLimitReachedException(ORIGIN_PREPROCESSOR_DIRECTIVE, candidate);
|
||||||
case IToken.tEND_OF_INPUT:
|
case IToken.tEND_OF_INPUT:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
@ -139,7 +139,8 @@ public class MacroExpander {
|
||||||
private ScannerContext fReportMacros;
|
private ScannerContext fReportMacros;
|
||||||
private boolean fReportUndefined;
|
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;
|
fDictionary= macroDictionary;
|
||||||
fLocationMap= locationMap;
|
fLocationMap= locationMap;
|
||||||
fDefinitionParser= new MacroDefinitionParser();
|
fDefinitionParser= new MacroDefinitionParser();
|
||||||
|
@ -185,7 +186,7 @@ public class MacroExpander {
|
||||||
|
|
||||||
result= expandAll(input, forbidden, protectDefined, null);
|
result= expandAll(input, forbidden, protectDefined, null);
|
||||||
} catch (CompletionInMacroExpansionException e) {
|
} 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
|
// parameter at the current cursor position and hope that they make sense if
|
||||||
// they are inserted at the position of the expansion.
|
// they are inserted at the position of the expansion.
|
||||||
// For a better solution one would have to perform the expansion with artificial
|
// 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.
|
* Method for tracking macro expansions.
|
||||||
* @since 5.0
|
* @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();
|
fImplicitMacroExpansions.clear();
|
||||||
fImageLocationInfos.clear();
|
fImageLocationInfos.clear();
|
||||||
fFixedInput= beforeExpansion.toCharArray();
|
fFixedInput= beforeExpansion.toCharArray();
|
||||||
|
@ -227,7 +229,8 @@ public class MacroExpander {
|
||||||
fStartOffset= identifier.getOffset();
|
fStartOffset= identifier.getOffset();
|
||||||
fEndOffset= identifier.getEndOffset();
|
fEndOffset= identifier.getEndOffset();
|
||||||
fCompletionMode= false;
|
fCompletionMode= false;
|
||||||
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden= new IdentityHashMap<PreprocessorMacro, PreprocessorMacro>();
|
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden=
|
||||||
|
new IdentityHashMap<PreprocessorMacro, PreprocessorMacro>();
|
||||||
|
|
||||||
// setup input sequence
|
// setup input sequence
|
||||||
TokenSource input= new TokenSource(lexer);
|
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
|
* Expects that the identifier of the macro expansion has been consumed. Expands the macro
|
||||||
* tokens from the input (to read the parameters) and stores the resulting tokens together
|
* consuming tokens from the input (to read the parameters) and stores the resulting tokens
|
||||||
* with boundary markers in the result token list.
|
* together with boundary markers in the result token list.
|
||||||
* Returns the last token of the expansion.
|
* @return the last token of the expansion.
|
||||||
* @throws AbortMacroExpansionException
|
* @throws AbortMacroExpansionException
|
||||||
*/
|
*/
|
||||||
private Token expandOne(Token lastConsumed, PreprocessorMacro macro,
|
private Token expandOne(Token lastConsumed, PreprocessorMacro macro,
|
||||||
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden, TokenSource input, TokenList result,
|
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden, TokenSource input,
|
||||||
MacroExpansionTracker tracker)
|
TokenList result, MacroExpansionTracker tracker)
|
||||||
throws OffsetLimitReachedException {
|
throws OffsetLimitReachedException {
|
||||||
if (fReportMacros != null)
|
if (fReportMacros != null)
|
||||||
fReportMacros.significantMacro(macro);
|
fReportMacros.significantMacro(macro);
|
||||||
|
@ -290,8 +293,8 @@ public class MacroExpander {
|
||||||
TokenList[] expandedArgs= new TokenList[paramCount];
|
TokenList[] expandedArgs= new TokenList[paramCount];
|
||||||
for (int i = 0; i < paramCount; i++) {
|
for (int i = 0; i < paramCount; i++) {
|
||||||
final TokenSource argInput = argInputs[i];
|
final TokenSource argInput = argInputs[i];
|
||||||
final boolean needCopy= paramUsage.get(2*i);
|
final boolean needCopy= paramUsage.get(2 * i);
|
||||||
final boolean needExpansion = paramUsage.get(2*i+1);
|
final boolean needExpansion = paramUsage.get(2 * i + 1);
|
||||||
clonedArgs[i]= needCopy ? argInput.cloneTokens() : EMPTY_TOKEN_LIST;
|
clonedArgs[i]= needCopy ? argInput.cloneTokens() : EMPTY_TOKEN_LIST;
|
||||||
expandedArgs[i]= needExpansion ? expandAll(argInput, forbidden, false, tracker) : EMPTY_TOKEN_LIST;
|
expandedArgs[i]= needExpansion ? expandAll(argInput, forbidden, false, tracker) : EMPTY_TOKEN_LIST;
|
||||||
if (!needExpansion) {
|
if (!needExpansion) {
|
||||||
|
@ -354,7 +357,7 @@ public class MacroExpander {
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token t= input.removeFirst();
|
Token t= input.removeFirst();
|
||||||
while(t != null) {
|
while(t != null) {
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case CPreprocessor.tSCOPE_MARKER:
|
case CPreprocessor.tSCOPE_MARKER:
|
||||||
((ExpansionBoundary) t).execute(forbidden);
|
((ExpansionBoundary) t).execute(forbidden);
|
||||||
break;
|
break;
|
||||||
|
@ -451,8 +454,10 @@ public class MacroExpander {
|
||||||
/**
|
/**
|
||||||
* Expects that the identifier has been consumed.
|
* Expects that the identifier has been consumed.
|
||||||
*/
|
*/
|
||||||
private Token parseArguments(TokenSource input, FunctionStyleMacro macro, IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden,
|
private Token parseArguments(TokenSource input, FunctionStyleMacro macro,
|
||||||
TokenSource[] result, MacroExpansionTracker tracker) throws OffsetLimitReachedException, AbortMacroExpansionException {
|
IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden,
|
||||||
|
TokenSource[] result, MacroExpansionTracker tracker)
|
||||||
|
throws OffsetLimitReachedException, AbortMacroExpansionException {
|
||||||
final int argCount= macro.getParameterPlaceholderList().length;
|
final int argCount= macro.getParameterPlaceholderList().length;
|
||||||
final boolean hasVarargs= macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS;
|
final boolean hasVarargs= macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS;
|
||||||
final int requiredArgs= hasVarargs ? argCount-1 : argCount;
|
final int requiredArgs= hasVarargs ? argCount-1 : argCount;
|
||||||
|
@ -475,7 +480,7 @@ public class MacroExpander {
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tEND_OF_INPUT:
|
case IToken.tEND_OF_INPUT:
|
||||||
case IToken.tCOMPLETION:
|
case IToken.tCOMPLETION:
|
||||||
case CPreprocessor.tSCOPE_MARKER:
|
case CPreprocessor.tSCOPE_MARKER:
|
||||||
|
@ -487,7 +492,7 @@ public class MacroExpander {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastToken= t;
|
lastToken= t;
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tEND_OF_INPUT:
|
case IToken.tEND_OF_INPUT:
|
||||||
assert nesting >= 0;
|
assert nesting >= 0;
|
||||||
if (fCompletionMode) {
|
if (fCompletionMode) {
|
||||||
|
@ -564,7 +569,6 @@ public class MacroExpander {
|
||||||
isFirstOfArg= false;
|
isFirstOfArg= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (missingRParenthesis) {
|
if (missingRParenthesis) {
|
||||||
handleProblem(IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST, macro.getNameCharArray());
|
handleProblem(IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST, macro.getNameCharArray());
|
||||||
throw new AbortMacroExpansionException();
|
throw new AbortMacroExpansionException();
|
||||||
|
@ -572,7 +576,7 @@ public class MacroExpander {
|
||||||
|
|
||||||
if (tooManyArgs) {
|
if (tooManyArgs) {
|
||||||
handleProblem(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, macro.getNameCharArray());
|
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());
|
handleProblem(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, macro.getNameCharArray());
|
||||||
}
|
}
|
||||||
return lastToken;
|
return lastToken;
|
||||||
|
@ -591,7 +595,7 @@ public class MacroExpander {
|
||||||
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();
|
n= (Token) t.getNext();
|
||||||
|
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case CPreprocessor.tMACRO_PARAMETER:
|
case CPreprocessor.tMACRO_PARAMETER:
|
||||||
int idx= ((TokenParameterReference) t).getIndex();
|
int idx= ((TokenParameterReference) t).getIndex();
|
||||||
if (idx < args.length) { // be defensive
|
if (idx < args.length) { // be defensive
|
||||||
|
@ -750,7 +754,7 @@ public class MacroExpander {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isKind(final IToken t, final int kind) {
|
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) {
|
private BitSet getParamUsage(PreprocessorMacro macro) {
|
||||||
|
@ -759,11 +763,11 @@ public class MacroExpander {
|
||||||
|
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token n;
|
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();
|
n= (Token) t.getNext();
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case CPreprocessor.tMACRO_PARAMETER:
|
case CPreprocessor.tMACRO_PARAMETER:
|
||||||
int idx= 2*((TokenParameterReference) t).getIndex();
|
int idx= 2 * ((TokenParameterReference) t).getIndex();
|
||||||
if (!isKind(n, IToken.tPOUNDPOUND)) {
|
if (!isKind(n, IToken.tPOUNDPOUND)) {
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@ -773,7 +777,7 @@ public class MacroExpander {
|
||||||
case IToken.tPOUND:
|
case IToken.tPOUND:
|
||||||
if (isKind(n, CPreprocessor.tMACRO_PARAMETER)) {
|
if (isKind(n, CPreprocessor.tMACRO_PARAMETER)) {
|
||||||
idx= ((TokenParameterReference) n).getIndex();
|
idx= ((TokenParameterReference) n).getIndex();
|
||||||
result.set(2*idx);
|
result.set(2 * idx);
|
||||||
t= n; n= (Token) n.getNext();
|
t= n; n= (Token) n.getNext();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -783,10 +787,10 @@ public class MacroExpander {
|
||||||
idx= ((TokenParameterReference) n).getIndex();
|
idx= ((TokenParameterReference) n).getIndex();
|
||||||
// gcc-extension
|
// gcc-extension
|
||||||
if (isKind(l, IToken.tCOMMA) && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
|
if (isKind(l, IToken.tCOMMA) && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
|
||||||
idx == macro.getParameterPlaceholderList().length-1 && !isKind(n.getNext(), IToken.tPOUNDPOUND)) {
|
idx == macro.getParameterPlaceholderList().length - 1 && !isKind(n.getNext(), IToken.tPOUNDPOUND)) {
|
||||||
result.set(2*idx+1);
|
result.set(2 * idx + 1);
|
||||||
} else {
|
} else {
|
||||||
result.set(2*idx);
|
result.set(2 * idx);
|
||||||
}
|
}
|
||||||
t= n; n= (Token) n.getNext();
|
t= n; n= (Token) n.getNext();
|
||||||
}
|
}
|
||||||
|
@ -802,10 +806,10 @@ public class MacroExpander {
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token n;
|
Token n;
|
||||||
Token pasteArg1= null;
|
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();
|
n= (Token) t.getNext();
|
||||||
|
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tPOUNDPOUND:
|
case IToken.tPOUNDPOUND:
|
||||||
if (pasteArg1 != null) {
|
if (pasteArg1 != null) {
|
||||||
Token pasteArg2= null;
|
Token pasteArg2= null;
|
||||||
|
@ -857,7 +861,7 @@ public class MacroExpander {
|
||||||
final char[] image2= arg2.getCharImage();
|
final char[] image2= arg2.getCharImage();
|
||||||
final int l1 = image1.length;
|
final int l1 = image1.length;
|
||||||
final int l2 = image2.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(image1, 0, image, 0, l1);
|
||||||
System.arraycopy(image2, 0, image, l1, l2);
|
System.arraycopy(image2, 0, image, l1, l2);
|
||||||
Lexer lex= new Lexer(image, fLexOptions, ILexerLog.NULL, null);
|
Lexer lex= new Lexer(image, fLexOptions, ILexerLog.NULL, null);
|
||||||
|
@ -882,13 +886,13 @@ public class MacroExpander {
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token n;
|
Token n;
|
||||||
boolean space= false;
|
boolean space= false;
|
||||||
for (; t != null; l=t, t=n) {
|
for (; t != null; l= t, t= n) {
|
||||||
n= (Token) t.getNext();
|
n= (Token) t.getNext();
|
||||||
if (!space && hasImplicitSpace(l, t)) {
|
if (!space && hasImplicitSpace(l, t)) {
|
||||||
buf.append(' ');
|
buf.append(' ');
|
||||||
space= true;
|
space= true;
|
||||||
}
|
}
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tSTRING:
|
case IToken.tSTRING:
|
||||||
case IToken.tLSTRING:
|
case IToken.tLSTRING:
|
||||||
case IToken.tUTF16STRING:
|
case IToken.tUTF16STRING:
|
||||||
|
@ -941,8 +945,8 @@ public class MacroExpander {
|
||||||
final boolean createImageLocations= fLexOptions.fCreateImageLocations;
|
final boolean createImageLocations= fLexOptions.fCreateImageLocations;
|
||||||
int offset= 0;
|
int offset= 0;
|
||||||
Token l= null;
|
Token l= null;
|
||||||
for (Token t= replacement.first(); t!=null; t= (Token) t.getNext()) {
|
for (Token t= replacement.first(); t != null; t= (Token) t.getNext()) {
|
||||||
switch(t.getType()) {
|
switch (t.getType()) {
|
||||||
case CPreprocessor.tEXPANDED_IDENTIFIER:
|
case CPreprocessor.tEXPANDED_IDENTIFIER:
|
||||||
t.setType(IToken.tIDENTIFIER);
|
t.setType(IToken.tIDENTIFIER);
|
||||||
if (createImageLocations) {
|
if (createImageLocations) {
|
||||||
|
@ -970,8 +974,8 @@ public class MacroExpander {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case IToken.tCOMPLETION:
|
case IToken.tCOMPLETION:
|
||||||
// we need to preserve the length of the completion token.
|
// We need to preserve the length of the completion token.
|
||||||
t.setOffset(offset, offset+t.getLength());
|
t.setOffset(offset, offset + t.getLength());
|
||||||
t.setNext(null);
|
t.setNext(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
@ -116,8 +116,7 @@ public class MacroExpansionTracker {
|
||||||
toString(result, lexInput, replacementText, replacementText, replacementText);
|
toString(result, lexInput, replacementText, replacementText, replacementText);
|
||||||
fPreStep= new String(lexInput);
|
fPreStep= new String(lexInput);
|
||||||
fReplacement= new ReplaceEdit(0, endOffset, replacementText.toString());
|
fReplacement= new ReplaceEdit(0, endOffset, replacementText.toString());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// the regular case the result contains the text before the step
|
// the regular case the result contains the text before the step
|
||||||
StringBuilder before= new StringBuilder();
|
StringBuilder before= new StringBuilder();
|
||||||
StringBuilder replace= new StringBuilder();
|
StringBuilder replace= new StringBuilder();
|
||||||
|
@ -142,7 +141,8 @@ public class MacroExpansionTracker {
|
||||||
fReplacement= new ReplaceEdit(0, 0, ""); //$NON-NLS-1$
|
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;
|
StringBuilder buf= before;
|
||||||
Token t= tokenList.first();
|
Token t= tokenList.first();
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
|
@ -150,17 +150,16 @@ public class MacroExpansionTracker {
|
||||||
}
|
}
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token n;
|
Token n;
|
||||||
for (; t != null; l=t, t=n) {
|
for (; t != null; l= t, t= n) {
|
||||||
n= (Token) t.getNext();
|
n= (Token) t.getNext();
|
||||||
if (l != null && MacroExpander.hasImplicitSpace(l, t)) {
|
if (l != null && MacroExpander.hasImplicitSpace(l, t)) {
|
||||||
char[] input= getInputForSource(l.fSource, rootInput);
|
char[] input= getInputForSource(l.fSource, rootInput);
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
buf.append(' ');
|
buf.append(' ');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
final int from = l.getEndOffset();
|
final int from = l.getEndOffset();
|
||||||
final int to = t.getOffset();
|
final int to = t.getOffset();
|
||||||
buf.append(input, from, to-from);
|
buf.append(input, from, to - from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (t == fReplaceFrom) {
|
if (t == fReplaceFrom) {
|
||||||
|
@ -169,8 +168,7 @@ public class MacroExpansionTracker {
|
||||||
char[] input= getInputForSource(t.fSource, rootInput);
|
char[] input= getInputForSource(t.fSource, rootInput);
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
buf.append(t.getCharImage());
|
buf.append(t.getCharImage());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
buf.append(input, t.getOffset(), t.getLength());
|
buf.append(input, t.getOffset(), t.getLength());
|
||||||
}
|
}
|
||||||
if (t == fReplaceTo) {
|
if (t == fReplaceTo) {
|
||||||
|
@ -244,7 +242,7 @@ public class MacroExpansionTracker {
|
||||||
|
|
||||||
Token n;
|
Token n;
|
||||||
Token l= null;
|
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();
|
n = (Token) t.getNext();
|
||||||
switch (t.getType()) {
|
switch (t.getType()) {
|
||||||
case IToken.tLPAREN:
|
case IToken.tLPAREN:
|
||||||
|
@ -324,7 +322,8 @@ public class MacroExpansionTracker {
|
||||||
* @param replacement the replacement
|
* @param replacement the replacement
|
||||||
* @param result a list to store the macro in.
|
* @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;
|
fMacroDefinition= macro;
|
||||||
fReplaceFrom= fReplaceTo= identifier;
|
fReplaceFrom= fReplaceTo= identifier;
|
||||||
result.append(identifier);
|
result.append(identifier);
|
||||||
|
|
|
@ -31,9 +31,6 @@ public class Scanner extends SimpleScanner {
|
||||||
setSplitPreprocessor(false);
|
setSplitPreprocessor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.internal.formatter.scanner.SimpleScanner#init(java.io.Reader, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void init(Reader reader, String filename) {
|
protected void init(Reader reader, String filename) {
|
||||||
// not allowed
|
// not allowed
|
||||||
|
@ -148,7 +145,7 @@ public class Scanner extends SimpleScanner {
|
||||||
do {
|
do {
|
||||||
getChar();
|
getChar();
|
||||||
++diff;
|
++diff;
|
||||||
} while(diff < 0);
|
} while (diff < 0);
|
||||||
} else if (diff == 0) {
|
} else if (diff == 0) {
|
||||||
// no-op
|
// no-op
|
||||||
} else if (diff > fTokenBuffer.length()) {
|
} else if (diff > fTokenBuffer.length()) {
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
||||||
public class AbstractSemanticHighlightingTest extends TestCase {
|
public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
|
|
||||||
protected static class SemanticHighlightingTestSetup extends TestSetup {
|
protected static class SemanticHighlightingTestSetup extends TestSetup {
|
||||||
|
|
||||||
private ICProject fCProject;
|
private ICProject fCProject;
|
||||||
private final String fTestFilename;
|
private final String fTestFilename;
|
||||||
private File fExternalFile;
|
private File fExternalFile;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Tomasz Wesolowski
|
* Tomasz Wesolowski
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
|
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.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
|
public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID of the source -> toggle comment action
|
* Action definition ID of the source -> toggle comment action
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.comment"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.comment"</code>).
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2012 IBM Corporation and others.
|
* Copyright (c) 2000, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -42,12 +41,10 @@ import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class SemanticHighlightingManager implements IPropertyChangeListener {
|
public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlighting style.
|
* Highlighting style.
|
||||||
*/
|
*/
|
||||||
public static class HighlightingStyle {
|
public static class HighlightingStyle {
|
||||||
|
|
||||||
/** Text attribute */
|
/** Text attribute */
|
||||||
private TextAttribute fTextAttribute;
|
private TextAttribute fTextAttribute;
|
||||||
/** Enabled state */
|
/** Enabled state */
|
||||||
|
@ -96,7 +93,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
* Highlighted Positions.
|
* Highlighted Positions.
|
||||||
*/
|
*/
|
||||||
public static class HighlightedPosition extends Position {
|
public static class HighlightedPosition extends Position {
|
||||||
|
|
||||||
/** Highlighting of the position */
|
/** Highlighting of the position */
|
||||||
private HighlightingStyle fStyle;
|
private HighlightingStyle fStyle;
|
||||||
|
|
||||||
|
@ -169,9 +165,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.Position#setLength(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setLength(int length) {
|
public void setLength(int length) {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
|
@ -179,9 +172,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.Position#setOffset(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setOffset(int offset) {
|
public void setOffset(int offset) {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
|
@ -189,9 +179,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.Position#delete()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
synchronized (fLock) {
|
synchronized (fLock) {
|
||||||
|
@ -199,9 +186,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.Position#undelete()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void undelete() {
|
public void undelete() {
|
||||||
synchronized (fLock) {
|
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 sourceViewer the source viewer
|
||||||
* @param colorManager the color manager
|
* @param colorManager the color manager
|
||||||
* @param preferenceStore the preference store
|
* @param preferenceStore the preference store
|
||||||
* @param hardcodedRanges the hard-coded ranges to be highlighted
|
* @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;
|
fHardcodedRanges= hardcodedRanges;
|
||||||
install(null, sourceViewer, colorManager, preferenceStore);
|
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() {
|
public void uninstall() {
|
||||||
disable();
|
disable();
|
||||||
|
@ -402,7 +388,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable semantic highlighting.
|
* Disables semantic highlighting.
|
||||||
*/
|
*/
|
||||||
private void disable() {
|
private void disable() {
|
||||||
if (fReconciler != null) {
|
if (fReconciler != null) {
|
||||||
|
@ -427,7 +413,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize semantic highlightings.
|
* Initializes semantic highlightings.
|
||||||
*/
|
*/
|
||||||
protected void initializeHighlightings() {
|
protected void initializeHighlightings() {
|
||||||
fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
|
fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
|
||||||
|
@ -460,7 +446,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose the semantic highlightings.
|
* Disposes the semantic highlightings.
|
||||||
*/
|
*/
|
||||||
protected void disposeHighlightings() {
|
protected void disposeHighlightings() {
|
||||||
for (int i= 0, n= fSemanticHighlightings.length; i < n; i++)
|
for (int i= 0, n= fSemanticHighlightings.length; i < n; i++)
|
||||||
|
@ -470,9 +456,6 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
fHighlightings= null;
|
fHighlightings= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
handlePropertyChangeEvent(event);
|
handlePropertyChangeEvent(event);
|
||||||
|
@ -626,7 +609,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force refresh of highlighting.
|
* Forces refresh of highlighting.
|
||||||
*/
|
*/
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
if (fReconciler != null) {
|
if (fReconciler != null) {
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.editor.SemanticHighlightingManager.HighlightingStyle;
|
||||||
import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
|
import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting presenter - UI thread implementation.
|
* Semantic highlighting presenter - UI thread implementation.
|
||||||
* Cloned from JDT.
|
* Cloned from JDT.
|
||||||
|
@ -45,12 +43,10 @@ import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener {
|
public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting position updater.
|
* Semantic highlighting position updater.
|
||||||
*/
|
*/
|
||||||
private class HighlightingPositionUpdater implements IPositionUpdater {
|
private class HighlightingPositionUpdater implements IPositionUpdater {
|
||||||
|
|
||||||
/** The position category. */
|
/** The position category. */
|
||||||
private final String fCategory;
|
private final String fCategory;
|
||||||
|
|
||||||
|
@ -63,12 +59,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
fCategory= category;
|
fCategory= category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void update(DocumentEvent event) {
|
public void update(DocumentEvent event) {
|
||||||
|
|
||||||
int eventOffset= event.getOffset();
|
int eventOffset= event.getOffset();
|
||||||
int eventOldLength= event.getLength();
|
int eventOldLength= event.getLength();
|
||||||
int eventEnd= eventOffset + eventOldLength;
|
int eventEnd= eventOffset + eventOldLength;
|
||||||
|
@ -77,10 +69,10 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
Position[] positions= event.getDocument().getPositions(fCategory);
|
Position[] positions= event.getDocument().getPositions(fCategory);
|
||||||
|
|
||||||
for (int i= 0; i != positions.length; i++) {
|
for (int i= 0; i != positions.length; i++) {
|
||||||
|
|
||||||
HighlightedPosition position= (HighlightedPosition) positions[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())
|
// if (position.isDeleted())
|
||||||
// continue;
|
// continue;
|
||||||
|
|
||||||
|
@ -88,18 +80,19 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
int length= position.getLength();
|
int length= position.getLength();
|
||||||
int end= offset + length;
|
int end= offset + length;
|
||||||
|
|
||||||
if (offset > eventEnd)
|
if (offset > eventEnd) {
|
||||||
updateWithPrecedingEvent(position, event);
|
updateWithPrecedingEvent(position, event);
|
||||||
else if (end < eventOffset)
|
} else if (end < eventOffset) {
|
||||||
updateWithSucceedingEvent(position, event);
|
updateWithSucceedingEvent(position, event);
|
||||||
else if (offset <= eventOffset && end >= eventEnd)
|
} else if (offset <= eventOffset && end >= eventEnd) {
|
||||||
updateWithIncludedEvent(position, event);
|
updateWithIncludedEvent(position, event);
|
||||||
else if (offset <= eventOffset)
|
} else if (offset <= eventOffset) {
|
||||||
updateWithOverEndEvent(position, event);
|
updateWithOverEndEvent(position, event);
|
||||||
else if (end >= eventEnd)
|
} else if (end >= eventEnd) {
|
||||||
updateWithOverStartEvent(position, event);
|
updateWithOverStartEvent(position, event);
|
||||||
else
|
} else {
|
||||||
updateWithIncludingEvent(position, event);
|
updateWithIncludingEvent(position, event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (BadPositionCategoryException e) {
|
} catch (BadPositionCategoryException e) {
|
||||||
// ignore and return
|
// 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 position The position
|
||||||
* @param event The event
|
* @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 position The position
|
||||||
* @param event The event
|
* @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 position The position
|
||||||
* @param event The event
|
* @param event The event
|
||||||
|
@ -151,9 +144,9 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
int includedLength= 0;
|
int includedLength= 0;
|
||||||
while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
|
while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
|
||||||
includedLength++;
|
includedLength++;
|
||||||
if (includedLength == eventNewLength)
|
if (includedLength == eventNewLength) {
|
||||||
position.setLength(length + deltaLength);
|
position.setLength(length + deltaLength);
|
||||||
else {
|
} else {
|
||||||
int newLeftLength= eventOffset - offset + includedLength;
|
int newLeftLength= eventOffset - offset + includedLength;
|
||||||
|
|
||||||
int excludedLength= eventNewLength;
|
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 position The position
|
||||||
* @param event The event
|
* @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 position The position
|
||||||
* @param event The event
|
* @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.
|
* Invalidates the presentation of the positions based on the given added positions and
|
||||||
* Also unregisters the deleted positions from the document and patches the positions of this presenter.
|
* the existing deleted positions. Also unregisters the deleted positions from the document
|
||||||
|
* and patches the positions of this presenter.
|
||||||
* <p>
|
* <p>
|
||||||
* NOTE: Indirectly called from background thread by UI runnable.
|
* NOTE: Indirectly called from background thread by UI runnable.
|
||||||
* </p>
|
* </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 addedPositions the added positions
|
||||||
* @param removedPositions the removed positions
|
* @param removedPositions the removed positions
|
||||||
*/
|
*/
|
||||||
|
@ -398,7 +395,8 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
|
List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
|
||||||
HighlightedPosition position= null;
|
HighlightedPosition position= null;
|
||||||
HighlightedPosition addedPosition= 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)
|
// loop variant: i + j < old(i + j)
|
||||||
|
|
||||||
// a) find the next non-deleted Position from the old list
|
// 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
|
* @param position The position for insertion
|
||||||
*/
|
*/
|
||||||
|
@ -540,13 +538,11 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void applyTextPresentation(TextPresentation textPresentation) {
|
public void applyTextPresentation(TextPresentation textPresentation) {
|
||||||
IRegion region= textPresentation.getExtent();
|
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) {
|
if (n - i > 2) {
|
||||||
List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
|
List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
|
||||||
for (; i < 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
|
@Override
|
||||||
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
|
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
|
||||||
setCanceled(true);
|
setCanceled(true);
|
||||||
|
@ -576,25 +569,16 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
|
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
|
||||||
manageDocument(newInput);
|
manageDocument(newInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void documentAboutToBeChanged(DocumentEvent event) {
|
public void documentAboutToBeChanged(DocumentEvent event) {
|
||||||
setCanceled(true);
|
setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void documentChanged(DocumentEvent event) {
|
public void documentChanged(DocumentEvent event) {
|
||||||
}
|
}
|
||||||
|
@ -664,7 +648,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstall this presenter.
|
* Uninstalls this presenter.
|
||||||
*/
|
*/
|
||||||
public void uninstall() {
|
public void uninstall() {
|
||||||
setCanceled(true);
|
setCanceled(true);
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTTranslationUnit tu) {
|
public int visit(IASTTranslationUnit tu) {
|
||||||
// visit macro definitions
|
// Visit macro definitions.
|
||||||
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
|
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
|
||||||
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
|
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
|
||||||
if (macroDef.isPartOfTranslationUnitFile()) {
|
if (macroDef.isPartOfTranslationUnitFile()) {
|
||||||
|
@ -90,7 +90,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
fMinLocation= -1;
|
fMinLocation= -1;
|
||||||
|
|
||||||
// visit macro expansions
|
// Visit macro expansions.
|
||||||
IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
|
IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
|
||||||
for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
|
for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
|
||||||
if (macroExp.isPartOfTranslationUnitFile()) {
|
if (macroExp.isPartOfTranslationUnitFile()) {
|
||||||
|
@ -104,7 +104,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
fMinLocation= -1;
|
fMinLocation= -1;
|
||||||
|
|
||||||
// visit ordinary code
|
// Visit ordinary code.
|
||||||
return super.visit(tu);
|
return super.visit(tu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(ICPPASTNamespaceDefinition namespace) {
|
public int visit(ICPPASTNamespaceDefinition namespace) {
|
||||||
if (!namespace.isPartOfTranslationUnitFile()) {
|
if (!namespace.isPartOfTranslationUnitFile()) {
|
||||||
|
@ -172,7 +169,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
|
SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
|
||||||
if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) {
|
if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) {
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
addNameLocation((IASTName)node, fJobHighlightings[i]);
|
addNameLocation((IASTName) node, fJobHighlightings[i]);
|
||||||
} else {
|
} else {
|
||||||
addNodeLocation(node.getFileLocation(), fJobHighlightings[i]);
|
addNodeLocation(node.getFileLocation(), fJobHighlightings[i]);
|
||||||
}
|
}
|
||||||
|
@ -197,14 +194,14 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
int offset= imageLocation.getNodeOffset();
|
int offset= imageLocation.getNodeOffset();
|
||||||
if (offset >= fMinLocation) {
|
if (offset >= fMinLocation) {
|
||||||
int length= imageLocation.getNodeLength();
|
int length= imageLocation.getNodeLength();
|
||||||
if (offset > -1 && length > 0) {
|
if (offset >= 0 && length > 0) {
|
||||||
fMinLocation= offset + length;
|
fMinLocation= offset + length;
|
||||||
addPosition(offset, length, highlightingStyle);
|
addPosition(offset, length, highlightingStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fallback in case no image location available
|
// Fallback in case no image location available.
|
||||||
IASTNodeLocation[] nodeLocations= name.getNodeLocations();
|
IASTNodeLocation[] nodeLocations= name.getNodeLocations();
|
||||||
if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
|
if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
|
||||||
addNodeLocation(nodeLocations[0], highlightingStyle);
|
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 nodeLocation The node location
|
||||||
* @param highlighting The highlighting
|
* @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 offset The range offset
|
||||||
* @param length The range length
|
* @param length The range length
|
||||||
|
@ -290,11 +287,20 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
*/
|
*/
|
||||||
private boolean fIsReconciling= false;
|
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;
|
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;
|
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;
|
private HighlightingStyle[] fJobHighlightings;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -304,7 +310,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
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) {
|
synchronized (fReconcileLock) {
|
||||||
if (fIsReconciling)
|
if (fIsReconciling)
|
||||||
return;
|
return;
|
||||||
|
@ -359,7 +365,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start reconciling positions.
|
* Starts reconciling positions.
|
||||||
*/
|
*/
|
||||||
protected void startReconcilingPositions() {
|
protected void startReconcilingPositions() {
|
||||||
fJobPresenter.addAllPositions(fRemovedPositions);
|
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 ast the AST
|
||||||
* @param visitor the AST visitor
|
* @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 textPresentation the text presentation
|
||||||
* @param addedPositions the added positions
|
* @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() {
|
public void uninstall() {
|
||||||
if (fPresenter != null)
|
if (fPresenter != null)
|
||||||
|
|
|
@ -67,7 +67,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class SemanticHighlightings {
|
public class SemanticHighlightings {
|
||||||
|
|
||||||
private static final RGB RGB_BLACK = new RGB(0, 0, 0);
|
private static final RGB RGB_BLACK = new RGB(0, 0, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,7 +29,7 @@ public final class SemanticToken {
|
||||||
/** Binding */
|
/** Binding */
|
||||||
private IBinding fBinding;
|
private IBinding fBinding;
|
||||||
/** Is the binding resolved? */
|
/** Is the binding resolved? */
|
||||||
private boolean fIsBindingResolved= false;
|
private boolean fIsBindingResolved;
|
||||||
|
|
||||||
/** AST root */
|
/** AST root */
|
||||||
private IASTTranslationUnit fRoot;
|
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>
|
* <p>
|
||||||
* NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
|
* NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
|
||||||
* </p>
|
* </p>
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import org.eclipse.jface.text.IDocument;
|
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.TextPresentation;
|
||||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Presentation reconciler, adding functionality for operation without a viewer.
|
* Presentation reconciler, adding functionality for operation without a viewer.
|
||||||
* Cloned from JDT.
|
* Cloned from JDT.
|
||||||
|
@ -25,7 +23,6 @@ import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class CPresentationReconciler extends PresentationReconciler {
|
public class CPresentationReconciler extends PresentationReconciler {
|
||||||
|
|
||||||
/** Last used document */
|
/** Last used document */
|
||||||
private IDocument fLastDocument;
|
private IDocument fLastDocument;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue