Package org.apache.groovy.macrolib
Class MacroLibGroovyMethods
java.lang.Object
org.apache.groovy.macrolib.MacroLibGroovyMethods
Macro library helpers for string and named-value expansion.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectRuntime stub forDO(MacroContext, Expression...).static ExpressionDO(MacroContext ctx, Expression... exps) Monadic comprehension macro (DO).static <T> NamedValue<T>Runtime stub forNV(MacroContext, Expression).static ExpressionNV(MacroContext ctx, Expression exp) Builds aNamedValueexpression from the supplied expression.static <T> List<NamedValue<T>>Runtime stub forNVL(MacroContext, Expression...).static ExpressionNVL(MacroContext ctx, Expression... exps) Builds a list ofNamedValueexpressions from the supplied expressions.static GStringRuntime stub forSV(MacroContext, Expression...).static ExpressionSV(MacroContext ctx, Expression... exps) Builds a GString expression that labels each supplied expression with its source text.static GStringRuntime stub forSVD(MacroContext, Expression...).static ExpressionSVD(MacroContext ctx, Expression... exps) Builds a GString expression that labels each supplied expression with its dumped value.static GStringRuntime stub forSVI(MacroContext, Expression...).static ExpressionSVI(MacroContext ctx, Expression... exps) Builds a GString expression that labels each supplied expression with its inspected value.
-
Method Details
-
SV
Builds a GString expression that labels each supplied expression with its source text.- Parameters:
ctx- the current macro contextexps- the expressions to interpolate- Returns:
- the labeled GString expression
-
SV
Runtime stub forSV(MacroContext, Expression...).- Parameters:
self- the receiverargs- the interpolated values- Returns:
- never returns normally
-
SVI
Builds a GString expression that labels each supplied expression with its inspected value.- Parameters:
ctx- the current macro contextexps- the expressions to inspect- Returns:
- the labeled GString expression
-
SVI
Runtime stub forSVI(MacroContext, Expression...).- Parameters:
self- the receiverargs- the interpolated values- Returns:
- never returns normally
-
SVD
Builds a GString expression that labels each supplied expression with its dumped value.- Parameters:
ctx- the current macro contextexps- the expressions to dump- Returns:
- the labeled GString expression
-
SVD
Runtime stub forSVD(MacroContext, Expression...).- Parameters:
self- the receiverargs- the interpolated values- Returns:
- never returns normally
-
NV
Builds aNamedValueexpression from the supplied expression.- Parameters:
ctx- the current macro contextexp- the expression to wrap- Returns:
- the named-value expression
-
NV
Runtime stub forNV(MacroContext, Expression).- Type Parameters:
T- the value type- Parameters:
self- the receiverarg- the runtime value- Returns:
- never returns normally
-
NVL
Builds a list ofNamedValueexpressions from the supplied expressions.- Parameters:
ctx- the current macro contextexps- the expressions to wrap- Returns:
- the list expression
-
NVL
Runtime stub forNVL(MacroContext, Expression...).- Type Parameters:
T- the value type- Parameters:
self- the receiverargs- the runtime values- Returns:
- never returns normally
-
DO
Monadic comprehension macro (DO). Rewrites a comma-separated list ofname in expressiongenerators followed by a body closure into a nested chain ofComprehensions.bind(java.lang.Object, groovy.lang.Closure<?>)calls — the do-notation desugaring:DO(x in m1, y in f(x)) { body } ==> Comprehensions.bind(m1) { x -> Comprehensions.bind(f(x)) { y -> body } }Every generator becomes a bind; the body is the innermost closure body and must itself yield a carrier value (the do-notation rule — no implicit lifting). Carrier-specific bind dispatch is deferred to runtime (Comprehensions) because macros expand before type checking.- Parameters:
ctx- the current macro contextexps- the generators (eachname in expression) followed by the body closure- Returns:
- the nested bind-chain expression
- Since:
- 6.0.0
-
DO
Runtime stub forDO(MacroContext, Expression...).- Parameters:
self- the receiverargs- the runtime values- Returns:
- never returns normally
- Since:
- 6.0.0
-