public class MacroGroovyMethods
extends Object
Macro extension methods and helpers used during macro expansion.
| Modifiers | Name | Description |
|---|---|---|
static class |
MacroGroovyMethods.MacroValuePlaceholder |
Delegate used inside macro closures for $v substitutions. |
| Modifiers | Name | Description |
|---|---|---|
static String |
DOLLAR_VALUE |
Placeholder method name used for value substitution inside macros. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static ListExpression |
buildSubstitutions(SourceUnit source, ASTNode expr)Collects substitution closures referenced by $v calls. |
|
protected static ClosureExpression |
getClosureArgument(SourceUnit source, MethodCallExpression call)Returns the closure argument from a macro-style method call. |
|
protected static TupleExpression |
getMacroArguments(SourceUnit source, MethodCallExpression call)Extracts tuple arguments from a macro-style method call. |
<T> |
public static T |
macro(Object self, Closure cl)Runtime stub for macro { ... } calls. |
|
public static Expression |
macro(MacroContext macroContext, ClosureExpression closureExpression)Rewrites a macro closure into an expression builder call. |
<T> |
public static T |
macro(Object self, boolean asIs, Closure cl)Runtime stub for macro(asIs) { ... } calls. |
|
public static Expression |
macro(MacroContext macroContext, ConstantExpression asIsConstantExpression, ClosureExpression closureExpression)Rewrites a macro closure into an expression builder call. |
<T> |
public static T |
macro(Object self, CompilePhase compilePhase, Closure cl)Runtime stub for macro(phase) { ... } calls. |
|
public static Expression |
macro(MacroContext macroContext, PropertyExpression phaseExpression, ClosureExpression closureExpression)Rewrites a macro closure into an expression builder call. |
<T> |
public static T |
macro(Object self, CompilePhase compilePhase, boolean asIs, Closure cl)Runtime stub for macro(phase, asIs) { ... } calls. |
|
public static Expression |
macro(MacroContext macroContext, PropertyExpression phaseExpression, ConstantExpression asIsConstantExpression, ClosureExpression closureExpression)Rewrites a macro closure into an expression builder call. |
Placeholder method name used for value substitution inside macros.
Collects substitution closures referenced by $v calls.
source - the current source unitexpr - the AST node to scanReturns the closure argument from a macro-style method call.
source - the current source unitcall - the method call to inspectnull after reporting an errorExtracts tuple arguments from a macro-style method call.
source - the current source unitcall - the method call to inspectnull after reporting an error Runtime stub for macro { ... } calls.
self - the receivercl - the macro closureT - the inferred result typeRewrites a macro closure into an expression builder call.
macroContext - the current macro contextclosureExpression - the macro closure Runtime stub for macro(asIs) { ... } calls.
self - the receiverasIs - whether to keep the closure block intactcl - the macro closureT - the inferred result typeRewrites a macro closure into an expression builder call.
macroContext - the current macro contextasIsConstantExpression - whether to keep the closure block intactclosureExpression - the macro closure Runtime stub for macro(phase) { ... } calls.
self - the receivercompilePhase - the phase used to parse the macro bodycl - the macro closureT - the inferred result typeRewrites a macro closure into an expression builder call.
macroContext - the current macro contextphaseExpression - the compile phase expressionclosureExpression - the macro closure Runtime stub for macro(phase, asIs) { ... } calls.
self - the receivercompilePhase - the phase used to parse the macro bodyasIs - whether to keep the closure block intactcl - the macro closureT - the inferred result typeRewrites a macro closure into an expression builder call.
macroContext - the current macro contextphaseExpression - the compile phase expressionasIsConstantExpression - whether to keep the closure block intactclosureExpression - the macro closure