Package org.codehaus.groovy.classgen.asm

# Class ClosureWriter.CorrectAccessedVariableVisitor

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.classgen.asm.ClosureWriter.CorrectAccessedVariableVisitor

All Implemented Interfaces:
  `GroovyCodeVisitor`

Enclosing class:
  ClosureWriter

protected static class ClosureWriter.CorrectAccessedVariableVisitor extends CodeVisitorSupport
Visitor that rewrites `VariableExpression` nodes whose accessed variable is a `FieldNode` in an outer class to instead reference the corresponding field in the generated closure inner class.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CorrectAccessedVariableVisitor(InnerClassNode icn)`
  Creates a visitor for the generated closure class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `visitVariableExpression(VariableExpression expression)`
  Visits a `VariableExpression`.

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

  `afterSwitchCaseStatementsVisited, afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, 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, visitSwitchExpression, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitWhileLoop, visitYieldStatement`

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

  - ### CorrectAccessedVariableVisitor

    public CorrectAccessedVariableVisitor(InnerClassNode icn)
    Creates a visitor for the generated closure class.
    Parameters:
      `icn` - the generated closure class

- ## Method Details

  - ### visitVariableExpression

    public void visitVariableExpression(VariableExpression expression)
    Visits a `VariableExpression`. No traversal is performed as variable expressions contain no child expressions.
    Specified by:
      `visitVariableExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitVariableExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the variable expression