# Package org.apache.groovy.contracts.ast

package org.apache.groovy.contracts.ast
AST transformations for implementing Design by Contract semantics, including precondition, postcondition, and invariant validation transformations.

- Related Packages
  Package
  Description
  org.apache.groovy.contracts
  Provides Design by Contract (DbC) support for Groovy classes and methods.
  org.apache.groovy.contracts.ast.visitor
  Visitor implementations for AST traversal and manipulation during contract transformation processing.
  org.apache.groovy.contracts.domain
  Domain model classes representing contract elements such as preconditions, postconditions, and class invariants.
  org.apache.groovy.contracts.generation
  Code generation and transformation utilities for producing runtime contract validation code.
  org.apache.groovy.contracts.util
  Utility functions and helper classes for contract processing and validation.
- Classes
  Class
  Description
  BaseASTTransformation
  Base AST transformation encapsulating all common helper methods and implementing `ASTTransformation`.
  ClosureExpressionEvaluationASTTransformation
  Evaluates `ClosureExpression` instances in annotation parameters and generates special contract closure classes from them.
  GContractsASTTransformation
  Custom AST transformation that removes closure annotations of `Invariant`, `Requires` and `Ensures` and adds Java assertions executing the closure-code.
  LoopInvariantASTTransformation
  Handles `Invariant` annotations placed on loop statements (`for`, `while`, `do-while`).
  LoopVariantASTTransformation
  Handles `Decreases` annotations placed on loop statements (`for`, `while`, `do-while`).
  MethodVariantASTTransformation
  Handles a `Decreases` annotation placed on a method (the loop case is handled by `LoopVariantASTTransformation`).
  MethodVariantInheritanceASTTransformation
  Inherits a method-level `Decreases` termination measure onto an override that does not redeclare it — mirroring how groovy-contracts inherits `@Requires`/`@Ensures` (Liskov substitution).
  ModifiesASTTransformation
  Handles `Modifies` annotations placed on methods.
  ModifiesEnsuresValidationTransformation
  Validates that `@Ensures` postconditions on a method only reference fields via `old.xxx` that are declared as modifiable by `@Modifies`.