Class TreeAnnotator
- All Implemented Interfaces:
TreeVisitor<Void,
AnnotatedTypeMirror>
- Direct Known Subclasses:
AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator
,AliasingAnnotatedTypeFactory.AliasingTreeAnnotator
,ClassValAnnotatedTypeFactory.ClassValTreeAnnotator
,DependentTypesTreeAnnotator
,InitializationAnnotatedTypeFactory.CommitmentTreeAnnotator
,KeyForPropagationTreeAnnotator
,ListTreeAnnotator
,LiteralTreeAnnotator
,LockTreeAnnotator
,MethodValAnnotatedTypeFactory.MethodValTreeAnnotator
,NullnessAnnotatedTypeFactory.NullnessTreeAnnotator
,PropagationTreeAnnotator
,PropertyKeyAnnotatedTypeFactory.KeyLookupTreeAnnotator
,SameLenAnnotatedTypeFactory.SameLenTreeAnnotator
,UpperBoundAnnotatedTypeFactory.UpperBoundTreeAnnotator
TreeAnnotator
is an abstract SimpleTreeVisitor to be used with ListTreeAnnotator
.
A TreeAnnotator is mainly intended to change the type of an expression. If a TreeAnnotator changes the type of a variable declaration, that change will not generally be seen at uses of the variable, because uses of a variable tend to obtain the variable's type from an Element (which always exists) rather than from a Tree (which might or might not be available at the time of the variable's use).
This class does not visit component parts of the tree. By default, the visit methods all call
SimpleTreeVisitor.defaultAction(Tree, Object)
, which does nothing unless overridden. Therefore, subclass
implementations of methods do not need to call super()
unless they override SimpleTreeVisitor.defaultAction(Tree, Object)
.
-
Field Summary
Fields inherited from class com.sun.source.util.SimpleTreeVisitor
DEFAULT_VALUE
-
Constructor Summary
ModifierConstructorDescriptionprotected
TreeAnnotator
(AnnotatedTypeFactory atypeFactory) Create a new TreeAnnotator. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Output a message, if logging is on.visitBinary
(BinaryTree tree, AnnotatedTypeMirror mirror) When overriding this method, getAnnotatedType on the left and right operands should only be called when absolutely necessary.visitMethod
(MethodTree tree, AnnotatedTypeMirror p) This method is not called when checking a method invocation against its declaration.Methods inherited from class com.sun.source.util.SimpleTreeVisitor
defaultAction, visit, visit, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
-
Field Details
-
atypeFactory
The type factory.
-
-
Constructor Details
-
TreeAnnotator
Create a new TreeAnnotator.- Parameters:
atypeFactory
- the type factory
-
-
Method Details
-
log
Output a message, if logging is on.- Parameters:
format
- a format stringargs
- arguments to the format string
-
visitMethod
This method is not called when checking a method invocation against its declaration. So, instead of overriding this method, override TypeAnnotator.visitExecutable. TypeAnnotator.visitExecutable is called both when checking method declarations and method invocations.- Specified by:
visitMethod
in interfaceTreeVisitor<Void,
AnnotatedTypeMirror> - Overrides:
visitMethod
in classSimpleTreeVisitor<Void,
AnnotatedTypeMirror> - See Also:
-
visitBinary
When overriding this method, getAnnotatedType on the left and right operands should only be called when absolutely necessary. Otherwise, the checker will be very slow on heavily nested binary trees. (For example, a + b + c + d + e + f + g + h.)If a checker's performance is still too slow, the types of binary trees could be computed in a subclass of
CFTransfer
. When computing the types in a transfer, look up the value in the store rather than the AnnotatedTypeFactory. Then this method should annotate binary trees with top so that the type applied in the transfer is always a subtype of the type the AnnotatedTypeFactory computes.- Specified by:
visitBinary
in interfaceTreeVisitor<Void,
AnnotatedTypeMirror> - Overrides:
visitBinary
in classSimpleTreeVisitor<Void,
AnnotatedTypeMirror>
-