Package: org.codehaus.groovy.tools.gse

## [Java] Class DependencyTracker

- org.codehaus.groovy.tools.gse.DependencyTracker

-     public class DependencyTracker
      extends ClassCodeVisitorSupport

  Tracks type dependencies referenced from a source unit and stores them in a StringSetMap.

- - ### Constructor Summary

    Constructors
    Constructor and 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.

  - ### Methods Summary

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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ClassCodeVisitorSupport` | `addError, getSourceUnit, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`
    `class CodeVisitorSupport` | `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCastExpression, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop`

- - ### Constructor Detail

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

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

    - #### protected SourceUnit getSourceUnit()

      Returns the source unit whose dependencies are being tracked.

      Returns:
        the current source unit

    - #### public void visitAnnotations(AnnotatedNode node)

      Records the types of annotations attached to the supplied node.

      Parameters:
        `node` - the annotated node being visited

    - #### public void visitArrayExpression(ArrayExpression expression)

      Records the array type referenced by an array expression.

      Parameters:
        `expression` - the array expression being visited

    - #### public void visitCastExpression(CastExpression expression)

      Records the target type referenced by a cast expression.

      Parameters:
        `expression` - the cast expression being visited

    - #### public void visitCatchStatement(CatchStatement statement)

      Records the exception-variable type referenced by a catch statement.

      Parameters:
        `statement` - the catch statement being visited

    - #### public void visitClass(ClassNode node)

      Visits a class and records its direct type dependencies.

      Parameters:
        `node` - the class being visited

    - #### public void visitClassExpression(ClassExpression expression)

      Records the type referenced by a class literal expression.

      Parameters:
        `expression` - the class expression being visited

    - #### public void visitConstructorCallExpression(ConstructorCallExpression call)

      Records the constructed type referenced by a constructor call.

      Parameters:
        `call` - the constructor call expression being visited

    - #### public void visitField(FieldNode node)

      Records the declared type of a visited field.

      Parameters:
        `node` - the field being visited

    - #### public void visitMethod(MethodNode node)

      Records parameter, return, and exception types referenced by a method.

      Parameters:
        `node` - the method being visited

    - #### public void visitVariableExpression(VariableExpression expression)

      Records the type referenced by a variable expression.

      Parameters:
        `expression` - the variable expression being visited