Deprecated
The AstBuilder "from code" approach is used with a single Closure parameter. This transformation converts the ClosureExpression back into source code and rewrites the AST so that the "from string" builder is invoked on the source. In order for this to work, the closure source must be given a goto label. It is the "from string" approach's responsibility to remove the BlockStatement created by the label.
| Modifier and Type | Class and Description |
|---|---|
| private static class | AstBuilderTransformation.AstBuilderInvocationTrap
This class traps invocations of AstBuilder.build(CompilePhase, boolean, Closure) and converts the contents of the closure into expressions by reading the source of the Closure and sending that as a String to AstBuilder.build(String, CompilePhase, boolean) at runtime. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected GroovyCodeVisitor | getTransformer(ASTNode[] nodes, SourceUnit sourceUnit)
Implements abstract org. |
| AstBuilderTransformation | back to summary |
|---|---|
| public AstBuilderTransformation() | |
| getTransformer | back to summary |
|---|---|
| protected GroovyCodeVisitor getTransformer(ASTNode[] nodes, SourceUnit sourceUnit) Implements abstract org.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final List |
| Access | Constructor and Description |
|---|---|
| pack-priv | AstBuilderInvocationTrap(List<ImportNode>
all the imports from the source imports, List<ImportNode> all the imported packages from the source importPackages, ReaderSource the reader source that contains source for the SourceUnit source, SourceUnit the source unit being compiled. Used for error messages. sourceUnit)Creates the trap and captures all the ways in which a class may be referenced via imports. |
| Modifier and Type | Method and Description |
|---|---|
| private static ClosureExpression | |
| private static List | |
| protected boolean | |
| protected boolean | isBuildInvocation(MethodCallExpression
the method call expression, may not be null call)Implements abstract org. |
| factoryTargets | back to summary |
|---|---|
| private final List<String> factoryTargets | |
| AstBuilderInvocationTrap | back to summary |
|---|---|
| pack-priv AstBuilderInvocationTrap(List<ImportNode> imports, List<ImportNode> importPackages, ReaderSource source, SourceUnit sourceUnit) Creates the trap and captures all the ways in which a class may be referenced via imports.
| |
| getClosureArgument | back to summary |
|---|---|
| private static ClosureExpression getClosureArgument(MethodCallExpression call) | |
| getNonClosureArguments | back to summary |
|---|---|
| private static List | |
| handleTargetMethodCallExpression | back to summary |
|---|---|
| protected boolean handleTargetMethodCallExpression(MethodCallExpression call) Implements abstract org.
| |
| isBuildInvocation | back to summary |
|---|---|
| protected boolean isBuildInvocation(MethodCallExpression call) Implements abstract org. Looks for method calls on the AstBuilder class called build that take a Closure as parameter. This is all needed b/c build is overloaded.
| |