ClassCodeExpressionTransformer (Groovy 5.0.0)
Description: declaration: package: org.codehaus.groovy.ast, class: ClassCodeExpressionTransformer

Package org.codehaus.groovy.ast

# Class ClassCodeExpressionTransformer

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeExpressionTransformer

All Implemented Interfaces:
  `ExpressionTransformer`, `GroovyClassVisitor`, `GroovyCodeVisitor`, `ErrorCollecting`

Direct Known Subclasses:
  `FieldASTTransformation`, `NewifyASTTransformation`, `OperatorRenameASTTransformation`, `OptimizerVisitor`, `ResolveVisitor`, `StaticCompilationTransformer`, `StaticImportVisitor`

public abstract class ClassCodeExpressionTransformer extends ClassCodeVisitorSupport implements ExpressionTransformer
Transforms expressions in a whole class. Transformed expressions are usually not visited.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClassCodeExpressionTransformer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected static void`
  `setSourcePosition(Expression target, Expression source)`
  Transfers the source position to target including its property expression if it has one.
  `Expression`
  `transform(Expression expr)`
  NOTE: This method does not visit Expressions within Closures, for performance and historical reasons.
  `protected void`
  `visitAnnotation(AnnotationNode node)`
  `void`
  `visitAssertStatement(AssertStatement stmt)`
  `void`
  `visitCaseStatement(CaseStatement stmt)`
  `void`
  `visitClosureExpression(ClosureExpression expr)`
  `protected void`
  `visitConstructorOrMethod(MethodNode node, boolean isConstructor)`
  `void`
  `visitDoWhileLoop(DoWhileStatement stmt)`
  `void`
  `visitExpressionStatement(ExpressionStatement stmt)`
  `void`
  `visitField(FieldNode node)`
  Visit a FieldNode.
  `void`
  `visitForLoop(ForStatement stmt)`
  `void`
  `visitIfElse(IfStatement stmt)`
  `void`
  `visitProperty(PropertyNode node)`
  Visit a PropertyNode.
  `void`
  `visitReturnStatement(ReturnStatement stmt)`
  `void`
  `visitSwitch(SwitchStatement stmt)`
  `void`
  `visitSynchronizedStatement(SynchronizedStatement stmt)`
  `void`
  `visitThrowStatement(ThrowStatement stmt)`
  `void`
  `visitWhileLoop(WhileStatement stmt)`

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

  `addError, getSourceUnit, visitAnnotations, visitAnnotations, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitTryCatchFinally`

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

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, 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

  - ### ClassCodeExpressionTransformer

    public ClassCodeExpressionTransformer()

- ## Method Details

  - ### transform

    public Expression transform(Expression expr)
    NOTE: This method does not visit Expressions within Closures, for performance and historical reasons. If you want those Expressions to be visited, you can do this:

         public class YourTransformer extends ClassCodeExpressionTransformer {
           ...

           @Override
           public Expression transform(final Expression expr) {
             if (expr instanceof ClosureExpression) {
               expr.visit(this);

               return expr;
             }
             // ...
           }
         }

    Specified by:
      `transform` in interface `ExpressionTransformer`

  - ### visitAnnotation

    protected void visitAnnotation(AnnotationNode node)
    Overrides:
      `visitAnnotation` in class `ClassCodeVisitorSupport`

  - ### visitConstructorOrMethod

    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
    Overrides:
      `visitConstructorOrMethod` in class `ClassCodeVisitorSupport`

  - ### visitClosureExpression

    public void visitClosureExpression(ClosureExpression expr)
    Specified by:
      `visitClosureExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureExpression` in class `ClassCodeVisitorSupport`

  - ### visitField

    public void visitField(FieldNode node)
    Description copied from interface: `GroovyClassVisitor`
    Visit a FieldNode.
    Specified by:
      `visitField` in interface `GroovyClassVisitor`
    Overrides:
      `visitField` in class `ClassCodeVisitorSupport`

  - ### visitProperty

    public void visitProperty(PropertyNode node)
    Description copied from interface: `GroovyClassVisitor`
    Visit a PropertyNode.
    Specified by:
      `visitProperty` in interface `GroovyClassVisitor`
    Overrides:
      `visitProperty` in class `ClassCodeVisitorSupport`

  - ### visitAssertStatement

    public void visitAssertStatement(AssertStatement stmt)
    Specified by:
      `visitAssertStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitAssertStatement` in class `ClassCodeVisitorSupport`

  - ### visitCaseStatement

    public void visitCaseStatement(CaseStatement stmt)
    Specified by:
      `visitCaseStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCaseStatement` in class `ClassCodeVisitorSupport`

  - ### visitDoWhileLoop

    public void visitDoWhileLoop(DoWhileStatement stmt)
    Specified by:
      `visitDoWhileLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitDoWhileLoop` in class `ClassCodeVisitorSupport`

  - ### visitExpressionStatement

    public void visitExpressionStatement(ExpressionStatement stmt)
    Specified by:
      `visitExpressionStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitExpressionStatement` in class `ClassCodeVisitorSupport`

  - ### visitForLoop

    public void visitForLoop(ForStatement stmt)
    Specified by:
      `visitForLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitForLoop` in class `ClassCodeVisitorSupport`

  - ### visitIfElse

    public void visitIfElse(IfStatement stmt)
    Specified by:
      `visitIfElse` in interface `GroovyCodeVisitor`
    Overrides:
      `visitIfElse` in class `ClassCodeVisitorSupport`

  - ### visitReturnStatement

    public void visitReturnStatement(ReturnStatement stmt)
    Specified by:
      `visitReturnStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitReturnStatement` in class `ClassCodeVisitorSupport`

  - ### visitSwitch

    public void visitSwitch(SwitchStatement stmt)
    Specified by:
      `visitSwitch` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSwitch` in class `ClassCodeVisitorSupport`

  - ### visitSynchronizedStatement

    public void visitSynchronizedStatement(SynchronizedStatement stmt)
    Specified by:
      `visitSynchronizedStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitSynchronizedStatement` in class `ClassCodeVisitorSupport`

  - ### visitThrowStatement

    public void visitThrowStatement(ThrowStatement stmt)
    Specified by:
      `visitThrowStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitThrowStatement` in class `ClassCodeVisitorSupport`

  - ### visitWhileLoop

    public void visitWhileLoop(WhileStatement stmt)
    Specified by:
      `visitWhileLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitWhileLoop` in class `ClassCodeVisitorSupport`

  - ### setSourcePosition

    protected static void setSourcePosition(Expression target, Expression source)
    Transfers the source position to target including its property expression if it has one.
    Parameters:
      `target` - resulting node
      `source` - original node