public class AnnotationClosureVisitor
extends BaseVisitor
implements ASTNodeMetaData
Visits interfaces & classes and looks for @Requires or @Ensures and creates Closure classes for the annotation closures.
The annotation closure classes are used later on to check interface contract pre- and post-conditions in implementation classes.
| Modifiers | Name | Description |
|---|---|---|
static String |
META_DATA_ORIGINAL_TRY_CATCH_BLOCK |
Metadata key used to stash the original try/catch wrapped assertion block for later phases. |
static String |
META_DATA_USE_EXECUTION_TRACKER |
Metadata flag indicating that the rewritten closure performs method calls and therefore needs execution tracking instead of inline expansion. |
static String |
OLD_REFERENCES_KEY |
Node metadata key for the set of field names referenced via old.xxx in postconditions. |
| Fields inherited from class | Fields |
|---|---|
class BaseVisitor |
GCONTRACTS_ENABLED_VAR, sourceUnit |
| Constructor and description |
|---|
AnnotationClosureVisitor(SourceUnit sourceUnit, ReaderSource source)Creates a visitor that rewrites contract annotation closures into generated closure classes. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
visitClass(ClassNode classNode)Rewrites class-level contract closures and then recurses into inherited types that may also contribute contract annotations. |
|
public void |
visitConstructorOrMethod(MethodNode methodNode, boolean isConstructor)Rewrites method- and constructor-level contract closures into generated closure classes and records auxiliary metadata needed by later transformation phases. |
Metadata key used to stash the original try/catch wrapped assertion block for later phases.
Metadata flag indicating that the rewritten closure performs method calls and therefore needs execution tracking instead of inline expansion.
Node metadata key for the set of field names referenced via old.xxx in postconditions.
Creates a visitor that rewrites contract annotation closures into generated closure classes.
sourceUnit - the source unit currently being transformedsource - the reader source backing the source unitRewrites class-level contract closures and then recurses into inherited types that may also contribute contract annotations.
classNode - the class currently being visitedRewrites method- and constructor-level contract closures into generated closure classes and records auxiliary metadata needed by later transformation phases.
methodNode - the method or constructor being visitedisConstructor - whether the visited executable is a constructorCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.