Class TransformingCodeVisitor

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.TransformingCodeVisitor
All Implemented Interfaces:
GroovyCodeVisitor

public class TransformingCodeVisitor extends CodeVisitorSupport
Code visitor that combines depth-first traversal with expression transformation, delegating both to an underlying ClassCodeExpressionTransformer.

This visitor implements a two-phase approach for each statement and expression:

  1. Depth-first traversal via the parent CodeVisitorSupport class visits child nodes
  2. Expression transformation via the ClassCodeExpressionTransformer processes the node

This pattern enables both traversal and transformation in a single pass. The transformer receives fully-traversed nodes, allowing it to operate on complete subtrees or apply post-processing transformations after children are visited.

Typical usage involves creating a subclass of ClassCodeExpressionTransformer and passing it to this visitor:

   ClassCodeExpressionTransformer transformer = new MyTransformer(...);
   TransformingCodeVisitor visitor = new TransformingCodeVisitor(transformer);
   node.visit(visitor);
 
See Also: