public abstract class BaseVisitor
extends ClassCodeVisitorSupport
Base class for ClassCodeVisitorSupport descendants. This class is used in groovy-contracts as root class for all code visitors directly used by global AST transformations.
| Modifiers | Name | Description |
|---|---|---|
static String |
GCONTRACTS_ENABLED_VAR |
Local variable name used by generated code to guard contract execution. |
protected SourceUnit |
sourceUnit |
Source unit currently being visited. |
| Constructor and description |
|---|
BaseVisitor(SourceUnit sourceUnit, ReaderSource source)Creates a visitor bound to the supplied source unit. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static BooleanExpression |
asConditionExecution(AnnotationNode annotation)Creates a boolean expression that invokes the generated closure backing the supplied annotation. |
|
protected static ClosureExpression |
getOriginalCondition(AnnotationNode annotation)Returns the original closure expression stored on the annotation, if it has not yet been replaced. |
|
protected static Expression |
getReplacedCondition(AnnotationNode annotation)Returns the rewritten annotation value once the original closure has been replaced. |
|
protected SourceUnit |
getSourceUnit()Returns the source unit associated with this visitor. |
|
protected static void |
replaceCondition(AnnotationNode node, Expression expr)Replaces the annotation value with the generated expression used by later transformation phases. |
Local variable name used by generated code to guard contract execution.
Source unit currently being visited.
Creates a visitor bound to the supplied source unit.
sourceUnit - the source unit currently being transformedsource - the reader source backing the source unitCreates a boolean expression that invokes the generated closure backing the supplied annotation.
annotation - the contract annotation whose closure should be executedReturns the original closure expression stored on the annotation, if it has not yet been replaced.
annotation - the annotation to inspectnull if it has already been rewrittenReturns the rewritten annotation value once the original closure has been replaced.
annotation - the annotation to inspectnull while the original closure is still presentReturns the source unit associated with this visitor.
Replaces the annotation value with the generated expression used by later transformation phases.
node - the annotation to updateexpr - the replacement expressionCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.