Top Description Fields Constructors Methods
org.codehaus.groovy.transform

public abstract Class AbstractInterruptibleASTTransformation

extends ClassCodeVisitorSupport
implements ASTTransformation, Opcodes
Class Inheritance
All Implemented Interfaces
org.objectweb.asm.Opcodes, org.codehaus.groovy.transform.ASTTransformation
Imports
org.codehaus.groovy.GroovyBugError, org.codehaus.groovy.ast.ASTNode, .AnnotatedNode, .AnnotationNode, .ClassCodeVisitorSupport, .ClassHelper, .ClassNode, .FieldNode, .MethodNode, .ModuleNode, org.codehaus.groovy.ast.expr.ClassExpression, .ConstantExpression, .DeclarationExpression, .Expression, org.codehaus.groovy.ast.stmt.BlockStatement, .DoWhileStatement, .ForStatement, .LoopingStatement, .Statement, .WhileStatement, org.codehaus.groovy.control.SourceUnit, org.codehaus.groovy.runtime.DefaultGroovyMethods, org.objectweb.asm.Opcodes, java.util.Arrays, .List

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

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
protected boolean
protected boolean
protected static final String
protected boolean
protected SourceUnit
protected static final String
protected ClassNode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract Expression
createCondition()

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

protected Statement

Returns:

Returns the interruption check statement.
createInterruptStatement
()

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

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

protected abstract String
getErrorMessage()

Subclasses should implement this method to provide good error resolution.

protected SourceUnit
protected static void
protected void
protected abstract ClassNode
type()

public void
visit(ASTNode[]
The ASTnodes when the call was triggered. Element 0 is the AnnotationNode that triggered this annotation to be activated. Element 1 is the AnnotatedNode decorated, such as a MethodNode or ClassNode. For global transformations it is usually safe to ignore this parameter.
nodes
,
SourceUnit
The source unit being compiled. The source unit may contain several classes. For global transformations, information about the AST can be retrieved from this object.
source
)

Implements org.codehaus.groovy.transform.ASTTransformation.visit.

The method is invoked when an AST Transformation is active.
public final void
public final void
private void
visitLoop(LoopingStatement loopStatement)

Shortcut method which avoids duplicating code for every type of loop.

public final void
protected final Statement

Returns:

a block statement which first element is for checking interruption, and the second one the statement to be wrapped.
wrapBlock
(Statement
the statement to be wrapped
statement
)

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

Inherited from org.codehaus.groovy.ast.ClassCodeVisitorSupport:
addErrorvisitAnnotationvisitAnnotationsvisitAssertStatementvisitBlockStatementvisitBreakStatementvisitCaseStatementvisitCatchStatementvisitClassvisitClassCodeContainervisitConstructorvisitConstructorOrMethodvisitContinueStatementvisitDeclarationExpressionvisitExpressionStatementvisitFieldvisitIfElsevisitImportsvisitMethodvisitObjectInitializerStatementsvisitPackagevisitPropertyvisitReturnStatementvisitStatementvisitSwitchvisitSynchronizedStatementvisitThrowStatementvisitTryCatchFinally

Field Detail

APPLY_TO_ALL_CLASSESback to summary
private static final String APPLY_TO_ALL_CLASSES
APPLY_TO_ALL_MEMBERSback to summary
private static final String APPLY_TO_ALL_MEMBERS
applyToAllClassesback to summary
protected boolean applyToAllClasses
applyToAllMembersback to summary
protected boolean applyToAllMembers
CHECK_METHOD_START_MEMBERback to summary
protected static final String CHECK_METHOD_START_MEMBER
checkOnMethodStartback to summary
protected boolean checkOnMethodStart
sourceback to summary
protected SourceUnit source
THROWN_EXCEPTION_TYPEback to summary
protected static final String THROWN_EXCEPTION_TYPE
thrownExceptionTypeback to summary
protected ClassNode thrownExceptionType

Constructor Detail

AbstractInterruptibleASTTransformationback to summary
public AbstractInterruptibleASTTransformation()

Method Detail

createConditionback to summary
protected abstract Expression createCondition()

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

createInterruptStatementback to summary
protected Statement createInterruptStatement()
Returns:Statement

Returns the interruption check statement.

getBooleanAnnotationParameterback to summary
protected static boolean getBooleanAnnotationParameter(AnnotationNode node, String parameterName, boolean defaultValue)
getClassAnnotationParameterback to summary
protected static ClassNode getClassAnnotationParameter(AnnotationNode node, String parameterName, ClassNode defaultValue)
getErrorMessageback to summary
protected abstract String getErrorMessage()

Subclasses should implement this method to provide good error resolution.

getSourceUnitback to summary
protected SourceUnit getSourceUnit()

Implements abstract org.codehaus.groovy.ast.ClassCodeVisitorSupport.getSourceUnit.

internalErrorback to summary
protected static void internalError(String message)
setupTransformback to summary
protected void setupTransform(AnnotationNode node)
typeback to summary
protected abstract ClassNode type()
visitback to summary
public void visit(ASTNode[] nodes, SourceUnit source)

Implements org.codehaus.groovy.transform.ASTTransformation.visit.

Doc from org.codehaus.groovy.transform.ASTTransformation.visit.

The method is invoked when an AST Transformation is active. For local transformations, it is invoked once each time the local annotation is encountered. For global transformations, it is invoked once for every source unit, which is typically a source file.

Parameters
nodes:ASTNode[]

The ASTnodes when the call was triggered. Element 0 is the AnnotationNode that triggered this annotation to be activated. Element 1 is the AnnotatedNode decorated, such as a MethodNode or ClassNode. For global transformations it is usually safe to ignore this parameter.

source:SourceUnit

The source unit being compiled. The source unit may contain several classes. For global transformations, information about the AST can be retrieved from this object.

visitDoWhileLoopback to summary
public final void visitDoWhileLoop(DoWhileStatement doWhileStatement)

Overrides org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitDoWhileLoop.

Implements org.codehaus.groovy.ast.GroovyCodeVisitor.visitDoWhileLoop.

Annotations
@Override
visitForLoopback to summary
public final void visitForLoop(ForStatement forStatement)

Overrides org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitForLoop.

Implements org.codehaus.groovy.ast.GroovyCodeVisitor.visitForLoop.

Annotations
@Override
visitLoopback to summary
private void visitLoop(LoopingStatement loopStatement)

Shortcut method which avoids duplicating code for every type of loop. Actually wraps the loopBlock of different types of loop statements.

visitWhileLoopback to summary
public final void visitWhileLoop(WhileStatement whileStatement)

Overrides org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitWhileLoop.

Implements org.codehaus.groovy.ast.GroovyCodeVisitor.visitWhileLoop.

Annotations
@Override
wrapBlockback to summary
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:Statement

the statement to be wrapped

Returns:Statement

a block statement which first element is for checking interruption, and the second one the statement to be wrapped.