Groovy 2.2.1

org.codehaus.groovy.transform
[Java] Class AbstractInterruptibleASTTransformation

java.lang.Object
  org.codehaus.groovy.ast.CodeVisitorSupport
      org.codehaus.groovy.ast.ClassCodeVisitorSupport
          org.codehaus.groovy.transform.AbstractInterruptibleASTTransformation
All Implemented Interfaces:
ASTTransformation, org.objectweb.asm.Opcodes

public abstract class AbstractInterruptibleASTTransformation
extends ClassCodeVisitorSupport

Base class for AST Transformations which will automatically throw an InterruptedException when some conditions are met.

Authors:
Cedric Champeau
Hamlet D'Arcy
Paul King
Since:
1.8.0


Field Summary
protected static String CHECK_METHOD_START_MEMBER

protected static String THROWN_EXCEPTION_TYPE

protected boolean applyToAllClasses

protected boolean applyToAllMembers

protected boolean checkOnMethodStart

protected SourceUnit source

protected ClassNode thrownExceptionType

 
Method Summary
protected Expression createCondition()

Subclasses should implement this method to set the condition of the interruption statement

protected Statement createInterruptStatement()

@return Returns the interruption check statement.

protected static boolean getBooleanAnnotationParameter(AnnotationNode node, String parameterName, boolean defaultValue)

protected static ClassNode getClassAnnotationParameter(AnnotationNode node, String parameterName, ClassNode defaultValue)

protected String getErrorMessage()

Subclasses should implement this method to provide good error resolution.

protected SourceUnit getSourceUnit()

protected static void internalError(String message)

protected void setupTransform(AnnotationNode node)

protected ClassNode type()

void visit(ASTNode[] nodes, SourceUnit source)

void visitDoWhileLoop(DoWhileStatement doWhileStatement)

void visitForLoop(ForStatement forStatement)

void visitWhileLoop(WhileStatement whileStatement)

protected Statement wrapBlock(Statement statement)

Takes a statement and wraps it into a block statement which first element is the interruption check statement.

 
Methods inherited from class ClassCodeVisitorSupport
visitMethod, visitField, visitReturnStatement, visitProperty, visitConstructor, visitClass, visitPackage, visitBlockStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitSwitch, visitWhileLoop, visitDeclarationExpression, visitImports, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitAnnotations, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, visitClassExpression, visitPropertyExpression, visitListExpression, visitConstantExpression, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class CodeVisitorSupport
visitReturnStatement, visitClassExpression, visitPropertyExpression, visitListExpression, visitConstantExpression, visitBlockStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitSwitch, visitWhileLoop, visitDeclarationExpression, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

CHECK_METHOD_START_MEMBER

protected static final String CHECK_METHOD_START_MEMBER


THROWN_EXCEPTION_TYPE

protected static final String THROWN_EXCEPTION_TYPE


applyToAllClasses

protected boolean applyToAllClasses


applyToAllMembers

protected boolean applyToAllMembers


checkOnMethodStart

protected boolean checkOnMethodStart


source

protected SourceUnit source


thrownExceptionType

protected ClassNode thrownExceptionType


 
Method Detail

createCondition

protected Expression createCondition()
Subclasses should implement this method to set the condition of the interruption statement


createInterruptStatement

protected Statement createInterruptStatement()
Returns:
Returns the interruption check statement.


getBooleanAnnotationParameter

protected static boolean getBooleanAnnotationParameter(AnnotationNode node, String parameterName, boolean defaultValue)


getClassAnnotationParameter

protected static ClassNode getClassAnnotationParameter(AnnotationNode node, String parameterName, ClassNode defaultValue)


getErrorMessage

protected String getErrorMessage()
Subclasses should implement this method to provide good error resolution.


getSourceUnit

protected SourceUnit getSourceUnit()


internalError

protected static void internalError(String message)


setupTransform

protected void setupTransform(AnnotationNode node)


type

protected ClassNode type()


visit

public void visit(ASTNode[] nodes, SourceUnit source)


visitDoWhileLoop

@Override}
public final void visitDoWhileLoop(DoWhileStatement doWhileStatement)


visitForLoop

@Override}
public final void visitForLoop(ForStatement forStatement)


visitWhileLoop

@Override}
}
public final void visitWhileLoop(WhileStatement whileStatement)


wrapBlock

protected final Statement wrapBlock(Statement statement)
Takes a statement and wraps it into a block statement which first element is the interruption check statement.
Parameters:
statement - the statement to be wrapped
Returns:
a block statement which first element is for checking interruption, and the second one the statement to be wrapped.


 

Copyright © 2003-2013 The Codehaus. All rights reserved.