Top Description Inners Constructors Methods
org.codehaus.groovy.ast.builder

public Class AstBuilderTransformation

extends MethodCallTransformation
Class Inheritance
Annotations
@Deprecated
@GroovyASTTransformation
phase:SEMANTIC_ANALYSIS
Imports
org.codehaus.groovy.ast.ASTNode, .GroovyCodeVisitor, .ImportNode, .MethodCallTransformation, .MethodInvocationTrap, org.codehaus.groovy.ast.expr.ArgumentListExpression, .ClosureExpression, .ConstantExpression, .Expression, .MethodCallExpression, .TupleExpression, org.codehaus.groovy.control.CompilePhase, .SourceUnit, org.codehaus.groovy.control.io.ReaderSource, org.codehaus.groovy.transform.GroovyASTTransformation, java.util.ArrayList, .List

Deprecated

Transformation to capture ASTBuilder from code statements.

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.

Nested and Inner Type Summary

Modifier and TypeClass 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.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected GroovyCodeVisitor
Inherited from org.codehaus.groovy.ast.MethodCallTransformation:
visit

Constructor Detail

AstBuilderTransformationback to summary
public AstBuilderTransformation()

Method Detail

getTransformerback to summary
protected GroovyCodeVisitor getTransformer(ASTNode[] nodes, SourceUnit sourceUnit)

Implements abstract org.codehaus.groovy.ast.MethodCallTransformation.getTransformer.

Annotations
@Override
org.codehaus.groovy.ast.builder back to summary

private Class AstBuilderTransformation.AstBuilderInvocationTrap

extends MethodInvocationTrap
Class Inheritance

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.

Field Summary

Modifier and TypeField and Description
private final List<String>
Inherited from org.codehaus.groovy.ast.MethodInvocationTrap:
sourcesourceUnit

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
private static ClosureExpression
private static List<Expression>
protected boolean
protected boolean
isBuildInvocation(MethodCallExpression
the method call expression, may not be null
call
)

Implements abstract org.codehaus.groovy.ast.MethodInvocationTrap.isBuildInvocation.

Looks for method calls on the AstBuilder class called build that take a Closure as parameter.
Inherited from org.codehaus.groovy.ast.MethodInvocationTrap:
addErrorconvertClosureToSourcevisitMethodCallExpression

Field Detail

factoryTargetsback to summary
private final List<String> factoryTargets

Constructor Detail

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

Parameters
imports:List<ImportNode>

all the imports from the source

importPackages:List<ImportNode>

all the imported packages from the source

source:ReaderSource

the reader source that contains source for the SourceUnit

sourceUnit:SourceUnit

the source unit being compiled. Used for error messages.

Method Detail

getClosureArgumentback to summary
private static ClosureExpression getClosureArgument(MethodCallExpression call)
getNonClosureArgumentsback to summary
private static List<Expression> getNonClosureArguments(MethodCallExpression call)
handleTargetMethodCallExpressionback to summary
protected boolean handleTargetMethodCallExpression(MethodCallExpression call)

Implements abstract org.codehaus.groovy.ast.MethodInvocationTrap.handleTargetMethodCallExpression.

Annotations
@Override
isBuildInvocationback to summary
protected boolean isBuildInvocation(MethodCallExpression call)

Implements abstract org.codehaus.groovy.ast.MethodInvocationTrap.isBuildInvocation.

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.

Parameters
call:MethodCallExpression

the method call expression, may not be null

Annotations
@Override