Class AutoImplementASTStubber

java.lang.Object
org.codehaus.groovy.transform.AbstractASTTransformation
org.codehaus.groovy.transform.AutoImplementASTStubber
All Implemented Interfaces:
ASTTransformation, ErrorCollecting

public class AutoImplementASTStubber extends AbstractASTTransformation
Joint-compilation stubber for AutoImplement. Emits placeholder implementations of abstract methods reachable through the supertype and interface graph, so Java consumers can call those methods against the joint-compilation stub.

The walk mirrors the full transform's AutoImplementASTTransformation.getAllCorrectedMethodsMap(org.codehaus.groovy.ast.ClassNode): classpath supertypes/interfaces are fully resolved at CONVERSION; same-unit Groovy supertypes/interfaces have their source-declared abstracts visible too.

Boundary. Abstract methods contributed by another transform to a same-unit Groovy supertype/interface (most notably trait abstracts, since TraitASTTransformation runs at CANONICALIZATION after this stubber) are not visible at CONVERSION and therefore not stubbed. The runtime still implements them; only the Java-visible stub surface is reduced. Java callers that reach for those members get a stub-time compile error rather than a stub/runtime mismatch.

The placeholder body is a default-value return; the real body is installed by the full transform at CANONICALIZATION, which first discards stubber-tagged placeholders so the walk over isAbstract() candidates sees the true abstract surface again.

Since:
6.0.0
  • Constructor Details

    • AutoImplementASTStubber

      public AutoImplementASTStubber()
  • Method Details

    • visit

      public void visit(ASTNode[] nodes, SourceUnit source)
      Description copied from interface: ASTTransformation
      The method is invoked when an AST Transformation is active. For local transformations, it is invoked once each time the local annotation is encountered. For global transformations, it is invoked once for every source unit, which is typically a source file.
      Parameters:
      nodes - The ASTnodes when the call was triggered. Element 0 is the AnnotationNode that triggered this annotation to be activated. Element 1 is the AnnotatedNode decorated, such as a MethodNode or ClassNode. For global transformations it is usually safe to ignore this parameter.
      source - The source unit being compiled. The source unit may contain several classes. For global transformations, information about the AST can be retrieved from this object.