Package org.codehaus.groovy.transform
Class AsyncTransformHelper
java.lang.Object
org.codehaus.groovy.transform.AsyncTransformHelper
Shared AST utilities for the
async/await/defer language features.
Centralises AST node construction for the parser (AstBuilder).
- Since:
- 6.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExpressionbuildAsyncCall(Expression closure) BuildsAsyncSupport.async(closure)— starts immediately, returns Awaitable.static ExpressionbuildAsyncGeneratorCall(Expression closure) BuildsAsyncSupport.asyncGenerator(closure)— starts immediately, returns Iterable.static ExpressionbuildAwaitCall(Expression arg) BuildsAsyncSupport.await(arg)or for multi-arg:AsyncSupport.await(Awaitable.all(arg1, arg2, ...)).static ExpressionbuildCloseIterableCall(Expression source) BuildsAsyncSupport.closeIterable(source).static ExpressionbuildDeferCall(Expression action) BuildsAsyncSupport.defer($__deferScope__, action).static ExpressionbuildToIterableCall(Expression source) BuildsAsyncSupport.toIterable(source).static ExpressionBuildsAsyncSupport.yieldReturn($__asyncGen__, expr).static booleancontainsDefer(Statement stmt) Returnstrueif the statement tree contains adefercall, without descending into nested closures.static booleancontainsYieldReturn(Statement stmt) Returnstrueif the statement tree contains ayield returncall, without descending into nested closures.static ParameterCreates the synthetic generator parameter$__asyncGen__.static voidinjectGenParamIntoYieldReturnCalls(Statement stmt, Parameter genParam) RewritesyieldReturn(expr)calls toyieldReturn($__asyncGen__, expr)by injecting the generator parameter reference.static StatementwrapWithDeferScope(Statement body) Wraps a statement block with defer scope management:
-
Method Details
-
buildAwaitCall
BuildsAsyncSupport.await(arg)or for multi-arg:AsyncSupport.await(Awaitable.all(arg1, arg2, ...)). -
buildDeferCall
BuildsAsyncSupport.defer($__deferScope__, action). -
buildYieldReturnCall
BuildsAsyncSupport.yieldReturn($__asyncGen__, expr). -
buildAsyncCall
BuildsAsyncSupport.async(closure)— starts immediately, returns Awaitable. -
buildAsyncGeneratorCall
BuildsAsyncSupport.asyncGenerator(closure)— starts immediately, returns Iterable. -
buildToIterableCall
BuildsAsyncSupport.toIterable(source). -
buildCloseIterableCall
BuildsAsyncSupport.closeIterable(source). -
createGenParam
Creates the synthetic generator parameter$__asyncGen__. -
containsYieldReturn
Returnstrueif the statement tree contains ayield returncall, without descending into nested closures. -
injectGenParamIntoYieldReturnCalls
RewritesyieldReturn(expr)calls toyieldReturn($__asyncGen__, expr)by injecting the generator parameter reference. -
containsDefer
Returnstrueif the statement tree contains adefercall, without descending into nested closures. -
wrapWithDeferScope
Wraps a statement block with defer scope management:var $__deferScope__ = AsyncSupport.createDeferScope() try { original body } finally { AsyncSupport.executeDeferScope($__deferScope__) }
-