diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java index 8e3ea11db58..1f7f2077629 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclaration.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java index 9b4b64a3acb..c56efacb418 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java @@ -17,9 +17,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTStatement extends IASTNode { - /** - * Constant. - */ public static final IASTStatement[] EMPTY_STATEMENT_ARRAY = {}; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java index 146c9d79512..b4524045610 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTNamespaceAlias.java @@ -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; @@ -16,14 +16,13 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNameOwner; /** - * This interface represents a namespace alias in C++. e.g. namespace ABC { int - * x; } namspace DEF = ABC; + * This interface represents a namespace alias in C++, + * e.g. namespace ABC { int* x; } namespace DEF = ABC; * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner { - /** * ALIAS_NAME represents the new namespace name being * introduced. @@ -68,7 +67,6 @@ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner { */ public void setMappingName(IASTName qualifiedName); - /** * @since 5.1 */ @@ -80,5 +78,4 @@ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner { */ @Override public ICPPASTNamespaceAlias copy(CopyStyle style); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTToken.java new file mode 100644 index 00000000000..9aecc8e0726 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTToken.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2012 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.IASTToken; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.internal.core.parser.scanner.Token; + +/** + * Base class for C and C++ attributes. + */ +public class ASTToken extends ASTNode implements IASTToken { + private final IToken token; + + public ASTToken(IToken token) { + this.token = token; + } + + @Override + public ASTToken copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public ASTToken copy(CopyStyle style) { + Token tokenCopy = ((Token) token).clone(); + tokenCopy.setNext(null); + return super.copy(new ASTToken(tokenCopy), style); + } + + @Override + public IToken getToken() { + return token; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTokenList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTokenList.java new file mode 100644 index 00000000000..44d929f45e9 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTokenList.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2012 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.IASTToken; +import org.eclipse.cdt.core.dom.ast.IASTTokenList; +import org.eclipse.cdt.core.parser.IToken; +import org.eclipse.cdt.core.parser.util.ArrayUtil; + +/** + * Represents a sequence of code tokens. + */ +public class ASTTokenList extends ASTNode implements IASTTokenList { + private IASTToken[] tokens = IASTToken.EMPTY_TOKEN_ARRAY; + + public ASTTokenList() { + } + + @Override + public ASTTokenList copy() { + return copy(CopyStyle.withoutLocations); + } + + @Override + public ASTTokenList copy(CopyStyle style) { + ASTTokenList copy = super.copy(new ASTTokenList(), style); + for (IASTToken token : tokens) { + if (token == null) + break; + copy.addToken(token.copy(style)); + } + return copy; + } + + @Override + public IASTToken[] getTokens() { + tokens = ArrayUtil.trim(tokens); + return tokens; + } + + @Override + public void addToken(IASTToken token) { + tokens = ArrayUtil.append(tokens, token); + } + + @Override + public IToken getToken() { + IASTToken[] tok = getTokens(); + return tok != null && tok.length == 1 ? tok[0].getToken() : null; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguityParent.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguityParent.java index c855899649b..e59ae75df37 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguityParent.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguityParent.java @@ -6,15 +6,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.IASTNode; - public interface IASTAmbiguityParent { - public void replace( IASTNode child, IASTNode other ); - + public void replace(IASTNode child, IASTNode other); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousStatement.java index 11432af3b92..eaeb54a3b1c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IASTAmbiguousStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -14,9 +14,9 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTStatement; public interface IASTAmbiguousStatement extends IASTStatement { + public static final ASTNodeProperty STATEMENT = new ASTNodeProperty("IASTAmbiguousStatement.STATEMENT - Ambiguous statement."); //$NON-NLS-1$ - public static final ASTNodeProperty STATEMENT = new ASTNodeProperty( "IASTAmbiguousStatement.STATEMENT - Ambiguous statement." ); //$NON-NLS-1$ - public void addStatement( IASTStatement s ); - public IASTStatement [] getStatements(); - + public void addStatement(IASTStatement s); + + public IASTStatement[] getStatements(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java index c62e6eede27..36ec177e64b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - Initial API and implementation + * Markus Schorn - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -31,7 +31,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; * @since 5.0.1 */ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration { - private IASTSimpleDeclaration fSimpleDecl; private IASTDeclSpecifier fAltDeclSpec; private IASTDeclarator fAltDtor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java index 1c85de5bb5b..2726c54de93 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -24,9 +24,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope; public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbiguousStatement { - - private IASTStatement [] stmts = new IASTStatement[2]; - private int stmtsPos=-1; + private IASTStatement[] stmts = new IASTStatement[2]; + private int stmtsPos= -1; private IScope fScope; private IASTDeclaration fDeclaration; @@ -73,7 +72,7 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi public void addStatement(IASTStatement s) { assertNotFrozen(); if (s != null) { - stmts = ArrayUtil.appendAt( IASTStatement.class, stmts, ++stmtsPos, s ); + stmts = ArrayUtil.appendAt(IASTStatement.class, stmts, ++stmtsPos, s); s.setParent(this); s.setPropertyInParent(STATEMENT); } @@ -81,7 +80,7 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi @Override public IASTStatement[] getStatements() { - stmts = ArrayUtil.trimAt( IASTStatement.class, stmts, stmtsPos ); + stmts = ArrayUtil.trimAt(IASTStatement.class, stmts, stmtsPos); return stmts; } @@ -90,7 +89,6 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi return getStatements(); } - @Override public IASTStatement copy() { throw new UnsupportedOperationException(); @@ -100,5 +98,4 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi public IASTStatement copy(CopyStyle style) { throw new UnsupportedOperationException(); } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java index 3aefeac8f18..42c4d2e390c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBreakStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -19,22 +19,21 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CASTBreakStatement extends ASTNode implements IASTBreakStatement { - @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java index c18db597193..3f87fbe771b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCaseStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -22,10 +22,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IASTAmbiguityParent { - private IASTExpression expression; - public CASTCaseStatement() { } @@ -64,20 +62,20 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( expression != null ) if( !expression.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (expression != null) if (!expression.accept(action)) return false; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } @@ -86,10 +84,9 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS @Override public void replace(IASTNode child, IASTNode other) { - if( child == expression ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == expression) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); expression = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java index 8b8277b434d..81e22a8f58c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDefaultStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -19,26 +19,25 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CASTDefaultStatement extends ASTNode implements IASTDefaultStatement { - @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } - + @Override public CASTDefaultStatement copy() { return copy(CopyStyle.withoutLocations); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java index 03014d200eb..1e776c358eb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDoStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -23,11 +23,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmbiguityParent { - private IASTStatement body; private IASTExpression condition; - public CASTDoStatement() { } @@ -68,13 +66,11 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb } } - @Override public IASTExpression getCondition() { return condition; } - @Override public void setCondition(IASTExpression condition) { assertNotFrozen(); @@ -86,21 +82,23 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( body != null ) if( !body.accept( action ) ) return false; - if( condition != null ) if( !condition.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + + if (body != null && !body.accept(action)) return false; + if (condition != null && !condition.accept(action)) return false; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; @@ -108,16 +106,14 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb @Override public void replace(IASTNode child, IASTNode other) { - if( body == child ) - { - other.setPropertyInParent( body.getPropertyInParent() ); - other.setParent( body.getParent() ); + if (body == child) { + other.setPropertyInParent(body.getPropertyInParent()); + other.setParent(body.getParent()); body = (IASTStatement) other; } - if( child == condition ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == condition) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); condition = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java index 55e5daf039e..5092f4e35b1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTExpressionStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -23,10 +23,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; */ public class CASTExpressionStatement extends ASTNode implements IASTExpressionStatement, IASTAmbiguityParent { - private IASTExpression expression; - public CASTExpressionStatement() { } @@ -69,26 +67,19 @@ public class CASTExpressionStatement extends ASTNode implements public boolean accept(ASTVisitor action) { if (action.shouldVisitStatements) { 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 (expression != null) - if (!expression.accept(action)) - return false; + + if (expression != null && !expression.accept(action)) return false; if (action.shouldVisitStatements) { switch (action.leave(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; } } @@ -103,5 +94,4 @@ public class CASTExpressionStatement extends ASTNode implements expression = (IASTExpression) other; } } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java index 0fb9f9aa28a..24284ad71ed 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTForStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -25,12 +25,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTAmbiguityParent { - private IScope scope = null; - + private IScope scope; private IASTExpression condition; private IASTExpression iterationExpression; - private IASTStatement body, init; - + private IASTStatement body; + private IASTStatement init; public CASTForStatement() { } @@ -61,8 +60,8 @@ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTA protected void copyForStatement(CASTForStatement copy, CopyStyle style) { copy.setInitializerStatement(init == null ? null : init.copy(style)); copy.setConditionExpression(condition == null ? null : condition.copy(style)); - copy.setIterationExpression(iterationExpression == null ? null : iterationExpression - .copy(style)); + copy.setIterationExpression(iterationExpression == null ? + null : iterationExpression.copy(style)); copy.setBody(body == null ? null : body.copy(style)); copy.setOffsetAndLength(this); } @@ -128,62 +127,56 @@ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTA @Override public IScope getScope() { - if( scope == null ) - scope = new CScope( this, EScopeKind.eLocal); + if (scope == null) + scope = new CScope(this, EScopeKind.eLocal); return scope; } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( init != null ) if( !init.accept( action ) ) return false; - if( condition != null ) if( !condition.accept( action ) ) return false; - if( iterationExpression != null ) if( !iterationExpression.accept( action ) ) return false; - if( body != null ) if( !body.accept( action ) ) return false; + if (init != null && !init.accept(action)) return false; + if (condition != null && !condition.accept(action)) return false; + if (iterationExpression != null && !iterationExpression.accept(action)) return false; + if (body != null && !body.accept(action)) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - return true; } @Override public void replace(IASTNode child, IASTNode other) { - if( body == child ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (body == child) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); body = (IASTStatement) other; } - if( child == init ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == init) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); init = (IASTStatement) other; } - if( child == iterationExpression) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == iterationExpression) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); iterationExpression = (IASTExpression) other; } - if( child == condition) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == condition) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); condition = (IASTExpression) other; } - } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java index a9b0317631d..639e422ba0a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTGotoStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement { - private IASTName name; public CASTGotoStatement() { @@ -51,31 +50,32 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement { } @Override - public void setName(IASTName name) { - assertNotFrozen(); - this.name = name; - if (name != null) { - name.setParent(this); - name.setPropertyInParent(NAME); - } + public void setName(IASTName name) { + assertNotFrozen(); + this.name = name; + if (name != null) { + name.setParent(this); + name.setPropertyInParent(NAME); + } } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( name != null ) if( !name.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (name != null && !name.accept(action)) return false; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; @@ -83,7 +83,7 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement { @Override public int getRoleForName(IASTName n) { - if( n == name ) return r_reference; + if (n == name) return r_reference; return r_unclear; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java index 5c07fd3cd93..8848fadfc97 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIfStatement.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -24,12 +24,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * If statements for C. */ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmbiguityParent { - private IASTExpression condition; private IASTStatement thenClause; private IASTStatement elseClause; - - public CASTIfStatement() { } @@ -39,7 +36,6 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb setThenClause(thenClause); } - public CASTIfStatement(IASTExpression condition, IASTStatement thenClause, IASTStatement elseClause) { this(condition, thenClause); setElseClause(elseClause); @@ -165,22 +161,19 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb @Override public void replace(IASTNode child, IASTNode other) { - if( thenClause == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); + if (thenClause == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); thenClause = (IASTStatement) other; } - if( elseClause == child ) - { - other.setParent( child.getParent() ); - other.setPropertyInParent( child.getPropertyInParent() ); + if (elseClause == child) { + other.setParent(child.getParent()); + other.setPropertyInParent(child.getPropertyInParent()); elseClause = (IASTStatement) other; } - if( child == condition ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == condition) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); condition = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java index b9001d3087b..569e7073dc2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNullStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -19,21 +19,21 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CASTNullStatement extends ASTNode implements IASTNullStatement { - @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java index 7168cdc483f..124dea8f369 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemDeclaration.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -19,8 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration; /** * @author jcamelon */ -public class CASTProblemDeclaration extends CASTProblemOwner implements - IASTProblemDeclaration { +public class CASTProblemDeclaration extends CASTProblemOwner implements IASTProblemDeclaration { public CASTProblemDeclaration() { super(); @@ -46,20 +45,22 @@ public class CASTProblemDeclaration extends CASTProblemOwner implements } @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; + 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; } } + super.accept(action); // visits the problem - 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; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java index 5ba07cc8fa8..8e93433daf3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemExpression.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -45,20 +45,22 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitExpressions ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitExpressions) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } + super.accept(action); // visits the problem - if( action.shouldVisitExpressions ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + + if (action.shouldVisitExpressions) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java index 9de06ce5a97..98a9016d819 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemOwner.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder { - private IASTProblem problem; public CASTProblemOwner() { @@ -51,17 +50,17 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder { } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitProblems ){ - switch( action.visit( getProblem() ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action){ + if (action.shouldVisitProblems) { + switch (action.visit(getProblem())) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } - switch( action.leave( getProblem() ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + switch (action.leave(getProblem())) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java index 93183e88ae0..1a793d172b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTProblemStatement.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -44,20 +44,22 @@ public class CASTProblemStatement extends CASTProblemOwner implements IASTProble } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } + super.accept(action); // visits the problem - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java index 49ed5ec00fc..048766204ae 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTSwitchStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -22,9 +22,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ -public class CASTSwitchStatement extends ASTNode implements - IASTSwitchStatement, IASTAmbiguityParent { - +public class CASTSwitchStatement extends ASTNode + implements IASTSwitchStatement, IASTAmbiguityParent { private IASTExpression controller; private IASTStatement body; @@ -84,22 +83,23 @@ public class CASTSwitchStatement extends ASTNode implements } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( controller != null ) if( !controller.accept( action ) ) return false; - if( body != null ) if( !body.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (controller != null && !controller.accept(action)) return false; + if (body != null && !body.accept(action)) return false; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; @@ -107,16 +107,14 @@ public class CASTSwitchStatement extends ASTNode implements @Override public void replace(IASTNode child, IASTNode other) { - if( body == child ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (body == child) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); body = (IASTStatement) other; } - if( child == controller ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == controller) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); controller = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java index 483a0652c50..7f363cb0533 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - Initial API and implementation + * Markus Schorn - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; * }; */ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration { - private IASTSimpleDeclaration fSimpleDecl; private IASTDeclSpecifier fAltDeclSpec; private IASTDeclarator fAltDtor; @@ -55,7 +54,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement @Override public IASTNode[] getNodes() { - return new IASTNode[] {fSimpleDecl, fAltDeclSpec, fAltDtor}; + return new IASTNode[] { fSimpleDecl, fAltDeclSpec, fAltDtor }; } @Override @@ -97,7 +96,6 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement owner.replace(nodeToReplace, fSimpleDecl); IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0]; dtor.accept(resolver); - // find nested names final NameCollector nameCollector= new NameCollector(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java index ab68e647d17..cc6c607d1e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -23,16 +23,14 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; -public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements - IASTAmbiguousStatement { - - private IASTStatement [] stmts = new IASTStatement[2]; - private int stmtsPos=-1; +public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbiguousStatement { + private IASTStatement[] stmts = new IASTStatement[2]; + private int stmtsPos= -1; private IScope fScope; private IASTDeclaration fDeclaration; public CPPASTAmbiguousStatement(IASTStatement... statements) { - for(IASTStatement s : statements) + for (IASTStatement s : statements) addStatement(s); } @@ -84,7 +82,7 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements public void addStatement(IASTStatement s) { assertNotFrozen(); if (s != null) { - stmts = ArrayUtil.appendAt( IASTStatement.class, stmts, ++stmtsPos, s ); + stmts = ArrayUtil.appendAt(IASTStatement.class, stmts, ++stmtsPos, s); s.setParent(this); s.setPropertyInParent(STATEMENT); } @@ -92,7 +90,7 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements @Override public IASTStatement[] getStatements() { - stmts = ArrayUtil.trimAt( IASTStatement.class, stmts, stmtsPos ); + stmts = ArrayUtil.trimAt(IASTStatement.class, stmts, stmtsPos); return stmts; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java index f4decd6ba3c..82e8d3b8bd0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCaseStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, IASTAmbiguityParent { - private IASTExpression expression; public CPPASTCaseStatement() { @@ -38,8 +37,8 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I @Override public CPPASTCaseStatement copy(CopyStyle style) { - CPPASTCaseStatement copy = new CPPASTCaseStatement(expression == null ? null - : expression.copy(style)); + CPPASTCaseStatement copy = + new CPPASTCaseStatement(expression == null ? null : expression.copy(style)); copy.setOffsetAndLength(this); if (style == CopyStyle.withLocations) { copy.setCopyLocation(this); @@ -63,18 +62,19 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch(action.visit(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; } } - if( expression != null ) if( !expression.accept( action ) ) return false; + + if (expression != null && !expression.accept(action)) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ + if (action.shouldVisitStatements) { + switch(action.leave(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -85,10 +85,9 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I @Override public void replace(IASTNode child, IASTNode other) { - if( child == expression ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == expression) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); expression = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java index b9942a34ce4..6002782353f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDoStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -22,11 +22,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmbiguityParent { - private IASTStatement body; private IASTExpression condition; - public CPPASTDoStatement() { } @@ -83,21 +81,23 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( body != null ) if( !body.accept( action ) ) return false; - if( condition != null ) if( !condition.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + + if (body != null && !body.accept(action)) return false; + if (condition != null && !condition.accept(action)) return false; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; @@ -105,16 +105,14 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA @Override public void replace(IASTNode child, IASTNode other) { - if( body == child ) - { - other.setPropertyInParent( body.getPropertyInParent() ); - other.setParent( body.getParent() ); + if (body == child) { + other.setPropertyInParent(body.getPropertyInParent()); + other.setParent(body.getParent()); body = (IASTStatement) other; } - if( child == condition ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == condition) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); condition = (IASTExpression) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java index 538a1070851..b17798e0346 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTExpressionStatement.java @@ -22,7 +22,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; */ public class CPPASTExpressionStatement extends ASTNode implements IASTExpressionStatement, IASTAmbiguityParent { - private IASTExpression expression; public CPPASTExpressionStatement() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java index e5fdfdfb9b1..62e88114664 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTGotoStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -19,9 +19,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement { - private IASTName name; - public CPPASTGotoStatement() { } @@ -51,28 +49,29 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement { } @Override - public void setName(IASTName name) { - assertNotFrozen(); - this.name = name; - if (name != null) { - name.setParent(this); - name.setPropertyInParent(NAME); - } + public void setName(IASTName name) { + assertNotFrozen(); + this.name = name; + if (name != null) { + name.setParent(this); + name.setPropertyInParent(NAME); + } } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; } } - if( name != null ) if( !name.accept( action ) ) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ + if (name != null && !name.accept(action)) return false; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -83,7 +82,7 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement { @Override public int getRoleForName(IASTName n) { - if( name == n ) return r_reference; + if (name == n) return r_reference; return r_unclear; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java index 0ccfbb1d42e..1611f398ce0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIfStatement.java @@ -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; @@ -158,6 +158,7 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA break loop; } } + if (action.shouldVisitStatements) { if (stmt != null && action.leave(stmt) == ASTVisitor.PROCESS_ABORT) return false; @@ -207,8 +208,8 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA @Override public IScope getScope() { - if( scope == null ) - scope = new CPPBlockScope( this ); + if (scope == null) + scope = new CPPBlockScope(this); return scope; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java index c1da21d6927..c36952741e1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTInitializerList.java @@ -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; @@ -26,9 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * e.g.: int a[]= {1,2,3}; */ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList, IASTAmbiguityParent { - - private IASTInitializerClause [] initializers = null; - private int initializersPos=-1; + private IASTInitializerClause [] initializers; + private int initializersPos= -1; private int actualSize; private boolean fIsPackExpansion; @@ -40,8 +39,9 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer @Override public CPPASTInitializerList copy(CopyStyle style) { CPPASTInitializerList copy = new CPPASTInitializerList(); - for (IASTInitializerClause initializer : getClauses()) + for (IASTInitializerClause initializer : getClauses()) { copy.addClause(initializer == null ? null : initializer.copy(style)); + } copy.setOffsetAndLength(this); copy.actualSize = getSize(); copy.fIsPackExpansion = fIsPackExpansion; @@ -114,9 +114,9 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer public boolean accept( ASTVisitor action ){ if (action.shouldVisitInitializers) { 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; } } IASTInitializerClause[] list = getClauses(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java index 9d4af23a843..43dacc1c1f8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLabelStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -21,12 +21,10 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ -public class CPPASTLabelStatement extends ASTNode implements - IASTLabelStatement, IASTAmbiguityParent { - +public class CPPASTLabelStatement extends ASTNode + implements IASTLabelStatement, IASTAmbiguityParent { private IASTName name; private IASTStatement nestedStatement; - public CPPASTLabelStatement() { } @@ -69,22 +67,23 @@ public class CPPASTLabelStatement extends ASTNode implements } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( name != null ) if( !name.accept( action ) ) return false; - if( nestedStatement != null ) if( !nestedStatement.accept( action ) ) return false; + + if (name != null && !name.accept(action)) return false; + if (nestedStatement != null && !nestedStatement.accept(action)) return false; - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; @@ -92,7 +91,7 @@ public class CPPASTLabelStatement extends ASTNode implements @Override public int getRoleForName(IASTName n) { - if( n == name ) return r_declaration; + if (n == name) return r_declaration; return r_unclear; } @@ -113,12 +112,10 @@ public class CPPASTLabelStatement extends ASTNode implements @Override public void replace(IASTNode child, IASTNode other) { - if( child == nestedStatement ) - { - other.setParent( this ); - other.setPropertyInParent( child.getPropertyInParent() ); + if (child == nestedStatement) { + other.setParent(this); + other.setPropertyInParent(child.getPropertyInParent()); setNestedStatement((IASTStatement) other); } - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java index 8464ac526e6..2b8ae69a6e8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemDeclaration.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -32,7 +32,7 @@ public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements IAST public CPPASTProblemDeclaration copy() { return copy(CopyStyle.withoutLocations); } - + @Override public CPPASTProblemDeclaration copy(CopyStyle style) { CPPASTProblemDeclaration copy = new CPPASTProblemDeclaration(); @@ -42,25 +42,24 @@ public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements IAST } return copy; } - + @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; + 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; } } super.accept(action); // visits the problem - 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; } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java index 556aeb2ea24..e2da6a8cc7a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemExpression.java @@ -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; @@ -44,20 +44,20 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTP } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitExpressions ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitExpressions) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } super.accept(action); // visits the problem - if( action.shouldVisitExpressions ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitExpressions) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java index 34faea7268c..40e7eae4cdf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemOwner.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -20,17 +20,15 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder { - private IASTProblem problem; - public CPPASTProblemOwner() { } public CPPASTProblemOwner(IASTProblem problem) { setProblem(problem); } - + protected void copyBaseProblem(CPPASTProblemOwner copy, CopyStyle style) { copy.setProblem(problem == null ? null : problem.copy(style)); copy.setOffsetAndLength(this); @@ -52,17 +50,17 @@ abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder { } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitProblems ){ - switch( action.visit( getProblem() ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitProblems) { + switch (action.visit(getProblem())) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } - switch( action.leave( getProblem() ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + switch (action.leave(getProblem())) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java index 5e763e00830..55ffa3cc9ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -27,7 +27,7 @@ public class CPPASTProblemStatement extends CPPASTProblemOwner implements IASTPr public CPPASTProblemStatement(IASTProblem problem) { super(problem); } - + @Override public CPPASTProblemStatement copy() { return copy(CopyStyle.withoutLocations); @@ -44,20 +44,20 @@ public class CPPASTProblemStatement extends CPPASTProblemOwner implements IASTPr } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } super.accept(action); // visits the problem - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java index ce13cbcab98..20901b448f1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblemTypeId.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId; * @author jcamelon */ public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProblemTypeId { + public CPPASTProblemTypeId() { } @@ -52,7 +53,7 @@ public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProbl default: break; } - // Visits the problem + // Visit the problem if (!super.accept(action)) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java index 0a4dc3aacd4..7f41c1bde16 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTRangeBasedForStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - Initial API and implementation + * Markus Schorn - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -178,9 +178,9 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang public boolean accept( ASTVisitor action ){ if (action.shouldVisitStatements) { 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 (fDeclaration != null && !fDeclaration.accept(action)) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java index 192e9624a0f..2de2b71d577 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java @@ -77,16 +77,13 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen public boolean accept(ASTVisitor action) { if (action.shouldVisitStatements) { 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 (retValue != null && !retValue.accept(action)) - return false; + + if (retValue != null && !retValue.accept(action)) return false; if (action.shouldVisitStatements) { switch (action.leave(this)) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java index 1a47bc44936..af786b347d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleDeclaration.java @@ -41,8 +41,9 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar public CPPASTSimpleDeclaration copy(CopyStyle style) { CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration(); 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.setOffsetAndLength(this); if (style == CopyStyle.withLocations) { copy.setCopyLocation(this); @@ -129,5 +130,4 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar } } } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java index 85f983f029b..50b537e066f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSwitchStatement.java @@ -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; @@ -104,6 +104,7 @@ public class CPPASTSwitchStatement extends ASTNode default: break; } } + if (controllerExpression != null && !controllerExpression.accept(action)) return false; if (controllerDeclaration != null && !controllerDeclaration.accept(action)) return false; if (body != null && !body.accept(action)) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java index f90cf8b82c2..33063c203f9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java @@ -1,14 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2011 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Bryan Wilkinson (QNX) - * Markus Schorn (Wind River Systems) + * Contributors: + * John Camelon (IBM) - Initial API and implementation + * Bryan Wilkinson (QNX) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -24,10 +24,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; - public class CPPASTUsingDeclaration extends ASTNode implements ICPPASTUsingDeclaration, ICPPASTCompletionContext { - private boolean typeName; private IASTName name; @@ -45,8 +43,8 @@ public class CPPASTUsingDeclaration extends ASTNode @Override public CPPASTUsingDeclaration copy(CopyStyle style) { - CPPASTUsingDeclaration copy = new CPPASTUsingDeclaration(name == null ? null - : name.copy(style)); + CPPASTUsingDeclaration copy = + new CPPASTUsingDeclaration(name == null ? null : name.copy(style)); copy.typeName = typeName; copy.setOffsetAndLength(this); if (style == CopyStyle.withLocations) { @@ -85,19 +83,19 @@ public class CPPASTUsingDeclaration extends ASTNode 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; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if (name != null) if (!name.accept(action)) return false; + if (name != null && !name.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; + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java index cc6cbb3f92e..d4a60eb0b5e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Bryan Wilkinson (QNX) + * John Camelon (IBM) - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -23,10 +23,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; - -public class CPPASTUsingDirective extends ASTNode implements - ICPPASTUsingDirective, ICPPASTCompletionContext { - +public class CPPASTUsingDirective extends ASTNode + implements ICPPASTUsingDirective, ICPPASTCompletionContext { private IASTName name; public CPPASTUsingDirective() { @@ -64,35 +62,33 @@ public class CPPASTUsingDirective extends ASTNode implements qualifiedName.setParent(this); qualifiedName.setPropertyInParent(QUALIFIED_NAME); } - } @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; + 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( name != null ) if( !name.accept( action ) ) return false; + if (name != null && !name.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; } - - @Override + @Override public int getRoleForName(IASTName n) { - if( n == name ) + if (n == name) return r_reference; return r_unclear; } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java index 1fb52781b78..9b85e452595 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTForallStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.upc.ast; @@ -18,11 +18,9 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CASTForStatement; @SuppressWarnings("restriction") public class UPCASTForallStatement extends CASTForStatement implements IUPCASTForallStatement { - private IASTExpression affinity; private boolean affinityContinue; - public UPCASTForallStatement() { } @@ -40,15 +38,14 @@ public class UPCASTForallStatement extends CASTForStatement implements IUPCASTFo @Override public UPCASTForallStatement copy(CopyStyle style) { UPCASTForallStatement copy = new UPCASTForallStatement(); - copyForStatement(copy, style); copy.setAffinityExpression(affinity == null ? null : affinity.copy(style)); + copyForStatement(copy, style); if (style == CopyStyle.withLocations) { copy.setCopyLocation(this); } return copy; } - @Override public boolean isAffinityContinue() { return affinityContinue; @@ -61,10 +58,10 @@ public class UPCASTForallStatement extends CASTForStatement implements IUPCASTFo @Override public void setAffinityExpression(IASTExpression affinity) { - if(affinity != null) + if (affinity != null) this.affinityContinue = false; this.affinity = affinity; - if(affinity != null) { + if (affinity != null) { affinity.setParent(this); affinity.setPropertyInParent(AFFINITY); } @@ -72,43 +69,40 @@ public class UPCASTForallStatement extends CASTForStatement implements IUPCASTFo @Override public void setAffinityContinue(boolean affinityContinue) { - if(affinityContinue) + if (affinityContinue) this.affinity = null; this.affinityContinue = affinityContinue; } - @Override public boolean accept(ASTVisitor visitor) { - if(visitor.shouldVisitStatements) { - switch(visitor.visit(this)){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; + if (visitor.shouldVisitStatements) { + switch (visitor.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; } } IASTStatement initializer = super.getInitializerStatement(); - if(initializer != null) if(!initializer.accept(visitor)) return false; + if (initializer != null && !initializer.accept(visitor)) return false; IASTExpression condition = super.getConditionExpression(); - if(condition != null) if(!condition.accept(visitor)) return false; + if (condition != null && !condition.accept(visitor)) return false; IASTExpression iteration = super.getIterationExpression(); - if(iteration != null) if(!iteration.accept(visitor)) return false; + if (iteration != null && !iteration.accept(visitor)) return false; - if(affinity != null) if(!affinity.accept(visitor)) return false; + if (affinity != null && !affinity.accept(visitor)) return false; IASTStatement body = super.getBody(); - if(body != null) if(!body.accept(visitor)) return false; + if (body != null && !body.accept(visitor)) return false; - if(visitor.shouldVisitStatements) { - switch(visitor.leave(this)){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; + if (visitor.shouldVisitStatements) { + switch (visitor.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; } } - return true; } - } diff --git a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java index 7af6f97da17..9058c8aa904 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java +++ b/upc/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/internal/core/dom/parser/upc/ast/UPCASTSynchronizationStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.upc.ast; @@ -17,10 +17,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; @SuppressWarnings("restriction") public class UPCASTSynchronizationStatement extends ASTNode implements IUPCASTSynchronizationStatement { - private int statmentKind; - private IASTExpression barrierExpression = null; - + private IASTExpression barrierExpression; public UPCASTSynchronizationStatement() { } @@ -41,7 +39,7 @@ public class UPCASTSynchronizationStatement extends ASTNode implements IUPCASTSy copy.statmentKind = statmentKind; copy.setBarrierExpression(barrierExpression == null ? null : barrierExpression.copy(style)); copy.setOffsetAndLength(this); - if(style == CopyStyle.withLocations) { + if (style == CopyStyle.withLocations) { copy.setCopyLocation(this); } return copy; @@ -60,7 +58,7 @@ public class UPCASTSynchronizationStatement extends ASTNode implements IUPCASTSy @Override public void setBarrierExpression(IASTExpression expr) { this.barrierExpression = expr; - if(expr != null) { + if (expr != null) { expr.setParent(this); expr.setPropertyInParent(BARRIER_EXPRESSION); } @@ -71,30 +69,23 @@ public class UPCASTSynchronizationStatement extends ASTNode implements IUPCASTSy this.statmentKind = kind; } - @Override public boolean accept(ASTVisitor visitor) { - if(visitor.shouldVisitStatements) { - switch(visitor.visit(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; + if (visitor.shouldVisitStatements) { + switch (visitor.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; } } - if(barrierExpression != null) { - boolean abort = !barrierExpression.accept(visitor); - if(abort) - return false; - } + if (barrierExpression != null && !barrierExpression.accept(visitor)) return false; - if(visitor.shouldVisitStatements) { - switch(visitor.leave(this)) { - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; + if (visitor.shouldVisitStatements) { + switch (visitor.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; } } - return true; } - } \ No newline at end of file