Class InheritConstructorsASTStubber

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

public class InheritConstructorsASTStubber extends AbstractASTTransformation
Joint-compilation stubber for InheritConstructors. Walks the superclass's declared constructors and adds a placeholder constructor on the annotated subclass for each non-private signature not already present — mirroring the surface the full transform produces at CANONICALIZATION, but at CONVERSION so the joint-compilation stub reflects it.

The placeholder body is super(args) to ensure the generated stub Java file compiles cleanly even when the super class has no no-arg constructor; the full transform discards the stubber-tagged placeholder before installing its real body.

Recursive case. If the superclass also carries @InheritConstructors, this stubber pre-processes it (the same idiom the full transform uses), so chains like Sub → Mid → Base flatten correctly within the stubber pass.

Boundary. When the super class is in the same compilation unit and its constructors come from another CONVERSION-phase stubber (@TupleConstructor, @MapConstructor), visibility depends on within-phase iteration order: super-declared-first sees those constructors, sub-declared-first does not. The stub remains a subset of the runtime — Java callers reaching for sub's stub get a compile error for non-stubbed signatures rather than a stub/runtime divergence. The full transform at CANONICALIZATION still produces the complete surface at runtime.

Since:
6.0.0
  • Constructor Details

    • InheritConstructorsASTStubber

      public InheritConstructorsASTStubber()
  • 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.