Package org.codehaus.groovy.tools.gse

# Class DependencyTracker

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.tools.gse.DependencyTracker

All Implemented Interfaces:
  `GroovyClassVisitor`, `GroovyCodeVisitor`, `ErrorCollecting`

public class DependencyTracker extends ClassCodeVisitorSupport
Tracks type dependencies referenced from a source unit and stores them in a `StringSetMap`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DependencyTracker(SourceUnit source, StringSetMap cache)`
  Creates a dependency tracker for a source unit.
  `DependencyTracker(SourceUnit source, StringSetMap cache, Map<String,?> precompiledEntries)`
  Creates a dependency tracker for a source unit with an explicit set of precompiled dependency entries.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected SourceUnit`
  `getSourceUnit()`
  Returns the source unit whose dependencies are being tracked.
  `void`
  `visitAnnotations(AnnotatedNode node)`
  Records the types of annotations attached to the supplied node.
  `void`
  `visitArrayExpression(ArrayExpression expression)`
  Records the array type referenced by an array expression.
  `void`
  `visitCastExpression(CastExpression expression)`
  Records the target type referenced by a cast expression.
  `void`
  `visitCatchStatement(CatchStatement statement)`
  Records the exception-variable type referenced by a catch statement.
  `void`
  `visitClass(ClassNode node)`
  Visits a class and records its direct type dependencies.
  `void`
  `visitClassExpression(ClassExpression expression)`
  Records the type referenced by a class literal expression.
  `void`
  `visitConstructorCallExpression(ConstructorCallExpression call)`
  Records the constructed type referenced by a constructor call.
  `void`
  `visitField(FieldNode node)`
  Records the declared type of a visited field.
  `void`
  `visitMethod(MethodNode node)`
  Records parameter, return, and exception types referenced by a method.
  `void`
  `visitVariableExpression(VariableExpression expression)`
  Records the type referenced by a variable expression.

  ### Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport

  `addError, visitAnnotation, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitIfElse, visitImports, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitClosureListExpression, visitConstantExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression`

  ### 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

  - ### DependencyTracker

    public DependencyTracker(SourceUnit source, StringSetMap cache)
    Creates a dependency tracker for a source unit.
    Parameters:
      `source` - the source unit being analyzed
      `cache` - the dependency cache to populate

  - ### DependencyTracker

    public DependencyTracker(SourceUnit source, StringSetMap cache, Map<String,?> precompiledEntries)
    Creates a dependency tracker for a source unit with an explicit set of precompiled dependency entries.
    Parameters:
      `source` - the source unit being analyzed
      `cache` - the dependency cache to populate
      `precompiledEntries` - precompiled classes considered valid dependencies

- ## Method Details

  - ### visitClass

    public void visitClass(ClassNode node)
    Visits a class and records its direct type dependencies.
    Specified by:
      `visitClass` in interface `GroovyClassVisitor`
    Overrides:
      `visitClass` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the class being visited

  - ### getSourceUnit

    protected SourceUnit getSourceUnit()
    Returns the source unit whose dependencies are being tracked.
    Specified by:
      `getSourceUnit` in class `ClassCodeVisitorSupport`
    Returns:
      the current source unit

  - ### visitClassExpression

    public void visitClassExpression(ClassExpression expression)
    Records the type referenced by a class literal expression.
    Specified by:
      `visitClassExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClassExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the class expression being visited

  - ### visitField

    public void visitField(FieldNode node)
    Records the declared type of a visited field.
    Specified by:
      `visitField` in interface `GroovyClassVisitor`
    Overrides:
      `visitField` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the field being visited

  - ### visitMethod

    public void visitMethod(MethodNode node)
    Records parameter, return, and exception types referenced by a method.
    Specified by:
      `visitMethod` in interface `GroovyClassVisitor`
    Overrides:
      `visitMethod` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the method being visited

  - ### visitArrayExpression

    public void visitArrayExpression(ArrayExpression expression)
    Records the array type referenced by an array expression.
    Specified by:
      `visitArrayExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitArrayExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the array expression being visited

  - ### visitCastExpression

    public void visitCastExpression(CastExpression expression)
    Records the target type referenced by a cast expression.
    Specified by:
      `visitCastExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCastExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the cast expression being visited

  - ### visitVariableExpression

    public void visitVariableExpression(VariableExpression expression)
    Records the type referenced by a variable expression.
    Specified by:
      `visitVariableExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitVariableExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the variable expression being visited

  - ### visitCatchStatement

    public void visitCatchStatement(CatchStatement statement)
    Records the exception-variable type referenced by a catch statement.
    Specified by:
      `visitCatchStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCatchStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the catch statement being visited

  - ### visitAnnotations

    public void visitAnnotations(AnnotatedNode node)
    Records the types of annotations attached to the supplied node.
    Overrides:
      `visitAnnotations` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the annotated node being visited

  - ### visitConstructorCallExpression

    public void visitConstructorCallExpression(ConstructorCallExpression call)
    Records the constructed type referenced by a constructor call.
    Specified by:
      `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitConstructorCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the constructor call expression being visited