Package org.codehaus.groovy.control
Class OptimizerVisitor
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeExpressionTransformer
org.codehaus.groovy.control.OptimizerVisitor
- All Implemented Interfaces:
ExpressionTransformer
,GroovyClassVisitor
,GroovyCodeVisitor
,ErrorCollecting
Visitor to produce several optimizations:
- to replace numbered constants with references to static fields
- remove superfluous references to GroovyObject interface
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SourceUnit
transform
(Expression exp) NOTE: This method does not visit Expressions within Closures, for performance and historical reasons.void
visitClass
(ClassNode node, SourceUnit source) void
visitClosureExpression
(ClosureExpression expression) Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
setSourcePosition, visitAnnotation, visitAssertStatement, visitCaseStatement, visitConstructorOrMethod, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoop
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotations, visitAnnotations, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitTryCatchFinally
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, 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 org.codehaus.groovy.ast.GroovyCodeVisitor
visit, visit, visitEmptyExpression, visitListOfExpressions
-
Constructor Details
-
OptimizerVisitor
-
-
Method Details
-
visitClass
-
transform
Description copied from class:ClassCodeExpressionTransformer
NOTE: This method does not visit Expressions within Closures, for performance and historical reasons. If you want those Expressions to be visited, you can do this:public class YourTransformer extends ClassCodeExpressionTransformer { ... @Override public Expression transform(final Expression expr) { if (expr instanceof ClosureExpression) { expr.visit(this); return expr; } // ... } }
- Specified by:
transform
in interfaceExpressionTransformer
- Overrides:
transform
in classClassCodeExpressionTransformer
-
getSourceUnit
- Specified by:
getSourceUnit
in classClassCodeVisitorSupport
-
visitClosureExpression
- Specified by:
visitClosureExpression
in interfaceGroovyCodeVisitor
- Overrides:
visitClosureExpression
in classCodeVisitorSupport
-