1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 22:35:43 +02:00

@Override annotations.

This commit is contained in:
Sergey Prigogin 2012-01-05 20:21:29 -08:00
parent 6da58da8f8
commit 76e962ee9b
4 changed files with 97 additions and 69 deletions

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -22,10 +22,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifier, ICPPASTDeclSpecifier {
/**
* <code>k_class</code> C++ introduces the class concept for composite
* types.
* <code>k_class</code> C++ introduces the class concept for composite types.
*/
public static final int k_class = IASTCompositeTypeSpecifier.k_last + 1;
@ -52,15 +50,14 @@ public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifie
*
* @noimplement This interface is not intended to be implemented by clients.
*/
public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner, ICPPASTPackExpandable {
public static final ICPPASTBaseSpecifier[] EMPTY_BASESPECIFIER_ARRAY = new ICPPASTBaseSpecifier[0];
public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner, ICPPASTPackExpandable {
public static final ICPPASTBaseSpecifier[] EMPTY_BASESPECIFIER_ARRAY = {};
/**
* Relation between base specifier and its name.
*/
public static final ASTNodeProperty NAME = new ASTNodeProperty(
"ICPPASTBaseSpecifier.NAME - Name of base class"); //$NON-NLS-1$
public static final int v_public = 1;
public static final int v_protected = 2;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* John Camelon (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTVisibilityLabel extends IASTDeclaration {
/**
* <code>v_public</code> == public:
*/
@ -37,28 +36,28 @@ public interface ICPPASTVisibilityLabel extends IASTDeclaration {
public static final int v_private = 3;
/**
* Get the visibility.
* Returns the visibility.
*
* @return int
*/
public int getVisibility();
/**
* Set visibility.
* Sets visibility.
*
* @param visibility
* int
* @param visibility one of v_public, v_protected, v_private
*/
public void setVisibility(int visibility);
/**
* @since 5.1
*/
@Override
public ICPPASTVisibilityLabel copy();
/**
* @since 5.3
*/
@Override
public ICPPASTVisibilityLabel copy(CopyStyle style);
}

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research)
* John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@ -27,13 +27,12 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
*/
public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
ICASTCompositeTypeSpecifier, IASTAmbiguityParent {
private int fKey;
private IASTName fName;
private IASTDeclaration[] fActiveDeclarations= null;
private IASTDeclaration [] fAllDeclarations = null;
private int fDeclarationsPos=-1;
private IScope fScope = null;
private IASTDeclaration[] fActiveDeclarations;
private IASTDeclaration[] fAllDeclarations;
private int fDeclarationsPos = -1;
private IScope fScope;
public CASTCompositeTypeSpecifier() {
}
@ -43,10 +42,12 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
setName(name);
}
@Override
public CASTCompositeTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTCompositeTypeSpecifier copy(CopyStyle style) {
CASTCompositeTypeSpecifier copy = new CASTCompositeTypeSpecifier();
copyCompositeTypeSpecifier(copy, style);
@ -60,24 +61,28 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
copyBaseDeclSpec(copy);
copy.setKey(fKey);
copy.setName(fName == null ? null : fName.copy(style));
for(IASTDeclaration member : getMembers())
for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style));
}
public int getKey() {
@Override
public int getKey() {
return fKey;
}
public void setKey(int key) {
@Override
public void setKey(int key) {
assertNotFrozen();
this.fKey = key;
}
public IASTName getName() {
@Override
public IASTName getName() {
return fName;
}
public void setName(IASTName name) {
@Override
public void setName(IASTName name) {
assertNotFrozen();
this.fName = name;
if (name != null) {
@ -86,51 +91,57 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
}
}
@Override
public IASTDeclaration[] getMembers() {
IASTDeclaration[] active= fActiveDeclarations;
if (active == null) {
active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos+1);
active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos + 1);
fActiveDeclarations= active;
}
return active;
}
@Override
public final IASTDeclaration[] getDeclarations(boolean includeInactive) {
if (includeInactive) {
fAllDeclarations= (IASTDeclaration[]) ArrayUtil.removeNullsAfter(IASTDeclaration.class, fAllDeclarations, fDeclarationsPos);
fAllDeclarations= ArrayUtil.trimAt(IASTDeclaration.class, fAllDeclarations,
fDeclarationsPos);
return fAllDeclarations;
}
return getMembers();
}
public void addMemberDeclaration(IASTDeclaration declaration) {
@Override
public void addMemberDeclaration(IASTDeclaration declaration) {
assertNotFrozen();
if (declaration != null) {
declaration.setParent(this);
declaration.setPropertyInParent(MEMBER_DECLARATION);
fAllDeclarations = (IASTDeclaration[]) ArrayUtil.append(IASTDeclaration.class, fAllDeclarations,
fAllDeclarations = ArrayUtil.appendAt(IASTDeclaration.class, fAllDeclarations,
++fDeclarationsPos, declaration);
fActiveDeclarations= null;
}
}
public void addDeclaration(IASTDeclaration declaration) {
@Override
public void addDeclaration(IASTDeclaration declaration) {
addMemberDeclaration(declaration);
}
public IScope getScope() {
if( fScope == null )
fScope = new CCompositeTypeScope( this );
@Override
public IScope getScope() {
if (fScope == null)
fScope = new CCompositeTypeScope(this);
return fScope;
}
@Override
public boolean accept( ASTVisitor action ){
public boolean accept(ASTVisitor action){
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
if (fName != null && !fName.accept(action))
@ -138,7 +149,8 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
IASTDeclaration[] decls= getDeclarations(action.includeInactiveNodes);
for (int i = 0; i < decls.length; i++) {
if (!decls[i].accept(action)) return false;
if (!decls[i].accept(action))
return false;
}
if (action.shouldVisitDeclSpecifiers) {
@ -151,13 +163,15 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
return true;
}
@Override
public int getRoleForName(IASTName n) {
if( n == this.fName )
if (n == this.fName)
return r_definition;
return r_unclear;
}
public void replace(IASTNode child, IASTNode other) {
@Override
public void replace(IASTNode child, IASTNode other) {
assert child.isActive() == other.isActive();
for (int i = 0; i <= fDeclarationsPos; ++i) {
if (fAllDeclarations[i] == child) {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -27,17 +27,15 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
*/
public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
implements ICPPASTCompositeTypeSpecifier, IASTAmbiguityParent {
private int fKey;
private IASTName fName;
private CPPClassScope fScope;
private IASTDeclaration[] fAllDeclarations;
private IASTDeclaration[] fActiveDeclarations;
private int fDeclarationsPos=-1;
private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs = null;
private int fDeclarationsPos = -1;
private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs;
private int baseSpecsPos = -1;
private boolean fAmbiguitiesResolved= false;
private boolean fAmbiguitiesResolved;
public CPPASTCompositeTypeSpecifier() {
}
@ -54,13 +52,15 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
fAmbiguitiesResolved= true;
}
@Override
public CPPASTCompositeTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CPPASTCompositeTypeSpecifier copy(CopyStyle style) {
CPPASTCompositeTypeSpecifier copy = new CPPASTCompositeTypeSpecifier(fKey, fName == null
? null : fName.copy(style));
CPPASTCompositeTypeSpecifier copy =
new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style));
copyBaseDeclSpec(copy);
for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style));
@ -73,35 +73,43 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
return copy;
}
public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos );
@Override
public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
if (baseSpecs == null)
return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
baseSpecs = ArrayUtil.trimAt(ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos);
return baseSpecs;
}
public void addBaseSpecifier(ICPPASTBaseSpecifier baseSpec) {
@Override
public void addBaseSpecifier(ICPPASTBaseSpecifier baseSpec) {
assertNotFrozen();
if (baseSpec != null) {
baseSpec.setParent(this);
baseSpec.setPropertyInParent(BASE_SPECIFIER);
baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.append( ICPPASTBaseSpecifier.class, baseSpecs, ++baseSpecsPos, baseSpec );
baseSpecs = ArrayUtil.appendAt(ICPPASTBaseSpecifier.class, baseSpecs, ++baseSpecsPos,
baseSpec);
}
}
public int getKey() {
@Override
public int getKey() {
return fKey;
}
public void setKey(int key) {
@Override
public void setKey(int key) {
assertNotFrozen();
fKey = key;
}
public IASTName getName() {
@Override
public IASTName getName() {
return fName;
}
public void setName(IASTName name) {
@Override
public void setName(IASTName name) {
assertNotFrozen();
this.fName = name;
if (name != null) {
@ -110,23 +118,27 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
}
}
@Override
public IASTDeclaration[] getMembers() {
IASTDeclaration[] active= fActiveDeclarations;
if (active == null) {
active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos+1);
active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos + 1);
fActiveDeclarations= active;
}
return active;
}
@Override
public final IASTDeclaration[] getDeclarations(boolean includeInactive) {
if (includeInactive) {
fAllDeclarations= (IASTDeclaration[]) ArrayUtil.removeNullsAfter(IASTDeclaration.class, fAllDeclarations, fDeclarationsPos);
fAllDeclarations= ArrayUtil.trimAt(IASTDeclaration.class, fAllDeclarations,
fDeclarationsPos);
return fAllDeclarations;
}
return getMembers();
}
@Override
public void addMemberDeclaration(IASTDeclaration decl) {
if (decl == null)
return;
@ -138,15 +150,17 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
assertNotFrozen();
decl.setParent(this);
decl.setPropertyInParent(decl instanceof ICPPASTVisibilityLabel ? VISIBILITY_LABEL : MEMBER_DECLARATION);
fAllDeclarations = (IASTDeclaration[]) ArrayUtil.append(IASTDeclaration.class, fAllDeclarations,
fAllDeclarations = ArrayUtil.appendAt(IASTDeclaration.class, fAllDeclarations,
++fDeclarationsPos, decl);
fActiveDeclarations= null;
}
public final void addDeclaration(IASTDeclaration decl) {
@Override
public final void addDeclaration(IASTDeclaration decl) {
addMemberDeclaration(decl);
}
@Override
public ICPPClassScope getScope() {
if (fScope == null) {
fScope = new CPPClassScope(this);
@ -172,12 +186,14 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
ICPPASTBaseSpecifier[] bases = getBaseSpecifiers();
for (int i = 0; i < bases.length; i++) {
if (!bases[i].accept(action)) return false;
if (!bases[i].accept(action))
return false;
}
IASTDeclaration[] decls = getDeclarations(action.includeInactiveNodes);
for (int i = 0; i < decls.length; i++) {
if (!decls[i].accept(action)) return false;
if (!decls[i].accept(action))
return false;
}
if (action.shouldVisitDeclSpecifiers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
@ -186,12 +202,14 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
return true;
}
@Override
public int getRoleForName(IASTName name) {
if( name == this.fName )
if (name == this.fName)
return r_definition;
return r_unclear;
}
@Override
public void replace(IASTNode child, IASTNode other) {
assert child.isActive() == other.isActive();
for (int i = 0; i <= fDeclarationsPos; ++i) {