diff options
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java')
-rw-r--r-- | core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java | 128 |
1 files changed, 68 insertions, 60 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java index ab34e74ad29..4ff87d5f077 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSimpleDeclaration.java @@ -29,11 +29,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * Models a simple declaration. */ public class CASTSimpleDeclaration extends ASTAttributeOwner implements IASTSimpleDeclaration, IASTAmbiguityParent { - private IASTDeclarator[] declarators; - private int declaratorsPos = -1; - private IASTDeclSpecifier declSpecifier; + private IASTDeclarator[] declarators; + private int declaratorsPos = -1; + private IASTDeclSpecifier declSpecifier; - public CASTSimpleDeclaration() { + public CASTSimpleDeclaration() { } public CASTSimpleDeclaration(IASTDeclSpecifier declSpecifier) { @@ -57,82 +57,90 @@ public class CASTSimpleDeclaration extends ASTAttributeOwner implements IASTSimp @Override public IASTDeclSpecifier getDeclSpecifier() { - return declSpecifier; - } + return declSpecifier; + } - @Override + @Override public IASTDeclarator[] getDeclarators() { - if (declarators == null) - return IASTDeclarator.EMPTY_DECLARATOR_ARRAY; - declarators = ArrayUtil.trimAt(IASTDeclarator.class, declarators, declaratorsPos); - return declarators; - } + if (declarators == null) + return IASTDeclarator.EMPTY_DECLARATOR_ARRAY; + declarators = ArrayUtil.trimAt(IASTDeclarator.class, declarators, declaratorsPos); + return declarators; + } - @Override + @Override public void addDeclarator(IASTDeclarator d) { - assertNotFrozen(); - if (d != null) { - d.setParent(this); + assertNotFrozen(); + if (d != null) { + d.setParent(this); d.setPropertyInParent(DECLARATOR); - declarators = ArrayUtil.appendAt(IASTDeclarator.class, declarators, ++declaratorsPos, d); - } - } + declarators = ArrayUtil.appendAt(IASTDeclarator.class, declarators, ++declaratorsPos, d); + } + } - @Override + @Override public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) { - assertNotFrozen(); - this.declSpecifier = declSpecifier; - if (declSpecifier != null) { + assertNotFrozen(); + this.declSpecifier = declSpecifier; + if (declSpecifier != null) { declSpecifier.setParent(this); declSpecifier.setPropertyInParent(DECL_SPECIFIER); } - } + } - @Override + @Override public boolean accept(ASTVisitor action) { - if (action.shouldVisitDeclarations) { - switch (action.visit(this)) { - case ASTVisitor.PROCESS_ABORT: return false; - case ASTVisitor.PROCESS_SKIP: return true; - default: break; - } + if (action.shouldVisitDeclarations) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: + return false; + case ASTVisitor.PROCESS_SKIP: + return true; + default: + break; + } } - if (!acceptByAttributeSpecifiers(action)) return false; - if (declSpecifier != null && !declSpecifier.accept(action)) return false; + if (!acceptByAttributeSpecifiers(action)) + return false; + if (declSpecifier != null && !declSpecifier.accept(action)) + return false; - IASTDeclarator[] dtors = getDeclarators(); - for (int i = 0; i < dtors.length; i++) { - if (!dtors[i].accept(action)) - return false; - } + IASTDeclarator[] dtors = getDeclarators(); + for (int i = 0; i < dtors.length; i++) { + if (!dtors[i].accept(action)) + return false; + } - if (action.shouldVisitDeclarations) { - switch (action.leave(this)) { - case ASTVisitor.PROCESS_ABORT: return false; - case ASTVisitor.PROCESS_SKIP: return true; - default: break; - } + if (action.shouldVisitDeclarations) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: + return false; + case ASTVisitor.PROCESS_SKIP: + return true; + default: + break; + } } - return true; - } + return true; + } - @Override + @Override public void replace(IASTNode child, IASTNode other) { - if (declSpecifier == child) { + if (declSpecifier == child) { other.setParent(child.getParent()); other.setPropertyInParent(child.getPropertyInParent()); - declSpecifier= (IASTDeclSpecifier) other; - } else { - IASTDeclarator[] declarators = getDeclarators(); - for (int i = 0; i < declarators.length; i++) { - if (declarators[i] == child) { - declarators[i] = (IASTDeclarator) other; - other.setParent(child.getParent()); - other.setPropertyInParent(child.getPropertyInParent()); - break; - } - } - } + declSpecifier = (IASTDeclSpecifier) other; + } else { + IASTDeclarator[] declarators = getDeclarators(); + for (int i = 0; i < declarators.length; i++) { + if (declarators[i] == child) { + declarators[i] = (IASTDeclarator) other; + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); + break; + } + } + } } }
\ No newline at end of file |