1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 02:05:39 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-02-06 01:29:09 +00:00
parent ff3ee6ba99
commit e3505af7c7

View file

@ -35,7 +35,7 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
public CPPASTSimpleDeclaration copy() { public CPPASTSimpleDeclaration copy() {
CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration(); CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration();
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy());
for(IASTDeclarator declarator : getDeclarators()) for (IASTDeclarator declarator : getDeclarators())
copy.addDeclarator(declarator == null ? null : declarator.copy()); copy.addDeclarator(declarator == null ? null : declarator.copy());
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
return copy; return copy;
@ -46,22 +46,22 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
} }
public IASTDeclarator[] getDeclarators() { public IASTDeclarator[] getDeclarators() {
if( declarators == null ) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY; 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 ) { 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);
d.setParent(this); d.setParent(this);
d.setPropertyInParent(DECLARATOR); d.setPropertyInParent(DECLARATOR);
} }
} }
private IASTDeclarator [] declarators = null; private IASTDeclarator[] declarators = null;
private int declaratorsPos=-1; private int declaratorsPos = -1;
private IASTDeclSpecifier declSpecifier; private IASTDeclSpecifier declSpecifier;
/** /**
@ -77,25 +77,25 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
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( declSpecifier != null ) if( !declSpecifier.accept( action ) ) return false; if (declSpecifier != null) if (!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)) {
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;
@ -103,8 +103,8 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
public void replace(IASTNode child, IASTNode other) { 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) {
declarators[i] = (IASTDeclarator)other; declarators[i] = (IASTDeclarator)other;
other.setParent(child.getParent()); other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());