@CompileStatic
@GroovyASTTransformation(phase=CompilePhase.CANONICALIZATION)
class ConditionalInterruptibleASTTransformation
extends AbstractInterruptibleASTTransformation
Allows "interrupt-safe" executions of scripts by adding a custom conditional check on loops (for, while, do) and first statement of closures. By default, also adds an interrupt check statement on the beginning of method calls.
| Fields inherited from class | Fields |
|---|---|
class AbstractInterruptibleASTTransformation |
CHECK_METHOD_START_MEMBER, THROWN_EXCEPTION_TYPE, applyToAllClasses, applyToAllMembers, checkOnMethodStart, source, thrownExceptionType |
| Constructor and description |
|---|
ConditionalInterruptibleASTTransformation() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected Expression |
createCondition()Builds the expression that calls the generated condition method. |
|
protected String |
getErrorMessage()Returns the message used when the interrupt condition evaluates to true. |
|
protected void |
setupTransform(AnnotationNode node)Initializes the transformation state from the annotation node. |
|
protected ClassNode |
type()Returns the annotation type handled by this transformation. |
|
void |
visitAnnotations(AnnotatedNode node)Skips annotation visitation to avoid re-entering the transformation. |
|
void |
visitClass(ClassNode type)Adds the synthetic condition method and visits eligible class members. |
|
void |
visitClosureExpression(ClosureExpression closureExpr)Wraps closure bodies with the interrupt check, excluding the annotation closure itself. |
|
void |
visitField(FieldNode node)Visits eligible instance fields. |
|
void |
visitMethod(MethodNode node)Wraps eligible methods with the interrupt check while preserving script bootstrap behavior. |
|
void |
visitProperty(PropertyNode node)Visits eligible instance properties. |
Builds the expression that calls the generated condition method.
Returns the message used when the interrupt condition evaluates to true.
Initializes the transformation state from the annotation node.
node - the transformation annotationReturns the annotation type handled by this transformation.
Skips annotation visitation to avoid re-entering the transformation.
node - the annotated node, ignored by this transformationAdds the synthetic condition method and visits eligible class members.
type - the class being transformedWraps closure bodies with the interrupt check, excluding the annotation closure itself.
closureExpr - the closure being visitedVisits eligible instance fields.
node - the field being visitedWraps eligible methods with the interrupt check while preserving script bootstrap behavior.
node - the method being visitedVisits eligible instance properties.
node - the property being visitedCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.