Class CodeVisitorSupport

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
All Implemented Interfaces:
GroovyCodeVisitor
Direct Known Subclasses:
ClassCodeVisitorSupport, ClosureWriter.CorrectAccessedVariableVisitor, CollectRecursiveCalls, GinqAstBaseVisitor, GinqAstBuilder, HasRecursiveCalls, MethodInvocationTrap, ReturnAdderForClosures, SqlOrderByVisitor, SqlWhereVisitor, StatementReplacer, TransformingCodeVisitor, VariableExpressionReplacer, VerifierCodeVisitor

public abstract class CodeVisitorSupport extends Object implements GroovyCodeVisitor
Abstract base class for implementing the GroovyCodeVisitor interface, providing default implementations for all visit methods that perform depth-first traversal of the AST.

This class implements the visitor design pattern for Groovy AST nodes. Subclasses may override specific visit methods to perform custom processing, while other visit methods automatically traverse child nodes. Default implementations delegate to child nodes, allowing for simple tree traversal without accumulating logic in each subclass.

The traversal pattern follows the structure of the AST:

  • Block and control flow statements recursively visit their contained statements
  • Expressions recursively visit their operand expressions
  • Terminal expressions (constants, variables) perform no traversal

Subclasses typically override visit* methods of interest and call super.visit*(node) to maintain the default traversal behavior or to perform post-processing after traversing children.

See Also: