Package: org.codehaus.groovy.transform.tailrec

## [Java] Class VariableExpressionReplacer

- org.codehaus.groovy.transform.tailrec.VariableExpressionReplacer

-     public class VariableExpressionReplacer
      extends CodeVisitorSupport

  Tool for replacing VariableExpression instances in an AST by other VariableExpression instances. Regardless of a real change taking place in nested expressions, all considered expression (trees) will be replaced. This could be optimized to accelerate compilation.

  Within

  TailRecursive:
    it is used - to swap the access of method args with the access to iteration variables - to swap the access of iteration variables with the access of temp vars

- - ### Constructor Summary

    Constructors
    Constructor and description
    `VariableExpressionReplacer(Closure<Boolean> when, Closure<VariableExpression> replaceWith)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Closure<VariableExpression>` | `getReplaceWith()`
    `` | `public Closure<Boolean>` | `getWhen()`
    `` | `public void` | `replaceIn(ASTNode root)`
    `` | `public void` | `setReplaceWith(Closure<VariableExpression> replaceWith)`
    `` | `public void` | `setWhen(Closure<Boolean> when)`
    `` | `public void` | `visitAssertStatement(AssertStatement statement)`
    `` | `public void` | `visitBinaryExpression(BinaryExpression expression)` It's the only Expression type in which replacing is considered.
    `` | `public void` | `visitCaseStatement(CaseStatement statement)`
    `` | `public void` | `visitDoWhileLoop(DoWhileStatement loop)`
    `` | `public void` | `visitExpressionStatement(ExpressionStatement statement)`
    `` | `public void` | `visitForLoop(ForStatement forLoop)`
    `` | `public void` | `visitIfElse(IfStatement ifElse)`
    `` | `public void` | `visitReturnStatement(ReturnStatement statement)`
    `` | `public void` | `visitSwitch(SwitchStatement statement)`
    `` | `public void` | `visitSynchronizedStatement(SynchronizedStatement statement)`
    `` | `public void` | `visitThrowStatement(ThrowStatement statement)`
    `` | `public void` | `visitWhileLoop(WhileStatement loop)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `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`

- - ### Constructor Detail

    - #### public VariableExpressionReplacer(Closure<Boolean> when, Closure<VariableExpression> replaceWith)

  - ### Method Detail

    - #### public Closure<VariableExpression> getReplaceWith()

    - #### public Closure<Boolean> getWhen()

    - #### public void replaceIn(ASTNode root)

    - #### public void setReplaceWith(Closure<VariableExpression> replaceWith)

    - #### public void setWhen(Closure<Boolean> when)

    - #### @Override
      public void visitAssertStatement(AssertStatement statement)

    - #### @Override
      public void visitBinaryExpression(BinaryExpression expression)

      It's the only Expression type in which replacing is considered. That's an abuse of the class, but I couldn't think of a better way.

    - #### @Override
      public void visitCaseStatement(CaseStatement statement)

    - #### @Override
      public void visitDoWhileLoop(DoWhileStatement loop)

    - #### @Override
      public void visitExpressionStatement(ExpressionStatement statement)

    - #### @Override
      public void visitForLoop(ForStatement forLoop)

    - #### @Override
      public void visitIfElse(IfStatement ifElse)

    - #### @Override
      public void visitReturnStatement(ReturnStatement statement)

    - #### @Override
      public void visitSwitch(SwitchStatement statement)

    - #### @Override
      public void visitSynchronizedStatement(SynchronizedStatement statement)

    - #### @Override
      public void visitThrowStatement(ThrowStatement statement)

    - #### @Override
      public void visitWhileLoop(WhileStatement loop)