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

@Override annotations.

This commit is contained in:
Sergey Prigogin 2011-12-13 19:29:08 -08:00
parent cd080686aa
commit 18ec28be0f
28 changed files with 425 additions and 293 deletions

View file

@ -6,7 +6,7 @@
* 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;
@ -44,10 +44,12 @@ public interface IASTExpressionList extends IASTExpression {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public IASTExpressionList copy(); public IASTExpressionList copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public IASTExpressionList copy(CopyStyle style); public IASTExpressionList copy(CopyStyle style);
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -20,7 +20,7 @@ public interface IASTParameterDeclaration extends IASTNode {
/** /**
* Constant/sentinel. * Constant/sentinel.
*/ */
public static final IASTParameterDeclaration[] EMPTY_PARAMETERDECLARATION_ARRAY = new IASTParameterDeclaration[0]; public static final IASTParameterDeclaration[] EMPTY_PARAMETERDECLARATION_ARRAY = {};
/** /**
* <code>DECL_SPECIFIER</code> represents the relationship between an * <code>DECL_SPECIFIER</code> represents the relationship between an
@ -71,10 +71,12 @@ public interface IASTParameterDeclaration extends IASTNode {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public IASTParameterDeclaration copy(); public IASTParameterDeclaration copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public IASTParameterDeclaration copy(CopyStyle style); public IASTParameterDeclaration copy(CopyStyle style);
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator { public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator {
/** /**
* <code>FUNCTION_PARAMETER</code> represents the relationship between an * <code>FUNCTION_PARAMETER</code> represents the relationship between an
* <code>IASTStandardFunctionDeclarator</code> and it's nested * <code>IASTStandardFunctionDeclarator</code> and it's nested
@ -67,10 +66,12 @@ public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public IASTStandardFunctionDeclarator copy(); public IASTStandardFunctionDeclarator copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public IASTStandardFunctionDeclarator copy(CopyStyle style); public IASTStandardFunctionDeclarator copy(CopyStyle style);
} }

View file

@ -6,7 +6,7 @@
* 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
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTCatchHandler extends IASTStatement { public interface ICPPASTCatchHandler extends IASTStatement {
public static final ICPPASTCatchHandler[] EMPTY_CATCHHANDLER_ARRAY = {};
public static final ICPPASTCatchHandler[] EMPTY_CATCHHANDLER_ARRAY = new ICPPASTCatchHandler[0];
/** /**
* <code>DECLARATION</code> represents the nested declaration within the catch handler. * <code>DECLARATION</code> represents the nested declaration within the catch handler.
@ -78,10 +77,12 @@ public interface ICPPASTCatchHandler extends IASTStatement {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICPPASTCatchHandler copy(); public ICPPASTCatchHandler copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public ICPPASTCatchHandler copy(CopyStyle style); public ICPPASTCatchHandler copy(CopyStyle style);
} }

View file

@ -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.core.dom.ast.cpp; 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. * @noextend This interface is not intended to be extended by clients.
*/ */
public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator { public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator {
/** /**
* Used as return value for {@link #getExceptionSpecification()}. * Used as return value for {@link #getExceptionSpecification()}.
* @since 5.1 * @since 5.1
@ -80,6 +79,7 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
/** /**
* @since 5.2 * @since 5.2
*/ */
@Override
public ICPPASTParameterDeclaration[] getParameters(); public ICPPASTParameterDeclaration[] getParameters();
/** /**
@ -117,6 +117,7 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
* Get function scope this node represents. Returns <code>null</code>, if this declarator does not * Get function scope this node represents. Returns <code>null</code>, if this declarator does not
* declare a function-prototype or function-definition. * declare a function-prototype or function-definition.
*/ */
@Override
public ICPPFunctionScope getFunctionScope(); public ICPPFunctionScope getFunctionScope();
@ -136,10 +137,12 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICPPASTFunctionDeclarator copy(); public ICPPASTFunctionDeclarator copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public ICPPASTFunctionDeclarator copy(CopyStyle style); public ICPPASTFunctionDeclarator copy(CopyStyle style);
} }

View file

@ -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.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -42,11 +42,13 @@ public interface ICPPASTFunctionDefinition extends IASTFunctionDefinition {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICPPASTFunctionDefinition copy(); public ICPPASTFunctionDefinition copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public ICPPASTFunctionDefinition copy(CopyStyle style); public ICPPASTFunctionDefinition copy(CopyStyle style);
/** /**

View file

@ -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.cpp; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition { public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition {
/** /**
* A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in * A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in
* this interface. * this interface.
@ -44,6 +43,6 @@ public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICPPASTFunctionWithTryBlock copy(); public ICPPASTFunctionWithTryBlock copy();
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner, IASTDeclarationListOwner { public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner, IASTDeclarationListOwner {
/** /**
* <code>OWNED_DECLARATION</code> is the role served by all the nested * <code>OWNED_DECLARATION</code> is the role served by all the nested
* declarations. * declarations.
@ -68,22 +67,22 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn
public boolean isInline(); public boolean isInline();
/** /**
* A translation unit contains an ordered sequence of declarations. * A namespace contains an ordered sequence of declarations.
* *
* @return <code>IASTDeclaration []</code> * @return an array of declarations contained in the namespace
*/ */
public IASTDeclaration[] getDeclarations(); public IASTDeclaration[] getDeclarations();
/** /**
* Add a declaration to the namespace. * Adds a declaration to the namespace.
* *
* @param declaration * @param declaration <code>IASTDeclaration</code>
* <code>IASTDeclaration</code>
*/ */
@Override
public void addDeclaration(IASTDeclaration declaration); public void addDeclaration(IASTDeclaration declaration);
/** /**
* Get the scope object represented by this construct. * Returns the scope object represented by this construct.
* *
* @return <code>IScope</code> * @return <code>IScope</code>
*/ */
@ -92,10 +91,12 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICPPASTNamespaceDefinition copy(); public ICPPASTNamespaceDefinition copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public ICPPASTNamespaceDefinition copy(CopyStyle style); public ICPPASTNamespaceDefinition copy(CopyStyle style);
} }

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * 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; package org.eclipse.cdt.internal.core.dom.parser;
@ -17,32 +17,31 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
/** /**
* @author Emanuel Graf IFS * @author Emanuel Graf IFS
*
*/ */
public class ASTCopyLocation implements IASTCopyLocation { public class ASTCopyLocation implements IASTCopyLocation {
private IASTNode originalNode; private IASTNode originalNode;
public ASTCopyLocation(IASTNode originalNode) { public ASTCopyLocation(IASTNode originalNode) {
this.originalNode = originalNode; this.originalNode = originalNode;
} }
@Override
public int getNodeOffset() { public int getNodeOffset() {
return 0; return 0;
} }
@Override
public int getNodeLength() { public int getNodeLength() {
return 0; return 0;
} }
@Override
public IASTFileLocation asFileLocation() { public IASTFileLocation asFileLocation() {
return null; return null;
} }
@Override
public IASTNode getOriginalNode() { public IASTNode getOriginalNode() {
return originalNode; return originalNode;
} }
} }

View file

@ -40,6 +40,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
} }
@Override
public void setName(IASTName name) { public void setName(IASTName name) {
assertNotFrozen(); assertNotFrozen();
this.name = name; 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; return name;
} }
public void setValue(IASTExpression expression) { @Override
public void setValue(IASTExpression expression) {
assertNotFrozen(); assertNotFrozen();
this.value = expression; this.value = expression;
if (expression != null) { 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; return value;
} }
@ -87,6 +91,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
return true; return true;
} }
@Override
public int getRoleForName(IASTName n) { public int getRoleForName(IASTName n) {
if (n == name) if (n == name)
return r_definition; return r_definition;
@ -94,7 +99,8 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
return r_reference; return r_reference;
} }
public void replace(IASTNode child, IASTNode other) { @Override
public void replace(IASTNode child, IASTNode other) {
if (child == value) { if (child == value) {
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent()); other.setParent(child.getParent());

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -32,11 +32,13 @@ public abstract class ASTEqualsInitializer extends ASTNode implements IASTEquals
setInitializerClause(arg); setInitializerClause(arg);
} }
@Override
public IASTInitializerClause getInitializerClause() { public IASTInitializerClause getInitializerClause() {
return fArgument; return fArgument;
} }
public void setInitializerClause(IASTInitializerClause clause) { @Override
public void setInitializerClause(IASTInitializerClause clause) {
assertNotFrozen(); assertNotFrozen();
fArgument = clause; fArgument = clause;
if (clause != null) { if (clause != null) {
@ -64,6 +66,7 @@ public abstract class ASTEqualsInitializer extends ASTNode implements IASTEquals
return true; return true;
} }
@Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if (child == fArgument) { if (child == fArgument) {
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon - Initial API and implementation * John Camelon - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -42,23 +42,29 @@ public abstract class ASTNode implements IASTNode {
private int length; private int length;
private int offset; private int offset;
private IASTNodeLocation[] locations;
private IASTFileLocation fileLocation;
private boolean frozen = false; private boolean frozen = false;
private boolean active = true; private boolean active = true;
public IASTNode getParent() { @Override
public IASTNode getParent() {
return parent; return parent;
} }
@Override
public IASTNode[] getChildren() { public IASTNode[] getChildren() {
ChildCollector collector= new ChildCollector(this); ChildCollector collector= new ChildCollector(this);
return collector.getChildren(); return collector.getChildren();
} }
@Override
public boolean isFrozen() { public boolean isFrozen() {
return frozen; return frozen;
} }
@Override
public boolean isActive() { public boolean isActive() {
return active; return active;
} }
@ -78,16 +84,19 @@ public abstract class ASTNode implements IASTNode {
throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$
} }
public void setParent(IASTNode node) { @Override
public void setParent(IASTNode node) {
assertNotFrozen(); assertNotFrozen();
this.parent = node; this.parent = node;
} }
public ASTNodeProperty getPropertyInParent() { @Override
public ASTNodeProperty getPropertyInParent() {
return property; return property;
} }
public void setPropertyInParent(ASTNodeProperty property) { @Override
public void setPropertyInParent(ASTNodeProperty property) {
assertNotFrozen(); assertNotFrozen();
this.property = property; this.property = property;
} }
@ -120,10 +129,8 @@ public abstract class ASTNode implements IASTNode {
setOffsetAndLength(node.getOffset(), node.getLength()); setOffsetAndLength(node.getOffset(), node.getLength());
} }
private IASTNodeLocation[] locations = null; @Override
private IASTFileLocation fileLocation = null; public IASTNodeLocation[] getNodeLocations() {
public IASTNodeLocation[] getNodeLocations() {
if (locations != null) if (locations != null)
return locations; return locations;
if (length == 0) { if (length == 0) {
@ -163,11 +170,13 @@ public abstract class ASTNode implements IASTNode {
return CharArrayUtils.EMPTY; return CharArrayUtils.EMPTY;
} }
public String getRawSignature() { @Override
public String getRawSignature() {
return new String(getRawSignatureChars()); return new String(getRawSignatureChars());
} }
public String getContainingFilename() { @Override
public String getContainingFilename() {
if (offset <= 0 && (length == 0 || offset < 0)) { if (offset <= 0 && (length == 0 || offset < 0)) {
final IASTNode parent = getParent(); final IASTNode parent = getParent();
if (parent == null) { if (parent == null) {
@ -181,7 +190,8 @@ public abstract class ASTNode implements IASTNode {
return getTranslationUnit().getContainingFilename(offset); return getTranslationUnit().getContainingFilename(offset);
} }
public IASTFileLocation getFileLocation() { @Override
public IASTFileLocation getFileLocation() {
if (fileLocation != null) if (fileLocation != null)
return fileLocation; return fileLocation;
// TODO(sprigogin): The purpose of offset == 0 && length == 0 condition is not clear to me. // 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; return fileLocation;
} }
public boolean isPartOfTranslationUnitFile() { @Override
public boolean isPartOfTranslationUnitFile() {
IASTTranslationUnit ast = getTranslationUnit(); IASTTranslationUnit ast = getTranslationUnit();
if (ast != null) { if (ast != null) {
ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class); ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class);
@ -223,15 +234,18 @@ public abstract class ASTNode implements IASTNode {
return false; return false;
} }
public IASTTranslationUnit getTranslationUnit() { @Override
public IASTTranslationUnit getTranslationUnit() {
return parent != null ? parent.getTranslationUnit() : null; return parent != null ? parent.getTranslationUnit() : null;
} }
public boolean accept(ASTVisitor visitor) { @Override
public boolean accept(ASTVisitor visitor) {
return true; return true;
} }
public boolean contains(IASTNode node) { @Override
public boolean contains(IASTNode node) {
if (node instanceof ASTNode) { if (node instanceof ASTNode) {
ASTNode astNode= (ASTNode) node; ASTNode astNode= (ASTNode) node;
return offset <= astNode.offset && return offset <= astNode.offset &&
@ -240,15 +254,18 @@ public abstract class ASTNode implements IASTNode {
return false; return false;
} }
@Override
public IToken getSyntax() throws ExpansionOverlapsBoundaryException { public IToken getSyntax() throws ExpansionOverlapsBoundaryException {
return getSyntax(offset, offset+length, 0); return getSyntax(offset, offset+length, 0);
} }
@Override
public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException { public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException {
int left= getBoundary(-1); int left= getBoundary(-1);
return getSyntax(left, offset, -1); return getSyntax(left, offset, -1);
} }
@Override
public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException { public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException {
int right= getBoundary(1); int right= getBoundary(1);
return getSyntax(offset+length, right, 1); return getSyntax(offset+length, right, 1);
@ -346,5 +363,4 @@ public abstract class ASTNode implements IASTNode {
protected void setCopyLocation(IASTNode originalNode) { protected void setCopyLocation(IASTNode originalNode) {
locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)}; locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)};
} }
} }

View file

@ -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.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
* @since 5.0 * @since 5.0
*/ */
public class ASTNodeSelector implements IASTNodeSelector { public class ASTNodeSelector implements IASTNodeSelector {
private ASTTranslationUnit fTu; private ASTTranslationUnit fTu;
private ILocationResolver fLocationResolver; private ILocationResolver fLocationResolver;
private String fFilePath; private String fFilePath;
@ -74,7 +73,7 @@ public class ASTNodeSelector implements IASTNodeSelector {
sequenceLength= 0; sequenceLength= 0;
if (offsetInFile > 0) { if (offsetInFile > 0) {
altSequenceNumber= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, offsetInFile-1); altSequenceNumber= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, offsetInFile-1);
if (altSequenceNumber+1 == sequenceNumber) { if (altSequenceNumber + 1 == sequenceNumber) {
altSequenceNumber= -1; altSequenceNumber= -1;
} else { } else {
// we are on a context boundary and we need to check the variant to the left and // 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(); return nodeSpec.getBestNode();
} }
@Override
public IASTNode findFirstContainedNode(int offset, int length) { public IASTNode findFirstContainedNode(int offset, int length) {
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class); return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class);
} }
@Override
public IASTNode findNode(int offset, int length) { public IASTNode findNode(int offset, int length) {
return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class); return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class);
} }
@Override
public IASTNode findEnclosingNode(int offset, int length) { public IASTNode findEnclosingNode(int offset, int length) {
return findNode(offset, length, Relation.ENCLOSING, IASTNode.class); return findNode(offset, length, Relation.ENCLOSING, IASTNode.class);
} }
@Override
public IASTNode findStrictlyEnclosingNode(int offset, int length) { public IASTNode findStrictlyEnclosingNode(int offset, int length) {
return findNode(offset, length, Relation.STRICTLY_ENCLOSING, IASTNode.class); return findNode(offset, length, Relation.STRICTLY_ENCLOSING, IASTNode.class);
} }
@Override
public IASTNode findFirstContainedNodeInExpansion(int offset, int length) { public IASTNode findFirstContainedNodeInExpansion(int offset, int length) {
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class, true); return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class, true);
} }
@Override
public IASTNode findNodeInExpansion(int offset, int length) { public IASTNode findNodeInExpansion(int offset, int length) {
return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class, true); return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class, true);
} }
@Override
public IASTNode findEnclosingNodeInExpansion(int offset, int length) { public IASTNode findEnclosingNodeInExpansion(int offset, int length) {
return findNode(offset, length, Relation.ENCLOSING, IASTNode.class, true); return findNode(offset, length, Relation.ENCLOSING, IASTNode.class, true);
} }
@Override
public IASTName findFirstContainedName(int offset, int length) { public IASTName findFirstContainedName(int offset, int length) {
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTName.class); return findNode(offset, length, Relation.FIRST_CONTAINED, IASTName.class);
} }
@Override
public IASTName findName(int offset, int length) { public IASTName findName(int offset, int length) {
return findNode(offset, length, Relation.EXACT_MATCH, IASTName.class); return findNode(offset, length, Relation.EXACT_MATCH, IASTName.class);
} }
@Override
public IASTName findEnclosingName(int offset, int length) { public IASTName findEnclosingName(int offset, int length) {
return findNode(offset, length, Relation.ENCLOSING, IASTName.class); return findNode(offset, length, Relation.ENCLOSING, IASTName.class);
} }
@Override
public IASTImplicitName findImplicitName(int offset, int length) { public IASTImplicitName findImplicitName(int offset, int length) {
return findNode(offset, length, Relation.EXACT_MATCH, IASTImplicitName.class); return findNode(offset, length, Relation.EXACT_MATCH, IASTImplicitName.class);
} }
@Override
public IASTImplicitName findEnclosingImplicitName(int offset, int length) { public IASTImplicitName findEnclosingImplicitName(int offset, int length) {
return findNode(offset, length, Relation.ENCLOSING, IASTImplicitName.class); return findNode(offset, length, Relation.ENCLOSING, IASTImplicitName.class);
} }
@Override
public IASTPreprocessorMacroExpansion findEnclosingMacroExpansion(int offset, int length) { public IASTPreprocessorMacroExpansion findEnclosingMacroExpansion(int offset, int length) {
return findNode(offset, length, Relation.ENCLOSING, IASTPreprocessorMacroExpansion.class); return findNode(offset, length, Relation.ENCLOSING, IASTPreprocessorMacroExpansion.class);
} }

View file

@ -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.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -41,12 +41,12 @@ public class ASTNodeSpecification<T extends IASTNode> {
fRelation= relation; fRelation= relation;
fClass= clazz; fClass= clazz;
fFileOffset= fileOffset; fFileOffset= fileOffset;
fFileEndOffset= fileOffset+fileLength; fFileEndOffset= fileOffset + fileLength;
} }
public void setRangeInSequence(int offsetInSeq, int lengthInSeq) { public void setRangeInSequence(int offsetInSeq, int lengthInSeq) {
fSeqNumber= offsetInSeq; fSeqNumber= offsetInSeq;
fSeqEndNumber= offsetInSeq+lengthInSeq; fSeqEndNumber= offsetInSeq + lengthInSeq;
} }
public void setRangeInSequence(int offsetInSeq, int lengthInSeq, boolean zeroRangeToLeft) { public void setRangeInSequence(int offsetInSeq, int lengthInSeq, boolean zeroRangeToLeft) {

View file

@ -6,9 +6,9 @@
* 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
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; 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; import com.ibm.icu.text.MessageFormat;
/** /**
* Models problems, all problems should derive from this class. * Models problems, all problems should derive from this class.
*/ */
public class ASTProblem extends ASTNode implements IASTProblem { 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<Integer, String> errorMessages; protected static final Map<Integer, String> errorMessages;
static { static {
errorMessages = new HashMap<Integer, String>(); errorMessages = new HashMap<Integer, String>();
@ -179,16 +94,104 @@ public class ASTProblem extends ASTNode implements IASTProblem {
ParserMessages.getString("ParserProblemFactory.error.syntax.missingSemicolon")); //$NON-NLS-1$ ParserMessages.getString("ParserProblemFactory.error.syntax.missingSemicolon")); //$NON-NLS-1$
} }
/* private final int id;
* @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName() 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() { public char[] getOriginatingFileName() {
return getContainingFilename().toCharArray(); return getContainingFilename().toCharArray();
} }
/* @Override
* @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd()
*/
public int getSourceEnd() { public int getSourceEnd() {
final IASTFileLocation location= getFileLocation(); final IASTFileLocation location= getFileLocation();
if (location != null) { if (location != null) {
@ -197,9 +200,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
return INT_VALUE_NOT_PROVIDED; return INT_VALUE_NOT_PROVIDED;
} }
/* @Override
* @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber()
*/
public int getSourceLineNumber() { public int getSourceLineNumber() {
final IASTFileLocation location= getFileLocation(); final IASTFileLocation location= getFileLocation();
if (location != null) { if (location != null) {
@ -208,9 +209,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
return INT_VALUE_NOT_PROVIDED; return INT_VALUE_NOT_PROVIDED;
} }
/* @Override
* @see org.eclipse.cdt.core.parser.IProblem#getSourceStart()
*/
public int getSourceStart() { public int getSourceStart() {
final IASTFileLocation location= getFileLocation(); final IASTFileLocation location= getFileLocation();
if (location != null) { if (location != null) {

View file

@ -6,9 +6,9 @@
* 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
* Yuan Zhang / Beth Tibbitts (IBM Research) * Yuan Zhang / Beth Tibbitts (IBM Research)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -41,11 +41,13 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements
} }
} }
@Override
public IASTTypeId getTypeId() { public IASTTypeId getTypeId() {
return typeId; return typeId;
} }
public void setTypeId(IASTTypeId typeId) { @Override
public void setTypeId(IASTTypeId typeId) {
assertNotFrozen(); assertNotFrozen();
this.typeId = typeId; this.typeId = typeId;
if (typeId != null) { if (typeId != null) {
@ -54,11 +56,13 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements
} }
} }
public IASTInitializer getInitializer() { @Override
public IASTInitializer getInitializer() {
return initializer; return initializer;
} }
public void setInitializer(IASTInitializer initializer) { @Override
public void setInitializer(IASTInitializer initializer) {
assertNotFrozen(); assertNotFrozen();
this.initializer = initializer; this.initializer = initializer;
if (initializer != null) { if (initializer != null) {
@ -68,32 +72,34 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitExpressions ){ if (action.shouldVisitExpressions) {
switch( action.visit( this ) ){ switch(action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if( typeId != null ) if( !typeId.accept( action ) ) return false; if (typeId != null && !typeId.accept(action)) return false;
if( initializer != null ) if( !initializer.accept( action ) ) return false; if (initializer != null && !initializer.accept(action)) return false;
if( action.shouldVisitExpressions ){ if (action.shouldVisitExpressions) {
switch( action.leave( this ) ){ switch(action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
} }
@Override
public final boolean isLValue() { public final boolean isLValue() {
return false; return false;
} }
@Override
public final ValueCategory getValueCategory() { public final ValueCategory getValueCategory() {
return ValueCategory.PRVALUE; return ValueCategory.PRVALUE;
} }

View file

@ -6,10 +6,10 @@
* 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)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -63,7 +63,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
private static final Map<String, char[]> CHAR_ARRAYS = new HashMap<String, char[]>(); private static final Map<String, char[]> CHAR_ARRAYS = new HashMap<String, char[]>();
private IBinding[] fBindings; private IBinding[] fBindings;
private IScope fScope= null; private IScope fScope;
private final boolean fCpp; private final boolean fCpp;
private final boolean fGnu; private final boolean fGnu;
@ -75,6 +75,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
fGnu= supportGnuSymbols; fGnu= supportGnuSymbols;
} }
@Override
public IBinding[] getBuiltinBindings(IScope scope) { public IBinding[] getBuiltinBindings(IScope scope) {
fScope= scope; fScope= scope;
initialize(); initialize();

View file

@ -6,29 +6,31 @@
* 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.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; 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 { public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier {
/** /**
* Notifies that the value computation for the enumeration is started. Returns whether this is the * Notifies that the value computation for the enumeration is started. Returns whether this is
* first attempt to do so. * the first attempt to do so.
*/ */
boolean startValueComputation(); boolean startValueComputation();
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public IASTInternalEnumerationSpecifier copy(); public IASTInternalEnumerationSpecifier copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public IASTInternalEnumerationSpecifier copy(CopyStyle style); public IASTInternalEnumerationSpecifier copy(CopyStyle style);
} }

View file

@ -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.dom.parser; 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 { public abstract class NodeFactory implements INodeFactory {
@Override
public final void setOffsets(IASTNode node, int offset, int endOffset) { public final void setOffsets(IASTNode node, int offset, int endOffset) {
((ASTNode) node).setOffsetAndLength(offset, endOffset-offset); ((ASTNode) node).setOffsetAndLength(offset, endOffset-offset);
} }
@Override
public final void setEndOffset(IASTNode node, int endOffset) { public final void setEndOffset(IASTNode node, int endOffset) {
ASTNode a= (ASTNode) node; ASTNode a= (ASTNode) node;
a.setLength(endOffset - a.getOffset()); a.setLength(endOffset - a.getOffset());
} }
@Override
public final void setEndOffset(IASTNode node, IASTNode endNode) { public final void setEndOffset(IASTNode node, IASTNode endNode) {
ASTNode a= (ASTNode) node; ASTNode a= (ASTNode) node;
ASTNode e= (ASTNode) endNode; ASTNode e= (ASTNode) endNode;

View file

@ -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.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -36,26 +36,32 @@ public class ProblemFunctionType extends ProblemType implements ICPPFunctionType
return new ProblemFunctionType(buffer.getShort()); return new ProblemFunctionType(buffer.getShort());
} }
@Override
public IType getReturnType() { public IType getReturnType() {
return new ProblemType(getID()); return new ProblemType(getID());
} }
@Override
public IType[] getParameterTypes() { public IType[] getParameterTypes() {
return new IType[] {new ProblemType(getID())}; return new IType[] {new ProblemType(getID())};
} }
@Override
public boolean isConst() { public boolean isConst() {
return false; return false;
} }
@Override
public boolean isVolatile() { public boolean isVolatile() {
return false; return false;
} }
@Override
public boolean takesVarArgs() { public boolean takesVarArgs() {
return false; return false;
} }
@Override
public IPointerType getThisType() { public IPointerType getThisType() {
return new CPPPointerType(new ProblemType(getID())); return new CPPPointerType(new ProblemType(getID()));
} }

View file

@ -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.dom.parser; 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.cdt.internal.core.parser.ParserMessages;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* Implementation of problem types. * Implementation of problem types.
*/ */
@ -28,14 +27,17 @@ public class ProblemType implements IProblemType, ISerializableType {
fID= id; fID= id;
} }
@Override
public int getID() { public int getID() {
return fID; return fID;
} }
@Override
public String getMessage() { public String getMessage() {
return ParserMessages.getProblemPattern(this); return ParserMessages.getProblemPattern(this);
} }
@Override
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
return type == this; return type == this;
} }
@ -49,6 +51,7 @@ public class ProblemType implements IProblemType, ISerializableType {
} }
} }
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException { public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE); buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE);
buffer.putShort((short) getID()); buffer.putShort((short) getID());

View file

@ -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.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
* @author jcamelon * @author jcamelon
*/ */
public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent { public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent {
private boolean isCatchAll; private boolean isCatchAll;
private IASTStatement body; private IASTStatement body;
private IASTDeclaration declaration; private IASTDeclaration declaration;
@ -38,10 +37,12 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
setDeclaration(declaration); setDeclaration(declaration);
} }
@Override
public CPPASTCatchHandler copy() { public CPPASTCatchHandler copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CPPASTCatchHandler copy(CopyStyle style) { public CPPASTCatchHandler copy(CopyStyle style) {
CPPASTCatchHandler copy = new CPPASTCatchHandler(); CPPASTCatchHandler copy = new CPPASTCatchHandler();
copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setDeclaration(declaration == null ? null : declaration.copy(style));
@ -54,16 +55,19 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
return copy; return copy;
} }
@Override
public void setIsCatchAll(boolean isEllipsis) { public void setIsCatchAll(boolean isEllipsis) {
assertNotFrozen(); assertNotFrozen();
isCatchAll = isEllipsis; isCatchAll = isEllipsis;
} }
public boolean isCatchAll() { @Override
public boolean isCatchAll() {
return isCatchAll; return isCatchAll;
} }
public void setCatchBody(IASTStatement compoundStatement) { @Override
public void setCatchBody(IASTStatement compoundStatement) {
assertNotFrozen(); assertNotFrozen();
body = compoundStatement; body = compoundStatement;
if (compoundStatement != null) { if (compoundStatement != null) {
@ -72,11 +76,13 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
} }
} }
public IASTStatement getCatchBody() { @Override
public IASTStatement getCatchBody() {
return body; return body;
} }
public void setDeclaration(IASTDeclaration decl) { @Override
public void setDeclaration(IASTDeclaration decl) {
assertNotFrozen(); assertNotFrozen();
declaration = decl; declaration = decl;
if (decl != null) { if (decl != null) {
@ -85,48 +91,48 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
} }
} }
public IASTDeclaration getDeclaration() { @Override
public IASTDeclaration getDeclaration() {
return declaration; return declaration;
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitStatements ){ if (action.shouldVisitStatements) {
switch( action.visit( this ) ){ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if( declaration != null ) if( !declaration.accept( action ) ) return false; if (declaration != null && !declaration.accept(action)) return false;
if( body != null ) if( !body.accept( action ) ) return false; if (body != null && !body.accept(action)) return false;
if( action.shouldVisitStatements ){ if (action.shouldVisitStatements) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
} }
public void replace(IASTNode child, IASTNode other) { @Override
if( body == child ) public void replace(IASTNode child, IASTNode other) {
{ if (body == child) {
other.setPropertyInParent( child.getPropertyInParent() ); other.setPropertyInParent(child.getPropertyInParent());
other.setParent( child.getParent() ); other.setParent(child.getParent());
body = (IASTStatement) other; body = (IASTStatement) other;
} }
if( declaration == child ) if (declaration == child) {
{ other.setParent(child.getParent());
other.setParent( child.getParent() ); other.setPropertyInParent(child.getPropertyInParent());
other.setPropertyInParent( child.getPropertyInParent() );
declaration = (IASTDeclaration) other; declaration = (IASTDeclaration) other;
} }
} }
@Override
public IScope getScope() { public IScope getScope() {
if (scope == null) { if (scope == null) {
scope = new CPPBlockScope(this); scope = new CPPBlockScope(this);

View file

@ -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.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -77,6 +77,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
return copy; return copy;
} }
@Override
public ICPPASTParameterDeclaration[] getParameters() { public ICPPASTParameterDeclaration[] getParameters() {
if (parameters == null) if (parameters == null)
return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY; return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY;
@ -84,7 +85,8 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
return parameters= ArrayUtil.trim(parameters); return parameters= ArrayUtil.trim(parameters);
} }
public void addParameterDeclaration(IASTParameterDeclaration parameter) { @Override
public void addParameterDeclaration(IASTParameterDeclaration parameter) {
assertNotFrozen(); assertNotFrozen();
if (parameter != null) { if (parameter != null) {
parameter.setParent(this); parameter.setParent(this);
@ -93,52 +95,63 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
} }
} }
public boolean takesVarArgs() { @Override
public boolean takesVarArgs() {
return varArgs; return varArgs;
} }
public void setVarArgs(boolean value) { @Override
public void setVarArgs(boolean value) {
assertNotFrozen(); assertNotFrozen();
varArgs = value; varArgs = value;
} }
public boolean isConst() { @Override
public boolean isConst() {
return isConst; return isConst;
} }
public void setConst(boolean value) { @Override
public void setConst(boolean value) {
assertNotFrozen(); assertNotFrozen();
this.isConst = value; this.isConst = value;
} }
public boolean isVolatile() { @Override
public boolean isVolatile() {
return isVolatile; return isVolatile;
} }
public void setVolatile(boolean value) { @Override
public void setVolatile(boolean value) {
assertNotFrozen(); assertNotFrozen();
this.isVolatile = value; this.isVolatile = value;
} }
public boolean isMutable() { @Override
public boolean isMutable() {
return isMutable; return isMutable;
} }
public void setMutable(boolean value) { @Override
public void setMutable(boolean value) {
assertNotFrozen(); assertNotFrozen();
this.isMutable = value; this.isMutable = value;
} }
public IASTTypeId[] getExceptionSpecification() { @Override
public IASTTypeId[] getExceptionSpecification() {
return typeIds= ArrayUtil.trim(typeIds); return typeIds= ArrayUtil.trim(typeIds);
} }
public void setEmptyExceptionSpecification() { @Override
public void setEmptyExceptionSpecification() {
assertNotFrozen(); assertNotFrozen();
typeIds= IASTTypeId.EMPTY_TYPEID_ARRAY; typeIds= IASTTypeId.EMPTY_TYPEID_ARRAY;
} }
public void addExceptionSpecificationTypeId(IASTTypeId typeId) { @Override
public void addExceptionSpecificationTypeId(IASTTypeId typeId) {
assertNotFrozen(); assertNotFrozen();
if (typeId != null) { if (typeId != null) {
assert typeIds != null; assert typeIds != null;
@ -147,12 +160,13 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
typeId.setPropertyInParent(EXCEPTION_TYPEID); typeId.setPropertyInParent(EXCEPTION_TYPEID);
} }
} }
public IASTTypeId getTrailingReturnType() { @Override
public IASTTypeId getTrailingReturnType() {
return trailingReturnType; return trailingReturnType;
} }
@Override
public void setTrailingReturnType(IASTTypeId typeId) { public void setTrailingReturnType(IASTTypeId typeId) {
assertNotFrozen(); assertNotFrozen();
trailingReturnType= typeId; trailingReturnType= typeId;
@ -162,20 +176,23 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
} }
} }
@Override
public boolean isPureVirtual() { public boolean isPureVirtual() {
return pureVirtual; return pureVirtual;
} }
public void setPureVirtual(boolean isPureVirtual) { @Override
public void setPureVirtual(boolean isPureVirtual) {
assertNotFrozen(); assertNotFrozen();
this.pureVirtual = isPureVirtual; this.pureVirtual = isPureVirtual;
} }
@Deprecated @Override
@Deprecated
public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() { public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() {
if (ASTQueries.findTypeRelevantDeclarator(this) == this) { if (ASTQueries.findTypeRelevantDeclarator(this) == this) {
IASTNode parent= getParent(); IASTNode parent= getParent();
while(!(parent instanceof IASTDeclaration)) { while (!(parent instanceof IASTDeclaration)) {
if (parent == null) if (parent == null)
break; break;
parent= parent.getParent(); 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; 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) { public void addConstructorToChain(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer initializer) {
assertNotFrozen(); assertNotFrozen();
} }
public ICPPFunctionScope getFunctionScope() { @Override
public ICPPFunctionScope getFunctionScope() {
if (scope != null) if (scope != null)
return scope; return scope;
// introduce a scope for function declarations and definitions, only. // introduce a scope for function declarations and definitions, only.
IASTNode node= getParent(); IASTNode node= getParent();
while(!(node instanceof IASTDeclaration)) { while (!(node instanceof IASTDeclaration)) {
if (node==null) if (node==null)
return null; return null;
node= node.getParent(); node= node.getParent();
@ -232,6 +251,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
return super.postAccept(action); return super.postAccept(action);
} }
@Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if (parameters != null) { if (parameters != null) {
for (int i = 0; i < parameters.length; ++i) { for (int i = 0; i < parameters.length; ++i) {

View file

@ -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.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -24,7 +24,9 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
* @see ICPPASTFunctionWithTryBlock * @see ICPPASTFunctionWithTryBlock
*/ */
public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition implements ICPPASTFunctionWithTryBlock { public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition implements ICPPASTFunctionWithTryBlock {
private ICPPASTCatchHandler[] catchHandlers;
private int catchHandlersPos= -1;
public CPPASTFunctionWithTryBlock() { public CPPASTFunctionWithTryBlock() {
} }
@ -49,10 +51,12 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme
copy.setDeclarator(declarator == null ? null : declarator.copy(style)); copy.setDeclarator(declarator == null ? null : declarator.copy(style));
copy.setBody(bodyStatement == null ? null : bodyStatement.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)); 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.addCatchHandler(handler == null ? null : handler.copy(style));
}
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) { if (style == CopyStyle.withLocations) {
@ -61,29 +65,27 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme
return copy; return copy;
} }
@Override
public void addCatchHandler(ICPPASTCatchHandler statement) { public void addCatchHandler(ICPPASTCatchHandler statement) {
assertNotFrozen(); assertNotFrozen();
if (statement != null) { 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.setParent(this);
statement.setPropertyInParent(CATCH_HANDLER); statement.setPropertyInParent(CATCH_HANDLER);
} }
} }
public ICPPASTCatchHandler [] getCatchHandlers() { @Override
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; public ICPPASTCatchHandler[] getCatchHandlers() {
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos ); if (catchHandlers == null) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter(ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos);
return catchHandlers; return catchHandlers;
} }
private ICPPASTCatchHandler [] catchHandlers = null;
private int catchHandlersPos=-1;
@Override @Override
protected boolean acceptCatchHandlers( ASTVisitor action ){ protected boolean acceptCatchHandlers(ASTVisitor action) {
final ICPPASTCatchHandler [] handlers = getCatchHandlers(); final ICPPASTCatchHandler[] handlers = getCatchHandlers();
for (int i=0; i<handlers.length; i++) { for (int i= 0; i < handlers.length; i++) {
if (!handlers[i].accept(action)) if (!handlers[i].accept(action))
return false; return false;
} }

View file

@ -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.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -32,10 +32,12 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
setDeclSpecifier(declSpecifier); setDeclSpecifier(declSpecifier);
} }
@Override
public CPPASTSimpleDeclaration copy() { public CPPASTSimpleDeclaration copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CPPASTSimpleDeclaration copy(CopyStyle style) { public CPPASTSimpleDeclaration copy(CopyStyle style) {
CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration(); CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration();
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
@ -48,17 +50,21 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
return copy; return copy;
} }
@Override
public IASTDeclSpecifier getDeclSpecifier() { public IASTDeclSpecifier getDeclSpecifier() {
return declSpecifier; return declSpecifier;
} }
public IASTDeclarator[] getDeclarators() { @Override
if (declarators == null) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY; public IASTDeclarator[] getDeclarators() {
if (declarators == null)
return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, declarators, declaratorsPos); declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, declarators, declaratorsPos);
return declarators; return declarators;
} }
public void addDeclarator(IASTDeclarator d) { @Override
public void addDeclarator(IASTDeclarator d) {
assertNotFrozen(); assertNotFrozen();
if (d != null) { if (d != null) {
declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, ++declaratorsPos, d); declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, ++declaratorsPos, d);
@ -67,14 +73,15 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
} }
} }
private IASTDeclarator[] declarators = null; private IASTDeclarator[] declarators;
private int declaratorsPos = -1; private int declaratorsPos = -1;
private IASTDeclSpecifier declSpecifier; private IASTDeclSpecifier declSpecifier;
/** /**
* @param declSpecifier The declSpecifier to set. * @param declSpecifier The declSpecifier to set.
*/ */
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) { @Override
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
assertNotFrozen(); assertNotFrozen();
this.declSpecifier = declSpecifier; this.declSpecifier = declSpecifier;
if (declSpecifier != null) { if (declSpecifier != null) {
@ -93,10 +100,12 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
} }
} }
if (declSpecifier != null) if (!declSpecifier.accept(action)) return false; if (declSpecifier != null && !declSpecifier.accept(action)) return false;
IASTDeclarator[] dtors = getDeclarators(); IASTDeclarator[] dtors = getDeclarators();
for (int i = 0; i < dtors.length; i++) for (int i = 0; i < dtors.length; i++) {
if (!dtors[i].accept(action)) return false; if (!dtors[i].accept(action))
return false;
}
if (action.shouldVisitDeclarations) { if (action.shouldVisitDeclarations) {
switch (action.leave(this)) { switch (action.leave(this)) {
@ -108,7 +117,8 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
return true; return true;
} }
public void replace(IASTNode child, IASTNode other) { @Override
public void replace(IASTNode child, IASTNode other) {
IASTDeclarator[] declarators = getDeclarators(); IASTDeclarator[] declarators = getDeclarators();
for (int i = 0; i < declarators.length; i++) { for (int i = 0; i < declarators.length; i++) {
if (declarators[i] == child) { if (declarators[i] == child) {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -24,7 +24,6 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
private IASTDeclSpecifier declSpec; private IASTDeclSpecifier declSpec;
private IASTDeclarator absDecl; private IASTDeclarator absDecl;
private boolean isPackExpansion; private boolean isPackExpansion;
public CPPASTTypeId() { public CPPASTTypeId() {
} }
@ -34,10 +33,12 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
setAbstractDeclarator(absDecl); setAbstractDeclarator(absDecl);
} }
@Override
public CPPASTTypeId copy() { public CPPASTTypeId copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CPPASTTypeId copy(CopyStyle style) { public CPPASTTypeId copy(CopyStyle style) {
CPPASTTypeId copy = new CPPASTTypeId(); CPPASTTypeId copy = new CPPASTTypeId();
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style)); copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
@ -50,11 +51,13 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
return copy; return copy;
} }
@Override
public IASTDeclSpecifier getDeclSpecifier() { public IASTDeclSpecifier getDeclSpecifier() {
return declSpec; return declSpec;
} }
public void setDeclSpecifier(IASTDeclSpecifier declSpec) { @Override
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
assertNotFrozen(); assertNotFrozen();
this.declSpec = declSpec; this.declSpec = declSpec;
if (declSpec != null) { if (declSpec != null) {
@ -63,12 +66,13 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
} }
} }
public IASTDeclarator getAbstractDeclarator() { @Override
public IASTDeclarator getAbstractDeclarator() {
return absDecl; return absDecl;
} }
@Override
public void setAbstractDeclarator(IASTDeclarator abstractDeclarator) { public void setAbstractDeclarator(IASTDeclarator abstractDeclarator) {
assertNotFrozen(); assertNotFrozen();
this.absDecl = abstractDeclarator; this.absDecl = abstractDeclarator;
if (abstractDeclarator != null) { if (abstractDeclarator != null) {
@ -77,10 +81,12 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
} }
} }
public boolean isPackExpansion() { @Override
public boolean isPackExpansion() {
return isPackExpansion; return isPackExpansion;
} }
@Override
public void setIsPackExpansion(boolean val) { public void setIsPackExpansion(boolean val) {
isPackExpansion= val; isPackExpansion= val;
} }

View file

@ -68,6 +68,7 @@ public class LocationMap implements ILocationResolver {
fLexerOptions= lexOptions; fLexerOptions= lexOptions;
} }
@Override
public LexerOptions getLexerOptions() { public LexerOptions getLexerOptions() {
return fLexerOptions; return fLexerOptions;
} }
@ -382,6 +383,7 @@ public class LocationMap implements ILocationResolver {
addMacroReference(undef.getMacroName()); addMacroReference(undef.getMacroName());
} }
@Override
public void setRootNode(IASTTranslationUnit root) { public void setRootNode(IASTTranslationUnit root) {
fTranslationUnit= root; fTranslationUnit= root;
if (fTranslationUnit instanceof ISkippedIndexedFilesListener) { if (fTranslationUnit instanceof ISkippedIndexedFilesListener) {
@ -389,6 +391,7 @@ public class LocationMap implements ILocationResolver {
} }
} }
@Override
public String getTranslationUnitPath() { public String getTranslationUnitPath() {
return fTranslationUnitPath; return fTranslationUnitPath;
} }
@ -418,11 +421,13 @@ public class LocationMap implements ILocationResolver {
return fCurrentContext.getSequenceNumberForOffset(offset, offset < fLastChildInsertionOffset); return fCurrentContext.getSequenceNumberForOffset(offset, offset < fLastChildInsertionOffset);
} }
@Override
public String getContainingFilePath(int sequenceNumber) { public String getContainingFilePath(int sequenceNumber) {
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1); LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
return new String(ctx.getFilePath()); return new String(ctx.getFilePath());
} }
@Override
public boolean isPartOfSourceFile(int sequenceNumber) { public boolean isPartOfSourceFile(int sequenceNumber) {
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1); LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
if (ctx == fRootContext && fTranslationUnit != null) if (ctx == fRootContext && fTranslationUnit != null)
@ -431,14 +436,17 @@ public class LocationMap implements ILocationResolver {
return ctx.isSourceFile(); return ctx.isSourceFile();
} }
@Override
public ASTFileLocation getMappedFileLocation(int sequenceNumber, int length) { public ASTFileLocation getMappedFileLocation(int sequenceNumber, int length) {
return fRootContext.findMappedFileLocation(sequenceNumber, length); return fRootContext.findMappedFileLocation(sequenceNumber, length);
} }
public int convertToSequenceEndNumber(int sequenceNumber) { @Override
public int convertToSequenceEndNumber(int sequenceNumber) {
return fRootContext.convertToSequenceEndNumber(sequenceNumber); return fRootContext.convertToSequenceEndNumber(sequenceNumber);
} }
@Override
public char[] getUnpreprocessedSignature(IASTFileLocation loc) { public char[] getUnpreprocessedSignature(IASTFileLocation loc) {
ASTFileLocation floc= convertFileLocation(loc); ASTFileLocation floc= convertFileLocation(loc);
if (floc == null) { if (floc == null) {
@ -447,6 +455,7 @@ public class LocationMap implements ILocationResolver {
return floc.getSource(); return floc.getSource();
} }
@Override
public IASTPreprocessorMacroExpansion[] getMacroExpansions(IASTFileLocation loc) { public IASTPreprocessorMacroExpansion[] getMacroExpansions(IASTFileLocation loc) {
ASTFileLocation floc= convertFileLocation(loc); ASTFileLocation floc= convertFileLocation(loc);
if (floc == null) { if (floc == null) {
@ -485,17 +494,19 @@ public class LocationMap implements ILocationResolver {
return getMappedFileLocation(sequenceNumber, length); return getMappedFileLocation(sequenceNumber, length);
} }
@Override
public IASTNodeLocation[] getLocations(int sequenceNumber, int length) { public IASTNodeLocation[] getLocations(int sequenceNumber, int length) {
ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>(); ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>();
fRootContext.collectLocations(sequenceNumber, length, result); fRootContext.collectLocations(sequenceNumber, length, result);
return result.toArray(new IASTNodeLocation[result.size()]); return result.toArray(new IASTNodeLocation[result.size()]);
} }
@Override
public boolean isPartOfTranslationUnitFile(int sequenceNumber) { public boolean isPartOfTranslationUnitFile(int sequenceNumber) {
return fRootContext.isThisFile(sequenceNumber); return fRootContext.isThisFile(sequenceNumber);
} }
@Override
public IASTImageLocation getImageLocation(int sequenceNumber, int length) { public IASTImageLocation getImageLocation(int sequenceNumber, int length) {
ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>(); ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>();
fRootContext.collectLocations(sequenceNumber, length, result); fRootContext.collectLocations(sequenceNumber, length, result);
@ -515,6 +526,7 @@ public class LocationMap implements ILocationResolver {
return null; return null;
} }
@Override
public void findPreprocessorNode(ASTNodeSpecification<?> nodeSpec) { public void findPreprocessorNode(ASTNodeSpecification<?> nodeSpec) {
final int sequenceStart= nodeSpec.getSequenceStart(); final int sequenceStart= nodeSpec.getSequenceStart();
final int sequenceEnd= nodeSpec.getSequenceEnd(); final int sequenceEnd= nodeSpec.getSequenceEnd();
@ -600,6 +612,7 @@ public class LocationMap implements ILocationResolver {
return lower; return lower;
} }
@Override
public int getSequenceNumberForFileOffset(String filePath, int fileOffset) { public int getSequenceNumberForFileOffset(String filePath, int fileOffset) {
LocationCtx ctx= fRootContext; LocationCtx ctx= fRootContext;
if (filePath != null) { if (filePath != null) {
@ -624,6 +637,7 @@ public class LocationMap implements ILocationResolver {
return -1; return -1;
} }
@Override
public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) { public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) {
if (locations.length == 0) { if (locations.length == 0) {
return null; return null;
@ -643,7 +657,7 @@ public class LocationMap implements ILocationResolver {
return null; return null;
} }
@Override
public IASTPreprocessorMacroDefinition[] getMacroDefinitions() { public IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
ArrayList<Object> result= new ArrayList<Object>(); ArrayList<Object> result= new ArrayList<Object>();
for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) { for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) {
@ -655,7 +669,8 @@ public class LocationMap implements ILocationResolver {
return result.toArray(new IASTPreprocessorMacroDefinition[result.size()]); return result.toArray(new IASTPreprocessorMacroDefinition[result.size()]);
} }
public IASTPreprocessorIncludeStatement[] getIncludeDirectives() { @Override
public IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
ArrayList<Object> result= new ArrayList<Object>(); ArrayList<Object> result= new ArrayList<Object>();
for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) { for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) {
Object directive= iterator.next(); Object directive= iterator.next();
@ -666,26 +681,32 @@ public class LocationMap implements ILocationResolver {
return result.toArray(new IASTPreprocessorIncludeStatement[result.size()]); return result.toArray(new IASTPreprocessorIncludeStatement[result.size()]);
} }
@Override
public IASTComment[] getComments() { public IASTComment[] getComments() {
return fComments.toArray(new IASTComment[fComments.size()]); return fComments.toArray(new IASTComment[fComments.size()]);
} }
public IASTPreprocessorStatement[] getAllPreprocessorStatements() { @Override
public IASTPreprocessorStatement[] getAllPreprocessorStatements() {
return fDirectives.toArray(new IASTPreprocessorStatement[fDirectives.size()]); return fDirectives.toArray(new IASTPreprocessorStatement[fDirectives.size()]);
} }
public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() { @Override
public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
return fBuiltinMacros.toArray(new IASTPreprocessorMacroDefinition[fBuiltinMacros.size()]); return fBuiltinMacros.toArray(new IASTPreprocessorMacroDefinition[fBuiltinMacros.size()]);
} }
@Override
public IASTProblem[] getScannerProblems() { public IASTProblem[] getScannerProblems() {
return fProblems.toArray(new IASTProblem[fProblems.size()]); return fProblems.toArray(new IASTProblem[fProblems.size()]);
} }
@Override
public int getScannerProblemsCount() { public int getScannerProblemsCount() {
return fProblems.size(); return fProblems.size();
} }
@Override
public IASTName[] getDeclarations(IMacroBinding binding) { public IASTName[] getDeclarations(IMacroBinding binding) {
IASTPreprocessorMacroDefinition def = getMacroDefinition(binding); IASTPreprocessorMacroDefinition def = getMacroDefinition(binding);
return def == null ? IASTName.EMPTY_NAME_ARRAY: new IASTName[] { def.getName() }; return def == null ? IASTName.EMPTY_NAME_ARRAY: new IASTName[] { def.getName() };
@ -712,6 +733,7 @@ public class LocationMap implements ILocationResolver {
return fMacroDefinitionMap.get(binding); return fMacroDefinitionMap.get(binding);
} }
@Override
public IASTName[] getReferences(IMacroBinding binding) { public IASTName[] getReferences(IMacroBinding binding) {
List<IASTName> result= new ArrayList<IASTName>(); List<IASTName> result= new ArrayList<IASTName>();
for (IASTName name : fMacroReferences) { for (IASTName name : fMacroReferences) {
@ -737,6 +759,7 @@ public class LocationMap implements ILocationResolver {
return result.toArray(new ASTPreprocessorName[result.size()]); return result.toArray(new ASTPreprocessorName[result.size()]);
} }
@Override
public IDependencyTree getDependencyTree() { public IDependencyTree getDependencyTree() {
return new DependencyTree(fRootContext); return new DependencyTree(fRootContext);
} }

View file

@ -7,8 +7,8 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently * Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting unnamed profile fails silently
* Sergey Prigogin, Google * Sergey Prigogin (Google)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences.formatter; 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. * The code formatter preference page.
*/ */
public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock { public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
private static final String FORMATTER_DIALOG_PREFERENCE_KEY= "formatter_page"; //$NON-NLS-1$ 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$ 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(); fCodeStylePreview.update();
} }
@Override
public void update(Observable o, Object arg) { public void update(Observable o, Object arg) {
if (o == fCustomCodeFormatterBlock) { if (o == fCustomCodeFormatterBlock) {
fCodeStylePreview.setFormatterId((String)arg); fCodeStylePreview.setFormatterId((String)arg);
@ -173,5 +173,4 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
} }
return super.performOk(); return super.performOk();
} }
} }