Package org.codehaus.groovy.transform
Class StubberSupport
java.lang.Object
org.codehaus.groovy.transform.StubberSupport
Utilities for GEP-21 Shape C joint-compilation stubbers.
A stubber emits placeholder members at Phases.CONVERSION so the
joint-compilation stub reflects what the full transform will produce at
its declared phase. The placeholder is tagged with STUB_METADATA_KEY;
the full transform recognises the tag and either replaces the placeholder
body or discards the placeholder before adding its own member.
All stubbers share a single metadata key — the runtime mapping between a placeholder and the full transform that should complete it is given by the member's signature, not by per-stubber namespacing.
- Since:
- 6.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMetadata key tagging a member that was added by a CONVERSION-phase stubber as a placeholder. -
Method Summary
Modifier and TypeMethodDescriptionstatic ConstructorNodeaddStubConstructor(ClassNode classNode, int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement body) Add a placeholder constructor viaClassNodeUtils.addGeneratedConstructor(ClassNode, int, Parameter[], ClassNode[], Statement)and tag it withSTUB_METADATA_KEY.static MethodNodeaddStubMethod(ClassNode classNode, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement body) Add a placeholder method viaClassNodeUtils.addGeneratedMethod(org.codehaus.groovy.ast.ClassNode, java.lang.String, int, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.Parameter[], org.codehaus.groovy.ast.ClassNode[], org.codehaus.groovy.ast.stmt.Statement)and tag it withSTUB_METADATA_KEY.static voidclearStub(AnnotatedNode node) Removes the stubber-placeholder tag fromnode, if present.static booleanisStub(AnnotatedNode node) Returns true whennodecarries the stubber-placeholder tag.static <T extends AnnotatedNode>
TtagAsStub(T node) Tag an existing node as a stubber placeholder.
-
Field Details
-
STUB_METADATA_KEY
Metadata key tagging a member that was added by a CONVERSION-phase stubber as a placeholder. The paired full transform consults this key to decide whether to replace the body or discard the placeholder.- See Also:
-
-
Method Details
-
addStubMethod
public static MethodNode addStubMethod(ClassNode classNode, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement body) Add a placeholder method viaClassNodeUtils.addGeneratedMethod(org.codehaus.groovy.ast.ClassNode, java.lang.String, int, org.codehaus.groovy.ast.ClassNode, org.codehaus.groovy.ast.Parameter[], org.codehaus.groovy.ast.ClassNode[], org.codehaus.groovy.ast.stmt.Statement)and tag it withSTUB_METADATA_KEY. -
addStubConstructor
public static ConstructorNode addStubConstructor(ClassNode classNode, int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement body) Add a placeholder constructor viaClassNodeUtils.addGeneratedConstructor(ClassNode, int, Parameter[], ClassNode[], Statement)and tag it withSTUB_METADATA_KEY. -
tagAsStub
Tag an existing node as a stubber placeholder. Useful when the addition itself goes through a shared helper (e.g.addComparableSurface) so the stubber receives the resulting node and only needs to tag it. -
isStub
Returns true whennodecarries the stubber-placeholder tag. -
clearStub
Removes the stubber-placeholder tag fromnode, if present.
-