Package: org.codehaus.groovy.transform

## [Java] Class AbstractInterruptibleASTTransformation

- org.codehaus.groovy.transform.AbstractInterruptibleASTTransformation

- All Implemented Interfaces and Traits:
    ASTTransformation, org.objectweb.asm.Opcodes

      public abstract class AbstractInterruptibleASTTransformation
      extends ClassCodeVisitorSupport
      implements ASTTransformation, org.objectweb.asm.Opcodes

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

  Since:
    1.8.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `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` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected abstract Expression` | `createCondition()` Subclasses should implement this method to set the condition of the interruption statement
    `` | `protected Statement` | `createInterruptStatement()` Returns: 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 abstract 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 abstract ClassNode` | `type()`
    `` | `public void` | `visit(ASTNode[] nodes, SourceUnit source)`
    `` | `public final void` | `visitDoWhileLoop(DoWhileStatement doWhileStatement)`
    `` | `public final void` | `visitForLoop(ForStatement forStatement)`
    `` | `public final void` | `visitWhileLoop(WhileStatement whileStatement)`
    `` | `protected final Statement` | `wrapBlock(Statement statement)` Takes a statement and wraps it into a block statement which first element is the interruption check statement.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Field Detail

    - #### protected static final String CHECK_METHOD_START_MEMBER

    - #### protected static final String THROWN_EXCEPTION_TYPE

    - #### protected boolean applyToAllClasses

    - #### protected boolean applyToAllMembers

    - #### protected boolean checkOnMethodStart

    - #### protected SourceUnit source

    - #### protected ClassNode thrownExceptionType

  - ### Method Detail

    - #### protected abstract Expression createCondition()

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

    - #### protected Statement createInterruptStatement()

      Returns:
        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 abstract 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 abstract ClassNode type()

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

    - #### @Override public final void visitDoWhileLoop(DoWhileStatement doWhileStatement)

    - #### @Override public final void visitForLoop(ForStatement forStatement)

    - #### @Override public final void visitWhileLoop(WhileStatement whileStatement)

    - #### 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.