Package: org.codehaus.groovy.transform

## [Java] Class AsyncTransformHelper

- org.codehaus.groovy.transform.AsyncTransformHelper

-     public final class AsyncTransformHelper
      extends Object

  Shared AST utilities for the `async`/`await`/`defer` language features.

  Centralises AST node construction for the parser (`AstBuilder`).

  Since:
    6.0.0

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Expression` | `buildAsyncCall(Expression closure)` Builds `AsyncSupport.async(closure)` — starts immediately, returns Awaitable.
    `` | `public static Expression` | `buildAsyncGeneratorCall(Expression closure)` Builds `AsyncSupport.asyncGenerator(closure)` — starts immediately, returns Iterable.
    `` | `public static Expression` | `buildAwaitCall(Expression arg)` Builds `AsyncSupport.await(arg)` or for multi-arg: `AsyncSupport.await(Awaitable.all(arg1, arg2, ...))`.
    `` | `public static Expression` | `buildCloseIterableCall(Expression source)` Builds `AsyncSupport.closeIterable(source)`.
    `` | `public static Expression` | `buildDeferCall(Expression action)` Builds `AsyncSupport.defer($__deferScope__, action)`.
    `` | `public static Expression` | `buildToIterableCall(Expression source)` Builds `AsyncSupport.toIterable(source)`.
    `` | `public static Expression` | `buildYieldReturnCall(Expression arg)` Builds `AsyncSupport.yieldReturn($__asyncGen__, expr)`.
    `` | `public static boolean` | `containsDefer(Statement stmt)` Returns `true` if the statement tree contains a `defer` call, without descending into nested closures.
    `` | `public static boolean` | `containsYieldReturn(Statement stmt)` Returns `true` if the statement tree contains a `yield return` call, without descending into nested closures.
    `` | `public static Parameter` | `createGenParam()` Creates the synthetic generator parameter `$__asyncGen__`.
    `` | `public static void` | `injectGenParamIntoYieldReturnCalls(Statement stmt, Parameter genParam)` Rewrites `yieldReturn(expr)` calls to `yieldReturn($__asyncGen__, expr)` by injecting the generator parameter reference.
    `` | `public static Statement` | `wrapWithDeferScope(Statement body)` Wraps a statement block with defer scope management:
         var $__deferScope__ = AsyncSupport.createDeferScope()
         try { original body }
         finally { AsyncSupport.executeDeferScope($__deferScope__) }

  - ### Inherited Methods Summary

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

- - ### Method Detail

    - #### public static Expression buildAsyncCall(Expression closure)

      Builds `AsyncSupport.async(closure)` — starts immediately, returns Awaitable.

    - #### public static Expression buildAsyncGeneratorCall(Expression closure)

      Builds `AsyncSupport.asyncGenerator(closure)` — starts immediately, returns Iterable.

    - #### public static Expression buildAwaitCall(Expression arg)

      Builds `AsyncSupport.await(arg)` or for multi-arg: `AsyncSupport.await(Awaitable.all(arg1, arg2, ...))`.

    - #### public static Expression buildCloseIterableCall(Expression source)

      Builds `AsyncSupport.closeIterable(source)`.

    - #### public static Expression buildDeferCall(Expression action)

      Builds `AsyncSupport.defer($__deferScope__, action)`.

    - #### public static Expression buildToIterableCall(Expression source)

      Builds `AsyncSupport.toIterable(source)`.

    - #### public static Expression buildYieldReturnCall(Expression arg)

      Builds `AsyncSupport.yieldReturn($__asyncGen__, expr)`.

    - #### public static boolean containsDefer(Statement stmt)

      Returns `true` if the statement tree contains a `defer` call, without descending into nested closures.

    - #### public static boolean containsYieldReturn(Statement stmt)

      Returns `true` if the statement tree contains a `yield return` call, without descending into nested closures.

    - #### public static Parameter createGenParam()

      Creates the synthetic generator parameter `$__asyncGen__`.

    - #### public static void injectGenParamIntoYieldReturnCalls(Statement stmt, Parameter genParam)

      Rewrites `yieldReturn(expr)` calls to `yieldReturn($__asyncGen__, expr)` by injecting the generator parameter reference.

    - #### public static Statement wrapWithDeferScope(Statement body)

      Wraps a statement block with defer scope management:

           var $__deferScope__ = AsyncSupport.createDeferScope()
           try { original body }
           finally { AsyncSupport.executeDeferScope($__deferScope__) }