1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 18:55:38 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-02-26 17:07:56 -08:00
parent 71136d7739
commit 45fd24540c
3 changed files with 39 additions and 46 deletions

View file

@ -16,7 +16,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTReturnStatement extends IASTStatement { public interface IASTReturnStatement extends IASTStatement {
public static final ASTNodeProperty RETURNVALUE = new ASTNodeProperty( public static final ASTNodeProperty RETURNVALUE = new ASTNodeProperty(
"IASTReturnValue.RETURNVALUE - [IASTInitializerClause]"); //$NON-NLS-1$ "IASTReturnValue.RETURNVALUE - [IASTInitializerClause]"); //$NON-NLS-1$

View file

@ -14,15 +14,13 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTStatement;
/** /**
* This interface represents the try block statement. try { //body } catch( Exc * This interface represents the try block statement. try { //body } catch (Exc e )
* e ) { // handler } catch( ... ) { * { // handler } catch ( ... ) { }
* }
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTTryBlockStatement extends IASTStatement { public interface ICPPASTTryBlockStatement extends IASTStatement {
/** /**
* <code>BODY</code> is the body of the try block. * <code>BODY</code> is the body of the try block.
*/ */
@ -75,5 +73,4 @@ public interface ICPPASTTryBlockStatement extends IASTStatement {
*/ */
@Override @Override
public ICPPASTTryBlockStatement copy(CopyStyle style); public ICPPASTTryBlockStatement copy(CopyStyle style);
} }

View file

@ -24,7 +24,9 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
* @author jcamelon * @author jcamelon
*/ */
public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockStatement, IASTAmbiguityParent { public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockStatement, IASTAmbiguityParent {
private ICPPASTCatchHandler[] catchHandlers;
private int catchHandlersPos= -1;
private IASTStatement tryBody;
public CPPASTTryBlockStatement() { public CPPASTTryBlockStatement() {
} }
@ -40,8 +42,8 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
@Override @Override
public CPPASTTryBlockStatement copy(CopyStyle style) { public CPPASTTryBlockStatement copy(CopyStyle style) {
CPPASTTryBlockStatement copy = new CPPASTTryBlockStatement(tryBody == null ? null CPPASTTryBlockStatement copy =
: tryBody.copy(style)); new CPPASTTryBlockStatement(tryBody == null ? null : tryBody.copy(style));
for (ICPPASTCatchHandler handler : getCatchHandlers()) for (ICPPASTCatchHandler handler : getCatchHandlers())
copy.addCatchHandler(handler == null ? null : handler.copy(style)); copy.addCatchHandler(handler == null ? null : handler.copy(style));
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
@ -61,19 +63,14 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
} }
} }
@Override @Override
public ICPPASTCatchHandler[] getCatchHandlers() { public ICPPASTCatchHandler[] getCatchHandlers() {
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; if (catchHandlers == null)
return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
catchHandlers = ArrayUtil.trimAt(ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos); catchHandlers = ArrayUtil.trimAt(ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos);
return catchHandlers; return catchHandlers;
} }
private ICPPASTCatchHandler [] catchHandlers = null;
private int catchHandlersPos=-1;
private IASTStatement tryBody;
@Override @Override
public void setTryBody(IASTStatement tryBlock) { public void setTryBody(IASTStatement tryBlock) {
assertNotFrozen(); assertNotFrozen();
@ -84,7 +81,6 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
} }
} }
@Override @Override
public IASTStatement getTryBody() { public IASTStatement getTryBody() {
return tryBody; return tryBody;
@ -99,11 +95,13 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
default: break; default: break;
} }
} }
if( tryBody != null ) if( !tryBody.accept( action ) ) return false; if (tryBody != null && !tryBody.accept(action))
return false;
ICPPASTCatchHandler[] handlers = getCatchHandlers(); ICPPASTCatchHandler[] handlers = getCatchHandlers();
for (int i = 0; i < handlers.length; i++) { for (int i = 0; i < handlers.length; i++) {
if( !handlers[i].accept( action ) ) return false; if (!handlers[i].accept(action))
return false;
} }
if (action.shouldVisitStatements) { if (action.shouldVisitStatements) {
@ -118,8 +116,7 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
@Override @Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if( tryBody == child ) if (tryBody == child) {
{
other.setPropertyInParent(child.getPropertyInParent()); other.setPropertyInParent(child.getPropertyInParent());
other.setParent(child.getParent()); other.setParent(child.getParent());
tryBody = (IASTStatement) other; tryBody = (IASTStatement) other;