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
Tracks type dependencies referenced from a source unit and stores them in a
StringSetMap.-
Constructor Summary
ConstructorsConstructorDescriptionDependencyTracker(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 TypeMethodDescriptionprotected SourceUnitReturns the source unit whose dependencies are being tracked.voidRecords the types of annotations attached to the supplied node.voidvisitArrayExpression(ArrayExpression expression) Records the array type referenced by an array expression.voidvisitCastExpression(CastExpression expression) Records the target type referenced by a cast expression.voidvisitCatchStatement(CatchStatement statement) Records the exception-variable type referenced by a catch statement.voidvisitClass(ClassNode node) Visits a class and records its direct type dependencies.voidvisitClassExpression(ClassExpression expression) Records the type referenced by a class literal expression.voidRecords the constructed type referenced by a constructor call.voidvisitField(FieldNode node) Records the declared type of a visited field.voidvisitMethod(MethodNode node) Records parameter, return, and exception types referenced by a method.voidvisitVariableExpression(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, visitWhileLoopMethods 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, visitUnaryPlusExpressionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor
visit, visit, visitEmptyExpression, visitListOfExpressions
-
Constructor Details
-
DependencyTracker
Creates a dependency tracker for a source unit.- Parameters:
source- the source unit being analyzedcache- the dependency cache to populate
-
DependencyTracker
Creates a dependency tracker for a source unit with an explicit set of precompiled dependency entries.- Parameters:
source- the source unit being analyzedcache- the dependency cache to populateprecompiledEntries- precompiled classes considered valid dependencies
-
-
Method Details
-
visitClass
Visits a class and records its direct type dependencies.- Specified by:
visitClassin interfaceGroovyClassVisitor- Overrides:
visitClassin classClassCodeVisitorSupport- Parameters:
node- the class being visited
-
getSourceUnit
Returns the source unit whose dependencies are being tracked.- Specified by:
getSourceUnitin classClassCodeVisitorSupport- Returns:
- the current source unit
-
visitClassExpression
Records the type referenced by a class literal expression.- Specified by:
visitClassExpressionin interfaceGroovyCodeVisitor- Overrides:
visitClassExpressionin classCodeVisitorSupport- Parameters:
expression- the class expression being visited
-
visitField
Records the declared type of a visited field.- Specified by:
visitFieldin interfaceGroovyClassVisitor- Overrides:
visitFieldin classClassCodeVisitorSupport- Parameters:
node- the field being visited
-
visitMethod
Records parameter, return, and exception types referenced by a method.- Specified by:
visitMethodin interfaceGroovyClassVisitor- Overrides:
visitMethodin classClassCodeVisitorSupport- Parameters:
node- the method being visited
-
visitArrayExpression
Records the array type referenced by an array expression.- Specified by:
visitArrayExpressionin interfaceGroovyCodeVisitor- Overrides:
visitArrayExpressionin classCodeVisitorSupport- Parameters:
expression- the array expression being visited
-
visitCastExpression
Records the target type referenced by a cast expression.- Specified by:
visitCastExpressionin interfaceGroovyCodeVisitor- Overrides:
visitCastExpressionin classCodeVisitorSupport- Parameters:
expression- the cast expression being visited
-
visitVariableExpression
Records the type referenced by a variable expression.- Specified by:
visitVariableExpressionin interfaceGroovyCodeVisitor- Overrides:
visitVariableExpressionin classCodeVisitorSupport- Parameters:
expression- the variable expression being visited
-
visitCatchStatement
Records the exception-variable type referenced by a catch statement.- Specified by:
visitCatchStatementin interfaceGroovyCodeVisitor- Overrides:
visitCatchStatementin classClassCodeVisitorSupport- Parameters:
statement- the catch statement being visited
-
visitAnnotations
Records the types of annotations attached to the supplied node.- Overrides:
visitAnnotationsin classClassCodeVisitorSupport- Parameters:
node- the annotated node being visited
-
visitConstructorCallExpression
Records the constructed type referenced by a constructor call.- Specified by:
visitConstructorCallExpressionin interfaceGroovyCodeVisitor- Overrides:
visitConstructorCallExpressionin classCodeVisitorSupport- Parameters:
call- the constructor call expression being visited
-