Package asteroid.transformer
Class AbstractExpressionTransformer<T extends Expression>
- java.lang.Object
-
- org.codehaus.groovy.ast.CodeVisitorSupport
-
- org.codehaus.groovy.ast.ClassCodeVisitorSupport
-
- org.codehaus.groovy.ast.ClassCodeExpressionTransformer
-
- asteroid.transformer.AbstractTransformer
-
- asteroid.transformer.AbstractExpressionTransformer<T>
-
- Type Parameters:
T- use as a hint for thetransformExpression(T)method parameter
- All Implemented Interfaces:
Transformer,ExpressionTransformer,GroovyClassVisitor,GroovyCodeVisitor,ErrorCollecting
public abstract class AbstractExpressionTransformer<T extends Expression> extends AbstractTransformer
ThisTransformercould be used as a base for transformingExpressioninstances.
IMPORTANT: The parameter type is only used as a hint. If you are not carefull on how you define the search criteria you could get aClassCastExceptionat runtime. The criteria should ask for the type of the expression in the first place.- Since:
- 0.2.0
-
-
Constructor Summary
Constructors Constructor Description AbstractExpressionTransformer(Class<T> clazz, SourceUnit sourceUnit)Every instance needs the source unit awareness and the name of the method it's going to transformAbstractExpressionTransformer(Class<T> clazz, SourceUnit sourceUnit, Closure<Boolean> criteria)Every instance needs the source unit awareness and the name of the method it's going to transform
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Closure<Boolean>everything()Deprecated.useCriteriasExpressiontransform(Expression expression)abstract ExpressiontransformExpression(T expression)This method will transform the expression into its final version.-
Methods inherited from class asteroid.transformer.AbstractTransformer
getModule, getModulePackageName, getSourceUnit
-
Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
visitAnnotations, visitAssertStatement, visitCaseStatement, visitConstructorOrMethod, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoop
-
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitTryCatchFinally
-
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitListExpression, visitListOfExpressions, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface asteroid.transformer.Transformer
visitClass
-
-
-
-
Constructor Detail
-
AbstractExpressionTransformer
public AbstractExpressionTransformer(Class<T> clazz, SourceUnit sourceUnit, Closure<Boolean> criteria)
Every instance needs the source unit awareness and the name of the method it's going to transform- Parameters:
clazz- the type of the expression we're interested insourceUnit- Needed to apply scopecriteria- the criteria used to search the interestingExpression- Since:
- 0.2.3
-
AbstractExpressionTransformer
public AbstractExpressionTransformer(Class<T> clazz, SourceUnit sourceUnit)
Every instance needs the source unit awareness and the name of the method it's going to transform- Parameters:
clazz- the type of the expression we're interested insourceUnit- Needed to apply scopeExpression- Since:
- 0.2.3
-
-
Method Detail
-
transform
public Expression transform(Expression expression)
- Specified by:
transformin interfaceExpressionTransformer- Overrides:
transformin classClassCodeExpressionTransformer
-
transformExpression
public abstract Expression transformExpression(T expression)
This method will transform the expression into its final version.- Parameters:
expression- the method expression you want to transform- Returns:
- the final version of the method expression
- Since:
- 0.2.0
-
everything
@Deprecated public static Closure<Boolean> everything()
Deprecated.useCriteriasThis criteria will make the transformer to process everyExpression- Returns:
- a criteria to process everything
- Since:
- 0.2.0
-
-