mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
17f96f9eb3
commit
d88c1111f7
1 changed files with 32 additions and 32 deletions
|
@ -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
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
* Models a simple declaration.
|
* Models a simple declaration.
|
||||||
*/
|
*/
|
||||||
public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
||||||
|
private IASTDeclarator[] declarators;
|
||||||
|
private int declaratorsPos = -1;
|
||||||
|
private IASTDeclSpecifier declSpecifier;
|
||||||
|
|
||||||
public CASTSimpleDeclaration() {
|
public CASTSimpleDeclaration() {
|
||||||
}
|
}
|
||||||
|
@ -42,7 +44,7 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
||||||
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
||||||
|
|
||||||
for(IASTDeclarator declarator : getDeclarators())
|
for (IASTDeclarator declarator : getDeclarators())
|
||||||
copy.addDeclarator(declarator == null ? null : declarator.copy(style));
|
copy.addDeclarator(declarator == null ? null : declarator.copy(style));
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
|
@ -57,26 +59,21 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTDeclarator[] getDeclarators() {
|
public IASTDeclarator[] getDeclarators() {
|
||||||
if( declarators == null ) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
if (declarators == null)
|
||||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter( IASTDeclarator.class, declarators, declaratorsPos );
|
return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
|
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) {
|
||||||
d.setParent(this);
|
d.setParent(this);
|
||||||
d.setPropertyInParent(DECLARATOR);
|
d.setPropertyInParent(DECLARATOR);
|
||||||
declarators = (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, ++declaratorsPos, d );
|
declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, ++declaratorsPos, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private IASTDeclarator [] declarators = null;
|
|
||||||
private int declaratorsPos=-1;
|
|
||||||
private IASTDeclSpecifier declSpecifier;
|
|
||||||
|
|
||||||
|
|
||||||
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.declSpecifier = declSpecifier;
|
this.declSpecifier = declSpecifier;
|
||||||
|
@ -87,25 +84,28 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 && !declSpecifier.accept(action))
|
||||||
IASTDeclarator [] dtors = getDeclarators();
|
return false;
|
||||||
for( int i = 0; i < dtors.length; i++ )
|
IASTDeclarator[] dtors = getDeclarators();
|
||||||
if( !dtors[i].accept( action ) ) return false;
|
for (int i = 0; i < dtors.length; i++) {
|
||||||
|
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;
|
||||||
|
@ -118,8 +118,8 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
declSpecifier= (IASTDeclSpecifier) other;
|
declSpecifier= (IASTDeclSpecifier) other;
|
||||||
} else {
|
} else {
|
||||||
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());
|
||||||
|
|
Loading…
Add table
Reference in a new issue