diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java index a015ce755d4..f61b4791069 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTExpressionList.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation + * John Camelon (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -44,10 +44,12 @@ public interface IASTExpressionList extends IASTExpression { /** * @since 5.1 */ + @Override public IASTExpressionList copy(); /** * @since 5.3 */ + @Override public IASTExpressionList copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java index 979c575ab60..4808e3e4ea4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTParameterDeclaration.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -20,7 +20,7 @@ public interface IASTParameterDeclaration extends IASTNode { /** * Constant/sentinel. */ - public static final IASTParameterDeclaration[] EMPTY_PARAMETERDECLARATION_ARRAY = new IASTParameterDeclaration[0]; + public static final IASTParameterDeclaration[] EMPTY_PARAMETERDECLARATION_ARRAY = {}; /** * DECL_SPECIFIER represents the relationship between an @@ -71,10 +71,12 @@ public interface IASTParameterDeclaration extends IASTNode { /** * @since 5.1 */ + @Override public IASTParameterDeclaration copy(); /** * @since 5.3 */ + @Override public IASTParameterDeclaration copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java index 0984c720893..fed5711419b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStandardFunctionDeclarator.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -18,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator { - /** * FUNCTION_PARAMETER represents the relationship between an * IASTStandardFunctionDeclarator and it's nested @@ -67,10 +66,12 @@ public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator { /** * @since 5.1 */ + @Override public IASTStandardFunctionDeclarator copy(); /** * @since 5.3 */ + @Override public IASTStandardFunctionDeclarator copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java index 8ace8e3ecad..219a1889040 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCatchHandler.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -24,8 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTCatchHandler extends IASTStatement { - - public static final ICPPASTCatchHandler[] EMPTY_CATCHHANDLER_ARRAY = new ICPPASTCatchHandler[0]; + public static final ICPPASTCatchHandler[] EMPTY_CATCHHANDLER_ARRAY = {}; /** * DECLARATION represents the nested declaration within the catch handler. @@ -78,10 +77,12 @@ public interface ICPPASTCatchHandler extends IASTStatement { /** * @since 5.1 */ + @Override public ICPPASTCatchHandler copy(); /** * @since 5.3 */ + @Override public ICPPASTCatchHandler copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java index 2bf8d6104d5..f2ad2f402e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDeclarator.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * @noextend This interface is not intended to be extended by clients. */ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator { - /** * Used as return value for {@link #getExceptionSpecification()}. * @since 5.1 @@ -80,6 +79,7 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato /** * @since 5.2 */ + @Override public ICPPASTParameterDeclaration[] getParameters(); /** @@ -117,6 +117,7 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato * Get function scope this node represents. Returns null, if this declarator does not * declare a function-prototype or function-definition. */ + @Override public ICPPFunctionScope getFunctionScope(); @@ -136,10 +137,12 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato /** * @since 5.1 */ + @Override public ICPPASTFunctionDeclarator copy(); /** * @since 5.3 */ + @Override public ICPPASTFunctionDeclarator copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java index bb77771f525..00453b7d61d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionDefinition.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -42,11 +42,13 @@ public interface ICPPASTFunctionDefinition extends IASTFunctionDefinition { /** * @since 5.1 */ + @Override public ICPPASTFunctionDefinition copy(); /** * @since 5.3 */ + @Override public ICPPASTFunctionDefinition copy(CopyStyle style); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java index 13be9a177f8..3ea27afa6ab 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionWithTryBlock.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition { - /** * A CATCH_HANDLER is the role of an ICPPASTCatchHandler in * this interface. @@ -44,6 +43,6 @@ public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition { /** * @since 5.1 */ + @Override public ICPPASTFunctionWithTryBlock copy(); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java index 722c8049af4..59e0de8d438 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceDefinition.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IScope; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner, IASTDeclarationListOwner { - /** * OWNED_DECLARATION is the role served by all the nested * declarations. @@ -68,22 +67,22 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn public boolean isInline(); /** - * A translation unit contains an ordered sequence of declarations. + * A namespace contains an ordered sequence of declarations. * - * @return IASTDeclaration [] + * @return an array of declarations contained in the namespace */ public IASTDeclaration[] getDeclarations(); /** - * Add a declaration to the namespace. + * Adds a declaration to the namespace. * - * @param declaration - * IASTDeclaration + * @param declaration IASTDeclaration */ + @Override public void addDeclaration(IASTDeclaration declaration); /** - * Get the scope object represented by this construct. + * Returns the scope object represented by this construct. * * @return IScope */ @@ -92,10 +91,12 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn /** * @since 5.1 */ + @Override public ICPPASTNamespaceDefinition copy(); /** * @since 5.3 */ + @Override public ICPPASTNamespaceDefinition copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java index 0d72769cb64..46b8141eb5f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTCopyLocation.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software (IFS)- initial API and implementation + * Institute for Software (IFS)- initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -17,32 +17,31 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; /** * @author Emanuel Graf IFS - * */ public class ASTCopyLocation implements IASTCopyLocation { - private IASTNode originalNode; - - public ASTCopyLocation(IASTNode originalNode) { this.originalNode = originalNode; } + @Override public int getNodeOffset() { return 0; } + @Override public int getNodeLength() { return 0; } + @Override public IASTFileLocation asFileLocation() { return null; } + @Override public IASTNode getOriginalNode() { return originalNode; } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java index 7e1e9020386..32335283083 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEnumerator.java @@ -40,6 +40,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I copy.setOffsetAndLength(this); } + @Override public void setName(IASTName name) { assertNotFrozen(); this.name = name; @@ -49,11 +50,13 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I } } - public IASTName getName() { + @Override + public IASTName getName() { return name; } - public void setValue(IASTExpression expression) { + @Override + public void setValue(IASTExpression expression) { assertNotFrozen(); this.value = expression; if (expression != null) { @@ -62,7 +65,8 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I } } - public IASTExpression getValue() { + @Override + public IASTExpression getValue() { return value; } @@ -87,6 +91,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I return true; } + @Override public int getRoleForName(IASTName n) { if (n == name) return r_definition; @@ -94,7 +99,8 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I return r_reference; } - public void replace(IASTNode child, IASTNode other) { + @Override + public void replace(IASTNode child, IASTNode other) { if (child == value) { other.setPropertyInParent(child.getPropertyInParent()); other.setParent(child.getParent()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java index 65c5803578d..55a4b27c635 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTEqualsInitializer.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -32,11 +32,13 @@ public abstract class ASTEqualsInitializer extends ASTNode implements IASTEquals setInitializerClause(arg); } + @Override public IASTInitializerClause getInitializerClause() { return fArgument; } - public void setInitializerClause(IASTInitializerClause clause) { + @Override + public void setInitializerClause(IASTInitializerClause clause) { assertNotFrozen(); fArgument = clause; if (clause != null) { @@ -64,6 +66,7 @@ public abstract class ASTEqualsInitializer extends ASTNode implements IASTEquals return true; } + @Override public void replace(IASTNode child, IASTNode other) { if (child == fArgument) { other.setPropertyInParent(child.getPropertyInParent()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java index 25de5bcb568..c3d79aa6247 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -42,23 +42,29 @@ public abstract class ASTNode implements IASTNode { private int length; private int offset; + private IASTNodeLocation[] locations; + private IASTFileLocation fileLocation; private boolean frozen = false; private boolean active = true; - public IASTNode getParent() { + @Override + public IASTNode getParent() { return parent; } + @Override public IASTNode[] getChildren() { ChildCollector collector= new ChildCollector(this); return collector.getChildren(); } + @Override public boolean isFrozen() { return frozen; } + @Override public boolean isActive() { return active; } @@ -78,16 +84,19 @@ public abstract class ASTNode implements IASTNode { throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ } - public void setParent(IASTNode node) { + @Override + public void setParent(IASTNode node) { assertNotFrozen(); this.parent = node; } - public ASTNodeProperty getPropertyInParent() { + @Override + public ASTNodeProperty getPropertyInParent() { return property; } - public void setPropertyInParent(ASTNodeProperty property) { + @Override + public void setPropertyInParent(ASTNodeProperty property) { assertNotFrozen(); this.property = property; } @@ -120,10 +129,8 @@ public abstract class ASTNode implements IASTNode { setOffsetAndLength(node.getOffset(), node.getLength()); } - private IASTNodeLocation[] locations = null; - private IASTFileLocation fileLocation = null; - - public IASTNodeLocation[] getNodeLocations() { + @Override + public IASTNodeLocation[] getNodeLocations() { if (locations != null) return locations; if (length == 0) { @@ -163,11 +170,13 @@ public abstract class ASTNode implements IASTNode { return CharArrayUtils.EMPTY; } - public String getRawSignature() { + @Override + public String getRawSignature() { return new String(getRawSignatureChars()); } - public String getContainingFilename() { + @Override + public String getContainingFilename() { if (offset <= 0 && (length == 0 || offset < 0)) { final IASTNode parent = getParent(); if (parent == null) { @@ -181,7 +190,8 @@ public abstract class ASTNode implements IASTNode { return getTranslationUnit().getContainingFilename(offset); } - public IASTFileLocation getFileLocation() { + @Override + public IASTFileLocation getFileLocation() { if (fileLocation != null) return fileLocation; // TODO(sprigogin): The purpose of offset == 0 && length == 0 condition is not clear to me. @@ -201,7 +211,8 @@ public abstract class ASTNode implements IASTNode { return fileLocation; } - public boolean isPartOfTranslationUnitFile() { + @Override + public boolean isPartOfTranslationUnitFile() { IASTTranslationUnit ast = getTranslationUnit(); if (ast != null) { ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class); @@ -223,15 +234,18 @@ public abstract class ASTNode implements IASTNode { return false; } - public IASTTranslationUnit getTranslationUnit() { + @Override + public IASTTranslationUnit getTranslationUnit() { return parent != null ? parent.getTranslationUnit() : null; } - public boolean accept(ASTVisitor visitor) { + @Override + public boolean accept(ASTVisitor visitor) { return true; } - public boolean contains(IASTNode node) { + @Override + public boolean contains(IASTNode node) { if (node instanceof ASTNode) { ASTNode astNode= (ASTNode) node; return offset <= astNode.offset && @@ -240,15 +254,18 @@ public abstract class ASTNode implements IASTNode { return false; } + @Override public IToken getSyntax() throws ExpansionOverlapsBoundaryException { return getSyntax(offset, offset+length, 0); } + @Override public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException { int left= getBoundary(-1); return getSyntax(left, offset, -1); } + @Override public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException { int right= getBoundary(1); return getSyntax(offset+length, right, 1); @@ -346,5 +363,4 @@ public abstract class ASTNode implements IASTNode { protected void setCopyLocation(IASTNode originalNode) { locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)}; } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSelector.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSelector.java index ad7512b0d2e..b8e028975df 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSelector.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSelector.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver; * @since 5.0 */ public class ASTNodeSelector implements IASTNodeSelector { - private ASTTranslationUnit fTu; private ILocationResolver fLocationResolver; private String fFilePath; @@ -74,7 +73,7 @@ public class ASTNodeSelector implements IASTNodeSelector { sequenceLength= 0; if (offsetInFile > 0) { altSequenceNumber= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, offsetInFile-1); - if (altSequenceNumber+1 == sequenceNumber) { + if (altSequenceNumber + 1 == sequenceNumber) { altSequenceNumber= -1; } else { // we are on a context boundary and we need to check the variant to the left and @@ -118,55 +117,67 @@ public class ASTNodeSelector implements IASTNodeSelector { return nodeSpec.getBestNode(); } - + @Override public IASTNode findFirstContainedNode(int offset, int length) { return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class); } + @Override public IASTNode findNode(int offset, int length) { return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class); } + @Override public IASTNode findEnclosingNode(int offset, int length) { return findNode(offset, length, Relation.ENCLOSING, IASTNode.class); } + @Override public IASTNode findStrictlyEnclosingNode(int offset, int length) { return findNode(offset, length, Relation.STRICTLY_ENCLOSING, IASTNode.class); } + @Override public IASTNode findFirstContainedNodeInExpansion(int offset, int length) { return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class, true); } + @Override public IASTNode findNodeInExpansion(int offset, int length) { return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class, true); } + @Override public IASTNode findEnclosingNodeInExpansion(int offset, int length) { return findNode(offset, length, Relation.ENCLOSING, IASTNode.class, true); } + @Override public IASTName findFirstContainedName(int offset, int length) { return findNode(offset, length, Relation.FIRST_CONTAINED, IASTName.class); } + @Override public IASTName findName(int offset, int length) { return findNode(offset, length, Relation.EXACT_MATCH, IASTName.class); } + @Override public IASTName findEnclosingName(int offset, int length) { return findNode(offset, length, Relation.ENCLOSING, IASTName.class); } + @Override public IASTImplicitName findImplicitName(int offset, int length) { return findNode(offset, length, Relation.EXACT_MATCH, IASTImplicitName.class); } + @Override public IASTImplicitName findEnclosingImplicitName(int offset, int length) { return findNode(offset, length, Relation.ENCLOSING, IASTImplicitName.class); } + @Override public IASTPreprocessorMacroExpansion findEnclosingMacroExpansion(int offset, int length) { return findNode(offset, length, Relation.ENCLOSING, IASTPreprocessorMacroExpansion.class); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java index a269c788ed2..b3f438cd6b9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -41,12 +41,12 @@ public class ASTNodeSpecification { fRelation= relation; fClass= clazz; fFileOffset= fileOffset; - fFileEndOffset= fileOffset+fileLength; + fFileEndOffset= fileOffset + fileLength; } public void setRangeInSequence(int offsetInSeq, int lengthInSeq) { fSeqNumber= offsetInSeq; - fSeqEndNumber= offsetInSeq+lengthInSeq; + fSeqEndNumber= offsetInSeq + lengthInSeq; } public void setRangeInSequence(int offsetInSeq, int lengthInSeq, boolean zeroRangeToLeft) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java index 660b320d26c..1c24b726ce6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Anton Leherbauer (Wind River Systems) - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -23,95 +23,10 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages; import com.ibm.icu.text.MessageFormat; - /** * Models problems, all problems should derive from this class. */ public class ASTProblem extends ASTNode implements IASTProblem { - - private final int id; - private final char[] arg; - private boolean isError= false; - - public ASTProblem(IASTNode parent, ASTNodeProperty property, int id, char[] arg, boolean isError, int startNumber, int endNumber) { - setParent(parent); - setPropertyInParent(property); - setOffset(startNumber); - setLength(endNumber-startNumber); - - this.isError= isError; - this.id = id; - this.arg = arg; - } - - public ASTProblem(int id, char[] arg, boolean isError) { - this.id = id; - this.arg = arg; - this.isError= isError; - } - - public ASTProblem copy() { - return copy(CopyStyle.withoutLocations); - } - - public ASTProblem copy(CopyStyle style) { - ASTProblem problem = new ASTProblem(id, arg == null ? null : arg.clone(), isError); - problem.setOffsetAndLength(this); - if (style == CopyStyle.withLocations) { - problem.setCopyLocation(this); - } - return problem; - } - - public int getID() { - return id; - } - - public boolean isError() { - return isError; - } - - public boolean isWarning() { - return !isError; - } - - public String getMessageWithLocation() { - String msg= getMessage(); - - char[] file= getOriginatingFileName(); - int line= getSourceLineNumber(); - Object[] args = new Object[] { msg, new String(file), new Integer(line) }; - return ParserMessages.getFormattedString("BaseProblemFactory.problemPattern", args); //$NON-NLS-1$ - } - - public static String getMessage(int id, String arg) { - String msg = errorMessages.get(new Integer(id)); - if (msg == null) - msg = ""; //$NON-NLS-1$ - - if (arg != null) { - return MessageFormat.format(msg, new Object[] {arg}); - } - return msg; - } - - public String getMessage() { - return getMessage(id, arg == null ? null : new String(arg)); - } - - public boolean checkCategory(int bitmask) { - return ((id & bitmask) != 0); - } - - public String[] getArguments() { - return arg == null ? new String[0] : new String[] {new String(arg)}; - } - - public char[] getArgument() { - return arg; - } - - protected static final Map errorMessages; static { errorMessages = new HashMap(); @@ -179,16 +94,104 @@ public class ASTProblem extends ASTNode implements IASTProblem { ParserMessages.getString("ParserProblemFactory.error.syntax.missingSemicolon")); //$NON-NLS-1$ } - /* - * @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName() - */ + private final int id; + private final char[] arg; + private boolean isError; + + public ASTProblem(IASTNode parent, ASTNodeProperty property, int id, char[] arg, boolean isError, + int startNumber, int endNumber) { + setParent(parent); + setPropertyInParent(property); + setOffset(startNumber); + setLength(endNumber-startNumber); + + this.isError= isError; + this.id = id; + this.arg = arg; + } + + public ASTProblem(int id, char[] arg, boolean isError) { + this.id = id; + this.arg = arg; + this.isError= isError; + } + + @Override + public ASTProblem copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public ASTProblem copy(CopyStyle style) { + ASTProblem problem = new ASTProblem(id, arg == null ? null : arg.clone(), isError); + problem.setOffsetAndLength(this); + if (style == CopyStyle.withLocations) { + problem.setCopyLocation(this); + } + return problem; + } + + @Override + public int getID() { + return id; + } + + @Override + public boolean isError() { + return isError; + } + + @Override + public boolean isWarning() { + return !isError; + } + + @Override + public String getMessageWithLocation() { + String msg= getMessage(); + + char[] file= getOriginatingFileName(); + int line= getSourceLineNumber(); + Object[] args = new Object[] { msg, new String(file), new Integer(line) }; + return ParserMessages.getFormattedString("BaseProblemFactory.problemPattern", args); //$NON-NLS-1$ + } + + public static String getMessage(int id, String arg) { + String msg = errorMessages.get(new Integer(id)); + if (msg == null) + msg = ""; //$NON-NLS-1$ + + if (arg != null) { + return MessageFormat.format(msg, new Object[] {arg}); + } + return msg; + } + + @Override + public String getMessage() { + return getMessage(id, arg == null ? null : new String(arg)); + } + + @Override + public boolean checkCategory(int bitmask) { + return (id & bitmask) != 0; + } + + @Override + public String[] getArguments() { + return arg == null ? new String[0] : new String[] { new String(arg) }; + } + + public char[] getArgument() { + return arg; + } + + @Override public char[] getOriginatingFileName() { return getContainingFilename().toCharArray(); } - /* - * @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd() - */ + @Override public int getSourceEnd() { final IASTFileLocation location= getFileLocation(); if (location != null) { @@ -197,9 +200,7 @@ public class ASTProblem extends ASTNode implements IASTProblem { return INT_VALUE_NOT_PROVIDED; } - /* - * @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber() - */ + @Override public int getSourceLineNumber() { final IASTFileLocation location= getFileLocation(); if (location != null) { @@ -208,9 +209,7 @@ public class ASTProblem extends ASTNode implements IASTProblem { return INT_VALUE_NOT_PROVIDED; } - /* - * @see org.eclipse.cdt.core.parser.IProblem#getSourceStart() - */ + @Override public int getSourceStart() { final IASTFileLocation location= getFileLocation(); if (location != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java index fcdac6f06b7..34383d64d22 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTypeIdInitializerExpression.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -41,11 +41,13 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements } } + @Override public IASTTypeId getTypeId() { return typeId; } - public void setTypeId(IASTTypeId typeId) { + @Override + public void setTypeId(IASTTypeId typeId) { assertNotFrozen(); this.typeId = typeId; if (typeId != null) { @@ -54,11 +56,13 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements } } - public IASTInitializer getInitializer() { + @Override + public IASTInitializer getInitializer() { return initializer; } - public void setInitializer(IASTInitializer initializer) { + @Override + public void setInitializer(IASTInitializer initializer) { assertNotFrozen(); this.initializer = initializer; if (initializer != null) { @@ -68,32 +72,34 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitExpressions ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitExpressions) { + switch(action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( typeId != null ) if( !typeId.accept( action ) ) return false; - if( initializer != null ) if( !initializer.accept( action ) ) return false; + if (typeId != null && !typeId.accept(action)) return false; + if (initializer != null && !initializer.accept(action)) return false; - if( action.shouldVisitExpressions ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitExpressions) { + switch(action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } + @Override public final boolean isLValue() { return false; } + @Override public final ValueCategory getValueCategory() { return ValueCategory.PRVALUE; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java index 5f1b30e39a3..461a2afa83f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Anton Leherbauer (Wind River Systems) - * Sergey Prigogin (Google) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Anton Leherbauer (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -63,7 +63,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { private static final Map CHAR_ARRAYS = new HashMap(); private IBinding[] fBindings; - private IScope fScope= null; + private IScope fScope; private final boolean fCpp; private final boolean fGnu; @@ -75,6 +75,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { fGnu= supportGnuSymbols; } + @Override public IBinding[] getBuiltinBindings(IScope scope) { fScope= scope; initialize(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java index 8a7bcfc5dd1..0acd5ec5b71 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTInternalEnumerationSpecifier.java @@ -6,29 +6,31 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; /** - * Internal interface for c- or c++ enumeration specifiers. + * Internal interface for C or C++ enumeration specifiers. */ public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier { /** - * Notifies that the value computation for the enumeration is started. Returns whether this is the - * first attempt to do so. + * Notifies that the value computation for the enumeration is started. Returns whether this is + * the first attempt to do so. */ boolean startValueComputation(); /** * @since 5.1 */ + @Override public IASTInternalEnumerationSpecifier copy(); /** * @since 5.3 */ + @Override public IASTInternalEnumerationSpecifier copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/NodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/NodeFactory.java index bcc6d2caeef..04ba0b9aa95 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/NodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/NodeFactory.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -18,15 +18,18 @@ import org.eclipse.cdt.core.dom.ast.INodeFactory; */ public abstract class NodeFactory implements INodeFactory { + @Override public final void setOffsets(IASTNode node, int offset, int endOffset) { ((ASTNode) node).setOffsetAndLength(offset, endOffset-offset); } + @Override public final void setEndOffset(IASTNode node, int endOffset) { ASTNode a= (ASTNode) node; a.setLength(endOffset - a.getOffset()); } + @Override public final void setEndOffset(IASTNode node, IASTNode endNode) { ASTNode a= (ASTNode) node; ASTNode e= (ASTNode) endNode; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java index d68c6eb596f..590220e76c1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -36,26 +36,32 @@ public class ProblemFunctionType extends ProblemType implements ICPPFunctionType return new ProblemFunctionType(buffer.getShort()); } + @Override public IType getReturnType() { return new ProblemType(getID()); } + @Override public IType[] getParameterTypes() { return new IType[] {new ProblemType(getID())}; } + @Override public boolean isConst() { return false; } + @Override public boolean isVolatile() { return false; } + @Override public boolean takesVarArgs() { return false; } + @Override public IPointerType getThisType() { return new CPPPointerType(new ProblemType(getID())); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java index 4172ddaf9a0..b125d1f5ae1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -15,7 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.parser.ParserMessages; import org.eclipse.core.runtime.CoreException; - /** * Implementation of problem types. */ @@ -28,14 +27,17 @@ public class ProblemType implements IProblemType, ISerializableType { fID= id; } + @Override public int getID() { return fID; } + @Override public String getMessage() { return ParserMessages.getProblemPattern(this); } + @Override public boolean isSameType(IType type) { return type == this; } @@ -49,6 +51,7 @@ public class ProblemType implements IProblemType, ISerializableType { } } + @Override public void marshal(ITypeMarshalBuffer buffer) throws CoreException { buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE); buffer.putShort((short) getID()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java index 965e07a3012..1cf869e278c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCatchHandler.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent { - private boolean isCatchAll; private IASTStatement body; private IASTDeclaration declaration; @@ -38,10 +37,12 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, setDeclaration(declaration); } + @Override public CPPASTCatchHandler copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTCatchHandler copy(CopyStyle style) { CPPASTCatchHandler copy = new CPPASTCatchHandler(); copy.setDeclaration(declaration == null ? null : declaration.copy(style)); @@ -54,16 +55,19 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, return copy; } + @Override public void setIsCatchAll(boolean isEllipsis) { assertNotFrozen(); isCatchAll = isEllipsis; } - public boolean isCatchAll() { + @Override + public boolean isCatchAll() { return isCatchAll; } - public void setCatchBody(IASTStatement compoundStatement) { + @Override + public void setCatchBody(IASTStatement compoundStatement) { assertNotFrozen(); body = compoundStatement; if (compoundStatement != null) { @@ -72,11 +76,13 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, } } - public IASTStatement getCatchBody() { + @Override + public IASTStatement getCatchBody() { return body; } - public void setDeclaration(IASTDeclaration decl) { + @Override + public void setDeclaration(IASTDeclaration decl) { assertNotFrozen(); declaration = decl; if (decl != null) { @@ -85,48 +91,48 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, } } - public IASTDeclaration getDeclaration() { + @Override + public IASTDeclaration getDeclaration() { return declaration; } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( declaration != null ) if( !declaration.accept( action ) ) return false; - if( body != null ) if( !body.accept( action ) ) return false; + if (declaration != null && !declaration.accept(action)) return false; + if (body != null && !body.accept(action)) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } - public void replace(IASTNode child, IASTNode other) { - if( body == child ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + @Override + public void replace(IASTNode child, IASTNode other) { + if (body == child) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); body = (IASTStatement) other; } - if( declaration == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); + if (declaration == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); declaration = (IASTDeclaration) other; } - } + @Override public IScope getScope() { if (scope == null) { scope = new CPPBlockScope(this); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java index dd68669d0dc..760aa746449 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDeclarator.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -77,6 +77,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS return copy; } + @Override public ICPPASTParameterDeclaration[] getParameters() { if (parameters == null) return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY; @@ -84,7 +85,8 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS return parameters= ArrayUtil.trim(parameters); } - public void addParameterDeclaration(IASTParameterDeclaration parameter) { + @Override + public void addParameterDeclaration(IASTParameterDeclaration parameter) { assertNotFrozen(); if (parameter != null) { parameter.setParent(this); @@ -93,52 +95,63 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS } } - public boolean takesVarArgs() { + @Override + public boolean takesVarArgs() { return varArgs; } - public void setVarArgs(boolean value) { + @Override + public void setVarArgs(boolean value) { assertNotFrozen(); varArgs = value; } - public boolean isConst() { + @Override + public boolean isConst() { return isConst; } - public void setConst(boolean value) { + @Override + public void setConst(boolean value) { assertNotFrozen(); this.isConst = value; } - public boolean isVolatile() { + @Override + public boolean isVolatile() { return isVolatile; } - public void setVolatile(boolean value) { + @Override + public void setVolatile(boolean value) { assertNotFrozen(); this.isVolatile = value; } - public boolean isMutable() { + @Override + public boolean isMutable() { return isMutable; } - public void setMutable(boolean value) { + @Override + public void setMutable(boolean value) { assertNotFrozen(); this.isMutable = value; } - public IASTTypeId[] getExceptionSpecification() { + @Override + public IASTTypeId[] getExceptionSpecification() { return typeIds= ArrayUtil.trim(typeIds); } - public void setEmptyExceptionSpecification() { + @Override + public void setEmptyExceptionSpecification() { assertNotFrozen(); typeIds= IASTTypeId.EMPTY_TYPEID_ARRAY; } - public void addExceptionSpecificationTypeId(IASTTypeId typeId) { + @Override + public void addExceptionSpecificationTypeId(IASTTypeId typeId) { assertNotFrozen(); if (typeId != null) { assert typeIds != null; @@ -147,12 +160,13 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS typeId.setPropertyInParent(EXCEPTION_TYPEID); } } - - public IASTTypeId getTrailingReturnType() { + @Override + public IASTTypeId getTrailingReturnType() { return trailingReturnType; } + @Override public void setTrailingReturnType(IASTTypeId typeId) { assertNotFrozen(); trailingReturnType= typeId; @@ -162,20 +176,23 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS } } + @Override public boolean isPureVirtual() { return pureVirtual; } - public void setPureVirtual(boolean isPureVirtual) { + @Override + public void setPureVirtual(boolean isPureVirtual) { assertNotFrozen(); this.pureVirtual = isPureVirtual; } - @Deprecated + @Override + @Deprecated public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() { if (ASTQueries.findTypeRelevantDeclarator(this) == this) { IASTNode parent= getParent(); - while(!(parent instanceof IASTDeclaration)) { + while (!(parent instanceof IASTDeclaration)) { if (parent == null) break; parent= parent.getParent(); @@ -187,18 +204,20 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS return org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY; } - @Deprecated + @Override + @Deprecated public void addConstructorToChain(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer initializer) { assertNotFrozen(); } - public ICPPFunctionScope getFunctionScope() { + @Override + public ICPPFunctionScope getFunctionScope() { if (scope != null) return scope; // introduce a scope for function declarations and definitions, only. IASTNode node= getParent(); - while(!(node instanceof IASTDeclaration)) { + while (!(node instanceof IASTDeclaration)) { if (node==null) return null; node= node.getParent(); @@ -232,6 +251,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS return super.postAccept(action); } + @Override public void replace(IASTNode child, IASTNode other) { if (parameters != null) { for (int i = 0; i < parameters.length; ++i) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java index 9300b41cf31..c555f9d0c4c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionWithTryBlock.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -24,7 +24,9 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; * @see ICPPASTFunctionWithTryBlock */ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition implements ICPPASTFunctionWithTryBlock { - + private ICPPASTCatchHandler[] catchHandlers; + private int catchHandlersPos= -1; + public CPPASTFunctionWithTryBlock() { } @@ -49,10 +51,12 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme copy.setDeclarator(declarator == null ? null : declarator.copy(style)); copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style)); - for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) + for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) { copy.addMemberInitializer(initializer == null ? null : initializer.copy(style)); - for (ICPPASTCatchHandler handler : getCatchHandlers()) + } + for (ICPPASTCatchHandler handler : getCatchHandlers()) { copy.addCatchHandler(handler == null ? null : handler.copy(style)); + } copy.setOffsetAndLength(this); if (style == CopyStyle.withLocations) { @@ -61,29 +65,27 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme return copy; } + @Override public void addCatchHandler(ICPPASTCatchHandler statement) { assertNotFrozen(); if (statement != null) { - catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.append( ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement ); + catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.append(ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement); statement.setParent(this); statement.setPropertyInParent(CATCH_HANDLER); } } - public ICPPASTCatchHandler [] getCatchHandlers() { - if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; - catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos ); + @Override + public ICPPASTCatchHandler[] getCatchHandlers() { + if (catchHandlers == null) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; + catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter(ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos); return catchHandlers; } - - private ICPPASTCatchHandler [] catchHandlers = null; - private int catchHandlersPos=-1; - @Override - protected boolean acceptCatchHandlers( ASTVisitor action ){ - final ICPPASTCatchHandler [] handlers = getCatchHandlers(); - for (int i=0; i result= new ArrayList(); fRootContext.collectLocations(sequenceNumber, length, result); return result.toArray(new IASTNodeLocation[result.size()]); } - - + + @Override public boolean isPartOfTranslationUnitFile(int sequenceNumber) { return fRootContext.isThisFile(sequenceNumber); } + @Override public IASTImageLocation getImageLocation(int sequenceNumber, int length) { ArrayList result= new ArrayList(); fRootContext.collectLocations(sequenceNumber, length, result); @@ -515,6 +526,7 @@ public class LocationMap implements ILocationResolver { return null; } + @Override public void findPreprocessorNode(ASTNodeSpecification nodeSpec) { final int sequenceStart= nodeSpec.getSequenceStart(); final int sequenceEnd= nodeSpec.getSequenceEnd(); @@ -600,6 +612,7 @@ public class LocationMap implements ILocationResolver { return lower; } + @Override public int getSequenceNumberForFileOffset(String filePath, int fileOffset) { LocationCtx ctx= fRootContext; if (filePath != null) { @@ -624,6 +637,7 @@ public class LocationMap implements ILocationResolver { return -1; } + @Override public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) { if (locations.length == 0) { return null; @@ -643,7 +657,7 @@ public class LocationMap implements ILocationResolver { return null; } - + @Override public IASTPreprocessorMacroDefinition[] getMacroDefinitions() { ArrayList result= new ArrayList(); for (Iterator iterator = fDirectives.iterator(); iterator.hasNext();) { @@ -655,7 +669,8 @@ public class LocationMap implements ILocationResolver { return result.toArray(new IASTPreprocessorMacroDefinition[result.size()]); } - public IASTPreprocessorIncludeStatement[] getIncludeDirectives() { + @Override + public IASTPreprocessorIncludeStatement[] getIncludeDirectives() { ArrayList result= new ArrayList(); for (Iterator iterator = fDirectives.iterator(); iterator.hasNext();) { Object directive= iterator.next(); @@ -666,26 +681,32 @@ public class LocationMap implements ILocationResolver { return result.toArray(new IASTPreprocessorIncludeStatement[result.size()]); } + @Override public IASTComment[] getComments() { return fComments.toArray(new IASTComment[fComments.size()]); } - public IASTPreprocessorStatement[] getAllPreprocessorStatements() { + @Override + public IASTPreprocessorStatement[] getAllPreprocessorStatements() { return fDirectives.toArray(new IASTPreprocessorStatement[fDirectives.size()]); } - public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() { + @Override + public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() { return fBuiltinMacros.toArray(new IASTPreprocessorMacroDefinition[fBuiltinMacros.size()]); } + @Override public IASTProblem[] getScannerProblems() { return fProblems.toArray(new IASTProblem[fProblems.size()]); } + @Override public int getScannerProblemsCount() { return fProblems.size(); } + @Override public IASTName[] getDeclarations(IMacroBinding binding) { IASTPreprocessorMacroDefinition def = getMacroDefinition(binding); return def == null ? IASTName.EMPTY_NAME_ARRAY: new IASTName[] { def.getName() }; @@ -712,6 +733,7 @@ public class LocationMap implements ILocationResolver { return fMacroDefinitionMap.get(binding); } + @Override public IASTName[] getReferences(IMacroBinding binding) { List result= new ArrayList(); for (IASTName name : fMacroReferences) { @@ -737,6 +759,7 @@ public class LocationMap implements ILocationResolver { return result.toArray(new ASTPreprocessorName[result.size()]); } + @Override public IDependencyTree getDependencyTree() { return new DependencyTree(fRootContext); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java index 7349e8ee4f5..6efbd04161f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java @@ -7,8 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently - * Sergey Prigogin, Google + * Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting unnamed profile fails silently + * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.preferences.formatter; @@ -32,7 +32,6 @@ import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile; * The code formatter preference page. */ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock { - private static final String FORMATTER_DIALOG_PREFERENCE_KEY= "formatter_page"; //$NON-NLS-1$ private static final String DIALOGSTORE_LASTSAVELOADPATH= CUIPlugin.PLUGIN_ID + ".codeformatter.savepath"; //$NON-NLS-1$ @@ -46,6 +45,7 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock { fCodeStylePreview.update(); } + @Override public void update(Observable o, Object arg) { if (o == fCustomCodeFormatterBlock) { fCodeStylePreview.setFormatterId((String)arg); @@ -173,5 +173,4 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock { } return super.performOk(); } - }