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`

public class ResolveVisitor extends ClassCodeExpressionTransformer
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

  Fields
  Modifier and Type
  Field
  Description
  `static final String[]`
  `DEFAULT_IMPORTS`
  `static final String[]`
  `EMPTY_STRING_ARRAY`
  `static final String`
  `QUESTION_MARK`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ResolveVisitor(CompilationUnit compilationUnit)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected SourceUnit`
  `getSourceUnit()`
  `protected boolean`
  `resolve(ClassNode type)`
  `protected boolean`
  `resolve(ClassNode type, boolean testModuleImports, boolean testDefaultImports, boolean testStaticInnerClasses)`
  `protected boolean`
  `resolveFromCompileUnit(ClassNode type)`
  `protected boolean`
  `resolveFromDefaultImports(ClassNode type)`
  `protected boolean`
  `resolveFromDefaultImports(ClassNode type, String[] packagePrefixes)`
  `protected boolean`
  `resolveFromModule(ClassNode type, boolean testModuleImports)`
  `protected boolean`
  `resolveFromStaticInnerClasses(ClassNode type)`
  `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)`
  `Expression`
  `transform(Expression exp)`
  NOTE: This method does not visit Expressions within Closures, for performance and historical reasons.
  `protected Expression`
  `transformAnnotationConstantExpression(AnnotationConstantExpression ace)`
  `protected Expression`
  `transformBinaryExpression(BinaryExpression be)`
  `protected Expression`
  `transformClosureExpression(ClosureExpression ce)`
  `protected Expression`
  `transformConstructorCallExpression(ConstructorCallExpression cce)`
  `protected Expression`
  `transformDeclarationExpression(DeclarationExpression de)`
  `protected Expression`
  `transformMethodCallExpression(MethodCallExpression mce)`
  `protected Expression`
  `transformPropertyExpression(PropertyExpression pe)`
  `protected Expression`
  `transformVariableExpression(VariableExpression ve)`
  `protected void`
  `visitAnnotation(AnnotationNode node)`
  `void`
  `visitBlockStatement(BlockStatement block)`
  `void`
  `visitCatchStatement(CatchStatement cs)`
  `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, visitClosureExpression, 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

  `afterSwitchCaseStatementsVisited, 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`

- ## Field Details

  - ### DEFAULT_IMPORTS

    public static final String[] DEFAULT_IMPORTS

  - ### EMPTY_STRING_ARRAY

    public static final String[] EMPTY_STRING_ARRAY

  - ### QUESTION_MARK

    public static final String QUESTION_MARK
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### ResolveVisitor

    public ResolveVisitor(CompilationUnit compilationUnit)

- ## Method Details

  - ### setClassNodeResolver

    public void setClassNodeResolver(ClassNodeResolver classNodeResolver)

  - ### startResolving

    public void startResolving(ClassNode node, SourceUnit source)

  - ### getSourceUnit

    protected SourceUnit getSourceUnit()
    Specified by:
      `getSourceUnit` in class `ClassCodeVisitorSupport`

  - ### visitField

    public void visitField(FieldNode node)
    Description copied from interface: `GroovyClassVisitor`
    Visit a FieldNode.
    Specified by:
      `visitField` in interface `GroovyClassVisitor`
    Overrides:
      `visitField` in class `ClassCodeExpressionTransformer`

  - ### visitProperty

    public void visitProperty(PropertyNode node)
    Description copied from interface: `GroovyClassVisitor`
    Visit a PropertyNode.
    Specified by:
      `visitProperty` in interface `GroovyClassVisitor`
    Overrides:
      `visitProperty` in class `ClassCodeExpressionTransformer`

  - ### visitConstructorOrMethod

    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
    Overrides:
      `visitConstructorOrMethod` in class `ClassCodeExpressionTransformer`

  - ### resolveToInner

    protected boolean resolveToInner(ClassNode type)

  - ### resolve

    protected boolean resolve(ClassNode type)

  - ### resolve

    protected boolean resolve(ClassNode type, boolean testModuleImports, boolean testDefaultImports, boolean testStaticInnerClasses)

  - ### resolveNestedClass

    protected boolean resolveNestedClass(ClassNode type)

  - ### resolveFromStaticInnerClasses

    protected boolean resolveFromStaticInnerClasses(ClassNode type)

  - ### resolveFromDefaultImports

    protected boolean resolveFromDefaultImports(ClassNode type)

  - ### resolveFromDefaultImports

    protected boolean resolveFromDefaultImports(ClassNode type, String[] packagePrefixes)

  - ### resolveFromCompileUnit

    protected boolean resolveFromCompileUnit(ClassNode type)

  - ### resolveFromModule

    protected boolean resolveFromModule(ClassNode type, boolean testModuleImports)

  - ### resolveToOuter

    protected boolean resolveToOuter(ClassNode type)

  - ### transform

    public Expression transform(Expression exp)
    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 interface `ExpressionTransformer`
    Overrides:
      `transform` in class `ClassCodeExpressionTransformer`

  - ### transformPropertyExpression

    protected Expression transformPropertyExpression(PropertyExpression pe)

  - ### transformVariableExpression

    protected Expression transformVariableExpression(VariableExpression ve)

  - ### transformBinaryExpression

    protected Expression transformBinaryExpression(BinaryExpression be)

  - ### transformClosureExpression

    protected Expression transformClosureExpression(ClosureExpression ce)

  - ### transformConstructorCallExpression

    protected Expression transformConstructorCallExpression(ConstructorCallExpression cce)

  - ### transformMethodCallExpression

    protected Expression transformMethodCallExpression(MethodCallExpression mce)

  - ### transformDeclarationExpression

    protected Expression transformDeclarationExpression(DeclarationExpression de)

  - ### transformAnnotationConstantExpression

    protected Expression transformAnnotationConstantExpression(AnnotationConstantExpression ace)

  - ### visitAnnotation

    protected void visitAnnotation(AnnotationNode node)
    Overrides:
      `visitAnnotation` in class `ClassCodeExpressionTransformer`

  - ### visitClass

    public void visitClass(ClassNode node)
    Description copied from interface: `GroovyClassVisitor`
    Visit a ClassNode.
    Specified by:
      `visitClass` in interface `GroovyClassVisitor`
    Overrides:
      `visitClass` in class `ClassCodeVisitorSupport`

  - ### visitCatchStatement

    public void visitCatchStatement(CatchStatement cs)
    Specified by:
      `visitCatchStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCatchStatement` in class `ClassCodeVisitorSupport`

  - ### visitForLoop

    public void visitForLoop(ForStatement forLoop)
    Specified by:
      `visitForLoop` in interface `GroovyCodeVisitor`
    Overrides:
      `visitForLoop` in class `ClassCodeExpressionTransformer`

  - ### visitBlockStatement

    public void visitBlockStatement(BlockStatement block)
    Specified by:
      `visitBlockStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBlockStatement` in class `ClassCodeVisitorSupport`