1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 17:55:39 +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

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; 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. * @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

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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; 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

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -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);
@ -55,25 +57,20 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
public void addCatchHandler(ICPPASTCatchHandler statement) { public void addCatchHandler(ICPPASTCatchHandler statement) {
assertNotFrozen(); assertNotFrozen();
if (statement != null) { if (statement != null) {
catchHandlers = ArrayUtil.appendAt( ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement ); catchHandlers = ArrayUtil.appendAt(ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement);
statement.setParent(this); statement.setParent(this);
statement.setPropertyInParent(CATCH_HANDLER); statement.setPropertyInParent(CATCH_HANDLER);
} }
} }
@Override @Override
public ICPPASTCatchHandler[] getCatchHandlers() { public ICPPASTCatchHandler[] getCatchHandlers() {
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY; if (catchHandlers == null)
catchHandlers = ArrayUtil.trimAt( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos ); return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
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,33 +81,34 @@ public class CPPASTTryBlockStatement extends ASTNode implements ICPPASTTryBlockS
} }
} }
@Override @Override
public IASTStatement getTryBody() { public IASTStatement getTryBody() {
return tryBody; return tryBody;
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitStatements ){ if (action.shouldVisitStatements) {
switch( action.visit( this ) ){ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if( 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) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
@ -118,10 +116,9 @@ 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;
} }
} }