Package org.codehaus.groovy.transform.tailrec

# Class StatementReplacer

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.transform.tailrec.StatementReplacer

All Implemented Interfaces:
  `GroovyCodeVisitor`

public class StatementReplacer extends CodeVisitorSupport
Tool for replacing Statement objects in an AST by other Statement instances.

Within @TailRecursive it is used to swap ReturnStatements with looping back to RECUR label

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StatementReplacer(Closure<Boolean> when, Closure<Statement> replaceWith)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getClosureLevel()`
  `Closure<Statement>`
  `getReplaceWith()`
  `Closure<Boolean>`
  `getWhen()`
  `void`
  `replaceIn(ASTNode root)`
  `void`
  `setClosureLevel(int closureLevel)`
  `void`
  `setReplaceWith(Closure<Statement> replaceWith)`
  `void`
  `setWhen(Closure<Boolean> when)`
  `void`
  `visitBlockStatement(BlockStatement block)`
  `void`
  `visitClosureExpression(ClosureExpression expression)`
  `void`
  `visitDoWhileLoop(DoWhileStatement loop)`
  `void`
  `visitForLoop(ForStatement forLoop)`
  `void`
  `visitIfElse(IfStatement ifElse)`
  `void`
  `visitWhileLoop(WhileStatement loop)`

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitGStringExpression, 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor

  `visit, visit, visitEmptyExpression, visitListOfExpressions`

- ## Constructor Details

  - ### StatementReplacer

    public StatementReplacer(Closure<Boolean> when, Closure<Statement> replaceWith)

- ## Method Details

  - ### replaceIn

    public void replaceIn(ASTNode root)

  - ### visitClosureExpression

    public void visitClosureExpression(ClosureExpression expression)
    Specified by:
      `visitClosureExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureExpression` in class `CodeVisitorSupport`

  - ### visitBlockStatement

    public void visitBlockStatement(BlockStatement block)
    Specified by:
      `visitBlockStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBlockStatement` in class `CodeVisitorSupport`

  - ### visitIfElse

    public void visitIfElse(IfStatement ifElse)
    Specified by:
      `visitIfElse` in interface `GroovyCodeVisitor`
    Overrides:
      `visitIfElse` in class `CodeVisitorSupport`

  - ### visitForLoop

    public void visitForLoop(ForStatement forLoop)
    Specified by:
      `visitForLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitForLoop` in class `CodeVisitorSupport`

  - ### visitWhileLoop

    public void visitWhileLoop(WhileStatement loop)
    Specified by:
      `visitWhileLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitWhileLoop` in class `CodeVisitorSupport`

  - ### visitDoWhileLoop

    public void visitDoWhileLoop(DoWhileStatement loop)
    Specified by:
      `visitDoWhileLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitDoWhileLoop` in class `CodeVisitorSupport`

  - ### getWhen

    public Closure<Boolean> getWhen()

  - ### setWhen

    public void setWhen(Closure<Boolean> when)

  - ### getReplaceWith

    public Closure<Statement> getReplaceWith()

  - ### setReplaceWith

    public void setReplaceWith(Closure<Statement> replaceWith)

  - ### getClosureLevel

    public int getClosureLevel()

  - ### setClosureLevel

    public void setClosureLevel(int closureLevel)