Package org.codehaus.groovy.control
Class ResolveVisitor
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeExpressionTransformer
org.codehaus.groovy.control.ResolveVisitor
- All Implemented Interfaces:
ExpressionTransformer
,GroovyClassVisitor
,GroovyCodeVisitor
,ErrorCollecting
- Direct Known Subclasses:
JavaAwareResolveVisitor
Visitor to resolve types and convert VariableExpression to
ClassExpressions if needed. The ResolveVisitor will try to
find the Class for a ClassExpression and prints an error if
it fails to do so. Constructions like C[], foo as C, (C) foo
will force creation of a ClassExpression for C
Note: the method to start the resolving is startResolving(ClassNode,SourceUnit)
.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SourceUnit
protected boolean
protected boolean
resolve
(ClassNode type, boolean testModuleImports, boolean testDefaultImports, boolean testStaticInnerClasses) protected boolean
protected boolean
protected boolean
resolveFromDefaultImports
(ClassNode type, String[] packagePrefixes) protected boolean
resolveFromModule
(ClassNode type, boolean testModuleImports) protected boolean
protected boolean
resolveNestedClass
(ClassNode type) protected boolean
resolveToInner
(ClassNode type) protected boolean
resolveToOuter
(ClassNode type) void
setClassNodeResolver
(ClassNodeResolver classNodeResolver) void
startResolving
(ClassNode node, SourceUnit source) transform
(Expression exp) NOTE: This method does not visit Expressions within Closures, for performance and historical reasons.protected Expression
protected Expression
protected Expression
protected Expression
protected Expression
protected Expression
protected Expression
protected Expression
protected void
void
void
void
visitClass
(ClassNode node) Visit a ClassNode.protected void
visitConstructorOrMethod
(MethodNode node, boolean isConstructor) void
visitField
(FieldNode node) Visit a FieldNode.void
visitForLoop
(ForStatement forLoop) void
visitProperty
(PropertyNode node) Visit a PropertyNode.Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
setSourcePosition, visitAssertStatement, visitCaseStatement, visitDoWhileLoop, visitExpressionStatement, visitIfElse, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoop
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotations, visitAnnotations, visitBreakStatement, 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, visitClosureExpression, 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
-
Field Details
-
DEFAULT_IMPORTS
-
EMPTY_STRING_ARRAY
-
QUESTION_MARK
- See Also:
-
-
Constructor Details
-
ResolveVisitor
-
-
Method Details
-
setClassNodeResolver
-
startResolving
-
getSourceUnit
- Specified by:
getSourceUnit
in classClassCodeVisitorSupport
-
visitConstructorOrMethod
- Overrides:
visitConstructorOrMethod
in classClassCodeExpressionTransformer
-
visitField
Description copied from interface:GroovyClassVisitor
Visit a FieldNode.- Specified by:
visitField
in interfaceGroovyClassVisitor
- Overrides:
visitField
in classClassCodeExpressionTransformer
-
visitProperty
Description copied from interface:GroovyClassVisitor
Visit a PropertyNode.- Specified by:
visitProperty
in interfaceGroovyClassVisitor
- Overrides:
visitProperty
in classClassCodeExpressionTransformer
-
resolveToInner
-
resolve
-
resolve
protected boolean resolve(ClassNode type, boolean testModuleImports, boolean testDefaultImports, boolean testStaticInnerClasses) -
resolveNestedClass
-
resolveFromStaticInnerClasses
-
resolveFromDefaultImports
-
resolveFromDefaultImports
-
resolveFromCompileUnit
-
resolveFromModule
-
resolveToOuter
-
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
-
transformPropertyExpression
-
transformVariableExpression
-
transformBinaryExpression
-
transformClosureExpression
-
transformConstructorCallExpression
-
transformMethodCallExpression
-
transformDeclarationExpression
-
transformAnnotationConstantExpression
-
visitAnnotation
- Overrides:
visitAnnotation
in classClassCodeExpressionTransformer
-
visitClass
Description copied from interface:GroovyClassVisitor
Visit a ClassNode.- Specified by:
visitClass
in interfaceGroovyClassVisitor
- Overrides:
visitClass
in classClassCodeVisitorSupport
-
visitCatchStatement
- Specified by:
visitCatchStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitCatchStatement
in classClassCodeVisitorSupport
-
visitForLoop
- Specified by:
visitForLoop
in interfaceGroovyCodeVisitor
- Overrides:
visitForLoop
in classClassCodeExpressionTransformer
-
visitBlockStatement
- Specified by:
visitBlockStatement
in interfaceGroovyCodeVisitor
- Overrides:
visitBlockStatement
in classClassCodeVisitorSupport
-