Package: org.codehaus.groovy.macro.methods

## [Java] Class MacroGroovyMethods

- org.codehaus.groovy.macro.methods.MacroGroovyMethods

-     public class MacroGroovyMethods
      extends Object

  Macro extension methods and helpers used during macro expansion.

  Since:
    2.5.0

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `MacroGroovyMethods.MacroValuePlaceholder` | Delegate used inside macro closures for `$v` substitutions.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `DOLLAR_VALUE` | Placeholder method name used for value substitution inside macros.

  - ### Methods Summary

    Methods
    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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final String DOLLAR_VALUE

      Placeholder method name used for value substitution inside macros.

  - ### Method Detail

    - #### public static ListExpression buildSubstitutions(SourceUnit source, ASTNode expr)

      Collects substitution closures referenced by `$v` calls.

      Parameters:
        `source` - the current source unit
        `expr` - the AST node to scan
      Returns:
        a list expression containing substitution closures

    - #### protected static ClosureExpression getClosureArgument(SourceUnit source, MethodCallExpression call)

      Returns the closure argument from a macro-style method call.

      Parameters:
        `source` - the current source unit
        `call` - the method call to inspect
      Returns:
        the trailing closure argument, or `null` after reporting an error

    - #### protected static TupleExpression getMacroArguments(SourceUnit source, MethodCallExpression call)

      Extracts tuple arguments from a macro-style method call.

      Parameters:
        `source` - the current source unit
        `call` - the method call to inspect
      Returns:
        the tuple expression, or `null` after reporting an error

    - #### <T> public static T macro(Object self, @DelegatesTo(MacroValuePlaceholder.class)
      Closure cl)

      Runtime stub for `macro { ...` } calls.

      Parameters:
        `self` - the receiver
        `cl` - the macro closure
      Type Parameters:
        `T` - the inferred result type
      Returns:
        never returns normally

    - #### @Macro
      public static Expression macro(MacroContext macroContext, ClosureExpression closureExpression)

      Rewrites a macro closure into an expression builder call.

      Parameters:
        `macroContext` - the current macro context
        `closureExpression` - the macro closure
      Returns:
        an expression that builds the macro result

    - #### <T> public static T macro(Object self, boolean asIs, @DelegatesTo(MacroValuePlaceholder.class)
      Closure cl)

      Runtime stub for `macro(asIs) { ...` } calls.

      Parameters:
        `self` - the receiver
        `asIs` - whether to keep the closure block intact
        `cl` - the macro closure
      Type Parameters:
        `T` - the inferred result type
      Returns:
        never returns normally

    - #### @Macro
      public static Expression macro(MacroContext macroContext, ConstantExpression asIsConstantExpression, ClosureExpression closureExpression)

      Rewrites a macro closure into an expression builder call.

      Parameters:
        `macroContext` - the current macro context
        `asIsConstantExpression` - whether to keep the closure block intact
        `closureExpression` - the macro closure
      Returns:
        an expression that builds the macro result

    - #### <T> public static T macro(Object self, CompilePhase compilePhase, @DelegatesTo(MacroValuePlaceholder.class)
      Closure cl)

      Runtime stub for `macro(phase) { ...` } calls.

      Parameters:
        `self` - the receiver
        `compilePhase` - the phase used to parse the macro body
        `cl` - the macro closure
      Type Parameters:
        `T` - the inferred result type
      Returns:
        never returns normally

    - #### @Macro
      public static Expression macro(MacroContext macroContext, PropertyExpression phaseExpression, ClosureExpression closureExpression)

      Rewrites a macro closure into an expression builder call.

      Parameters:
        `macroContext` - the current macro context
        `phaseExpression` - the compile phase expression
        `closureExpression` - the macro closure
      Returns:
        an expression that builds the macro result

    - #### <T> public static T macro(Object self, CompilePhase compilePhase, boolean asIs, @DelegatesTo(MacroValuePlaceholder.class)
      Closure cl)

      Runtime stub for `macro(phase, asIs) { ...` } calls.

      Parameters:
        `self` - the receiver
        `compilePhase` - the phase used to parse the macro body
        `asIs` - whether to keep the closure block intact
        `cl` - the macro closure
      Type Parameters:
        `T` - the inferred result type
      Returns:
        never returns normally

    - #### @Macro
      public static Expression macro(MacroContext macroContext, PropertyExpression phaseExpression, ConstantExpression asIsConstantExpression, ClosureExpression closureExpression)

      Rewrites a macro closure into an expression builder call.

      Parameters:
        `macroContext` - the current macro context
        `phaseExpression` - the compile phase expression
        `asIsConstantExpression` - whether to keep the closure block intact
        `closureExpression` - the macro closure
      Returns:
        an expression that builds the macro result