diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java index 9a5e1d6266b..c8ec29969aa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTReturnStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -16,7 +16,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTReturnStatement extends IASTStatement { - public static final ASTNodeProperty RETURNVALUE = new ASTNodeProperty( "IASTReturnValue.RETURNVALUE - [IASTInitializerClause]"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java index c367cdf8ea6..c371ef80e45 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTryBlockStatement.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; @@ -14,15 +14,13 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTStatement; /** - * This interface represents the try block statement. try { //body } catch( Exc - * e ) { // handler } catch( ... ) { - * } + * This interface represents the try block statement. try { //body } catch (Exc e ) + * { // handler } catch ( ... ) { } * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTryBlockStatement extends IASTStatement { - /** * BODY is the body of the try block. */ @@ -75,5 +73,4 @@ public interface ICPPASTTryBlockStatement extends IASTStatement { */ @Override public ICPPASTTryBlockStatement copy(CopyStyle style); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java index f41cb4312c5..354787dbcb7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTryBlockStatement.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; @@ -24,7 +24,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockStatement, IASTAmbiguityParent { - + private ICPPASTCatchHandler[] catchHandlers; + private int catchHandlersPos= -1; + private IASTStatement tryBody; public CPPASTTryBlockStatement() { } @@ -37,11 +39,11 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS public CPPASTTryBlockStatement copy() { return copy(CopyStyle.withoutLocations); } - + @Override public CPPASTTryBlockStatement copy(CopyStyle style) { - CPPASTTryBlockStatement copy = new CPPASTTryBlockStatement(tryBody == null ? null - : tryBody.copy(style)); + CPPASTTryBlockStatement copy = + new CPPASTTryBlockStatement(tryBody == null ? null : tryBody.copy(style)); for (ICPPASTCatchHandler handler : getCatchHandlers()) copy.addCatchHandler(handler == null ? null : handler.copy(style)); copy.setOffsetAndLength(this); @@ -55,25 +57,20 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS public void addCatchHandler(ICPPASTCatchHandler statement) { assertNotFrozen(); if (statement != null) { - catchHandlers = ArrayUtil.appendAt( ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement ); + catchHandlers = ArrayUtil.appendAt(ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement); statement.setParent(this); statement.setPropertyInParent(CATCH_HANDLER); } } - @Override public ICPPASTCatchHandler[] getCatchHandlers() { - if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; - catchHandlers = ArrayUtil.trimAt( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos ); + if (catchHandlers == null) + return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; + catchHandlers = ArrayUtil.trimAt(ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos); return catchHandlers; } - - private ICPPASTCatchHandler [] catchHandlers = null; - private int catchHandlersPos=-1; - private IASTStatement tryBody; - @Override public void setTryBody(IASTStatement tryBlock) { assertNotFrozen(); @@ -84,33 +81,34 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS } } - @Override public IASTStatement getTryBody() { return tryBody; } @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( tryBody != null ) if( !tryBody.accept( action ) ) return false; - - ICPPASTCatchHandler [] handlers = getCatchHandlers(); - for ( int i = 0; i < handlers.length; i++ ) { - if( !handlers[i].accept( action ) ) return false; + if (tryBody != null && !tryBody.accept(action)) + return false; + + ICPPASTCatchHandler[] handlers = getCatchHandlers(); + for (int i = 0; i < handlers.length; i++) { + if (!handlers[i].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; @@ -118,10 +116,9 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS @Override public void replace(IASTNode child, IASTNode other) { - if( tryBody == child ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (tryBody == child) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); tryBody = (IASTStatement) other; } }