1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

@Override annotations.

This commit is contained in:
Sergey Prigogin 2011-12-29 18:12:31 -08:00
parent 2e5fcb513f
commit da95eb2605
3 changed files with 54 additions and 25 deletions

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;
@ -35,10 +35,10 @@ public class CPPASTFunctionDefinition extends ASTNode
private IASTDeclSpecifier declSpecifier; private IASTDeclSpecifier declSpecifier;
private IASTFunctionDeclarator declarator; private IASTFunctionDeclarator declarator;
private IASTStatement bodyStatement; private IASTStatement bodyStatement;
private ICPPASTConstructorChainInitializer[] memInits = null; private ICPPASTConstructorChainInitializer[] memInits;
private int memInitPos= -1; private int memInitPos= -1;
private boolean fDeleted= false; private boolean fDeleted;
private boolean fDefaulted= false; private boolean fDefaulted;
public CPPASTFunctionDefinition() { public CPPASTFunctionDefinition() {
} }
@ -50,10 +50,12 @@ public class CPPASTFunctionDefinition extends ASTNode
setBody(bodyStatement); setBody(bodyStatement);
} }
@Override
public CPPASTFunctionDefinition copy() { public CPPASTFunctionDefinition copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CPPASTFunctionDefinition copy(CopyStyle style) { public CPPASTFunctionDefinition copy(CopyStyle style) {
CPPASTFunctionDefinition copy = new CPPASTFunctionDefinition(); CPPASTFunctionDefinition copy = new CPPASTFunctionDefinition();
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
@ -61,8 +63,7 @@ public class CPPASTFunctionDefinition extends ASTNode
if (declarator != null) { if (declarator != null) {
IASTDeclarator outer = ASTQueries.findOutermostDeclarator(declarator); IASTDeclarator outer = ASTQueries.findOutermostDeclarator(declarator);
outer = outer.copy(style); outer = outer.copy(style);
copy.setDeclarator((IASTFunctionDeclarator) ASTQueries copy.setDeclarator((IASTFunctionDeclarator) ASTQueries.findTypeRelevantDeclarator(outer));
.findTypeRelevantDeclarator(outer));
} }
copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style)); copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style));
@ -79,11 +80,13 @@ public class CPPASTFunctionDefinition extends ASTNode
return copy; return copy;
} }
@Override
public IASTDeclSpecifier getDeclSpecifier() { public IASTDeclSpecifier getDeclSpecifier() {
return declSpecifier; return declSpecifier;
} }
public void setDeclSpecifier(IASTDeclSpecifier declSpec) { @Override
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
assertNotFrozen(); assertNotFrozen();
declSpecifier = declSpec; declSpecifier = declSpec;
if (declSpec != null) { if (declSpec != null) {
@ -92,11 +95,13 @@ public class CPPASTFunctionDefinition extends ASTNode
} }
} }
public IASTFunctionDeclarator getDeclarator() { @Override
public IASTFunctionDeclarator getDeclarator() {
return declarator; return declarator;
} }
public void setDeclarator(IASTFunctionDeclarator declarator) { @Override
public void setDeclarator(IASTFunctionDeclarator declarator) {
assertNotFrozen(); assertNotFrozen();
this.declarator = declarator; this.declarator = declarator;
if (declarator != null) { if (declarator != null) {
@ -106,11 +111,13 @@ public class CPPASTFunctionDefinition extends ASTNode
} }
} }
public IASTStatement getBody() { @Override
public IASTStatement getBody() {
return bodyStatement; return bodyStatement;
} }
public void setBody(IASTStatement statement) { @Override
public void setBody(IASTStatement statement) {
assertNotFrozen(); assertNotFrozen();
bodyStatement = statement; bodyStatement = statement;
if (statement != null) { if (statement != null) {
@ -119,6 +126,7 @@ public class CPPASTFunctionDefinition extends ASTNode
} }
} }
@Override
public void addMemberInitializer(ICPPASTConstructorChainInitializer initializer) { public void addMemberInitializer(ICPPASTConstructorChainInitializer initializer) {
assertNotFrozen(); assertNotFrozen();
if (initializer != null) { if (initializer != null) {
@ -128,6 +136,7 @@ public class CPPASTFunctionDefinition extends ASTNode
} }
} }
@Override
public ICPPASTConstructorChainInitializer[] getMemberInitializers() { public ICPPASTConstructorChainInitializer[] getMemberInitializers() {
if (memInits == null) if (memInits == null)
return ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY; return ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY;
@ -136,23 +145,28 @@ public class CPPASTFunctionDefinition extends ASTNode
ICPPASTConstructorChainInitializer.class, memInits, memInitPos); ICPPASTConstructorChainInitializer.class, memInits, memInitPos);
} }
@Override
public IScope getScope() { public IScope getScope() {
return ((ICPPASTFunctionDeclarator) declarator).getFunctionScope(); return ((ICPPASTFunctionDeclarator) declarator).getFunctionScope();
} }
@Override
public boolean isDefaulted() { public boolean isDefaulted() {
return fDefaulted; return fDefaulted;
} }
@Override
public boolean isDeleted() { public boolean isDeleted() {
return fDeleted; return fDeleted;
} }
@Override
public void setIsDefaulted(boolean isDefaulted) { public void setIsDefaulted(boolean isDefaulted) {
assertNotFrozen(); assertNotFrozen();
fDefaulted= isDefaulted; fDefaulted= isDefaulted;
} }
@Override
public void setIsDeleted(boolean isDeleted) { public void setIsDeleted(boolean isDeleted) {
assertNotFrozen(); assertNotFrozen();
fDeleted= isDeleted; fDeleted= isDeleted;
@ -203,6 +217,7 @@ public class CPPASTFunctionDefinition extends ASTNode
return true; return true;
} }
@Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if (bodyStatement == child) { if (bodyStatement == child) {
other.setPropertyInParent(bodyStatement.getPropertyInParent()); other.setPropertyInParent(bodyStatement.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 (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,15 +24,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/** /**
* Represents a template declaration. * Represents a template declaration.
*/ */
public class CPPASTTemplateDeclaration extends ASTNode implements public class CPPASTTemplateDeclaration extends ASTNode
ICPPASTInternalTemplateDeclaration, IASTAmbiguityParent { implements ICPPASTInternalTemplateDeclaration, IASTAmbiguityParent {
private boolean exported; private boolean exported;
private byte isAssociatedWithLastName= -1; private byte isAssociatedWithLastName= -1;
private short nestingLevel= -1; private short nestingLevel= -1;
private IASTDeclaration declaration; private IASTDeclaration declaration;
private ICPPTemplateScope templateScope; private ICPPTemplateScope templateScope;
private ICPPASTTemplateParameter[] parameters = null; private ICPPASTTemplateParameter[] parameters;
private int parametersPos= -1; private int parametersPos= -1;
public CPPASTTemplateDeclaration() { public CPPASTTemplateDeclaration() {
@ -42,10 +41,12 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
setDeclaration(declaration); setDeclaration(declaration);
} }
@Override
public CPPASTTemplateDeclaration copy() { public CPPASTTemplateDeclaration copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CPPASTTemplateDeclaration copy(CopyStyle style) { public CPPASTTemplateDeclaration copy(CopyStyle style) {
CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration(); CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration();
copy.setDeclaration(declaration == null ? null : declaration.copy(style)); copy.setDeclaration(declaration == null ? null : declaration.copy(style));
@ -59,20 +60,24 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return copy; return copy;
} }
@Override
public boolean isExported() { public boolean isExported() {
return exported; return exported;
} }
public void setExported(boolean value) { @Override
public void setExported(boolean value) {
assertNotFrozen(); assertNotFrozen();
exported = value; exported = value;
} }
public IASTDeclaration getDeclaration() { @Override
public IASTDeclaration getDeclaration() {
return declaration; return declaration;
} }
public void setDeclaration(IASTDeclaration declaration) { @Override
public void setDeclaration(IASTDeclaration declaration) {
assertNotFrozen(); assertNotFrozen();
this.declaration = declaration; this.declaration = declaration;
if (declaration != null) { if (declaration != null) {
@ -81,13 +86,15 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
} }
} }
public ICPPASTTemplateParameter[] getTemplateParameters() { @Override
public ICPPASTTemplateParameter[] getTemplateParameters() {
if (parameters == null) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY; if (parameters == null) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter(ICPPASTTemplateParameter.class, parameters, parametersPos); parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter(ICPPASTTemplateParameter.class, parameters, parametersPos);
return parameters; return parameters;
} }
public void addTemplateParameter(ICPPASTTemplateParameter parm) { @Override
public void addTemplateParameter(ICPPASTTemplateParameter parm) {
assertNotFrozen(); assertNotFrozen();
if (parm != null) { if (parm != null) {
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append(ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm); parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append(ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm);
@ -97,6 +104,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
} }
@Deprecated @Deprecated
@Override
public void addTemplateParamter(ICPPASTTemplateParameter param) { public void addTemplateParamter(ICPPASTTemplateParameter param) {
addTemplateParameter(param); addTemplateParameter(param);
} }
@ -128,13 +136,15 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return true; return true;
} }
@Override
public ICPPTemplateScope getScope() { public ICPPTemplateScope getScope() {
if (templateScope == null) if (templateScope == null)
templateScope = new CPPTemplateScope(this); templateScope = new CPPTemplateScope(this);
return templateScope; return templateScope;
} }
public void replace(IASTNode child, IASTNode other) { @Override
public void replace(IASTNode child, IASTNode other) {
if (declaration == child) { if (declaration == child) {
other.setParent(child.getParent()); other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());
@ -142,6 +152,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
} }
} }
@Override
public short getNestingLevel() { public short getNestingLevel() {
if (nestingLevel == -1) { if (nestingLevel == -1) {
CPPTemplates.associateTemplateDeclarations(this); CPPTemplates.associateTemplateDeclarations(this);
@ -150,6 +161,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return nestingLevel; return nestingLevel;
} }
@Override
public boolean isAssociatedWithLastName() { public boolean isAssociatedWithLastName() {
if (isAssociatedWithLastName == -1) if (isAssociatedWithLastName == -1)
CPPTemplates.associateTemplateDeclarations(this); CPPTemplates.associateTemplateDeclarations(this);
@ -158,10 +170,12 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return isAssociatedWithLastName != 0; return isAssociatedWithLastName != 0;
} }
@Override
public void setAssociatedWithLastName(boolean value) { public void setAssociatedWithLastName(boolean value) {
isAssociatedWithLastName= value ? (byte) 1 : (byte) 0; isAssociatedWithLastName= value ? (byte) 1 : (byte) 0;
} }
@Override
public void setNestingLevel(short level) { public void setNestingLevel(short level) {
assert level >= 0; assert level >= 0;
nestingLevel= level; nestingLevel= level;

View file

@ -30,7 +30,7 @@ public class ASTLiteralNode implements IASTNode {
public ASTLiteralNode(String code) { public ASTLiteralNode(String code) {
fCode= code; fCode= code;
} }
@Override @Override
public String getRawSignature() { public String getRawSignature() {
return fCode; return fCode;