public class TreeAnnotator extends SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
ImplicitFor
annotation and applies implicit
annotations specified by ImplicitFor
for any tree whose visitor is
not overridden or does not call super
; it is designed to be invoked
from
AnnotatedTypeFactory.annotateImplicit(Element, AnnotatedTypeMirror)
and AnnotatedTypeFactory.annotateImplicit(Tree, AnnotatedTypeMirror)
.
TreeAnnotator
does not traverse trees deeply by default.
This class takes care of three of the attributes of ImplicitFor
;
the others are handled in TypeAnnotator
.
TODO: we currently don't check that any attribute is set, that is, a qualifier
could be annotated as @ImplicitFor(), which might be misleading.
TypeAnnotator
DEFAULT_VALUE
Constructor and Description |
---|
TreeAnnotator(BaseTypeChecker checker,
AnnotatedTypeFactory typeFactory)
Creates a
TypeAnnotator from the given checker, using that checker's
TypeQualifiers annotation to determine the annotations that are
in the type hierarchy. |
Modifier and Type | Method and Description |
---|---|
void |
addStringPattern(@ReadOnly String pattern,
@Nullable AnnotationMirror theQual) |
void |
addTreeClass(Class<? extends @Nullable Tree> treeClass,
@Nullable AnnotationMirror theQual) |
void |
addTreeKind(Tree.Kind treeKind,
@Nullable AnnotationMirror theQual) |
@Nullable Void |
defaultAction(@Nullable Tree tree,
@Mutable AnnotatedTypeMirror type) |
@Nullable Void |
visitBinary(BinaryTree node,
@Mutable AnnotatedTypeMirror type) |
@Nullable Void |
visitCompoundAssignment(CompoundAssignmentTree node,
@Mutable AnnotatedTypeMirror type) |
@Nullable Void |
visitLiteral(LiteralTree tree,
@Mutable AnnotatedTypeMirror type)
Go through the string patterns and add the greatest lower bound of all matching patterns.
|
@Nullable Void |
visitNewArray(NewArrayTree tree,
@Mutable AnnotatedTypeMirror type) |
@Nullable Void |
visitTypeCast(TypeCastTree node,
@Mutable AnnotatedTypeMirror type) |
@Nullable Void |
visitUnary(UnaryTree node,
@Mutable AnnotatedTypeMirror type) |
visit, visit, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitLabeledStatement, visitLambdaExpression, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitNewClass, visitOther, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeParameter, visitUnionType, visitVariable, visitWhileLoop, visitWildcard
public TreeAnnotator(BaseTypeChecker checker, AnnotatedTypeFactory typeFactory)
TypeAnnotator
from the given checker, using that checker's
TypeQualifiers
annotation to determine the annotations that are
in the type hierarchy.checker
- the type checker to which this annotator belongspublic void addTreeClass(Class<? extends @Nullable Tree> treeClass, @Nullable AnnotationMirror theQual)
public void addTreeKind(Tree.Kind treeKind, @Nullable AnnotationMirror theQual)
public void addStringPattern(@ReadOnly String pattern, @Nullable AnnotationMirror theQual)
public @Nullable Void defaultAction(@Nullable Tree tree, @Mutable AnnotatedTypeMirror type)
defaultAction
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
public @Nullable Void visitLiteral(LiteralTree tree, @Mutable AnnotatedTypeMirror type)
visitLiteral
in interface TreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
visitLiteral
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
public @Nullable Void visitNewArray(NewArrayTree tree, @Mutable AnnotatedTypeMirror type)
visitNewArray
in interface TreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
visitNewArray
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
public @Nullable Void visitCompoundAssignment(CompoundAssignmentTree node, @Mutable AnnotatedTypeMirror type)
visitCompoundAssignment
in interface TreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
visitCompoundAssignment
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
public @Nullable Void visitBinary(BinaryTree node, @Mutable AnnotatedTypeMirror type)
visitBinary
in interface TreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
visitBinary
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
public @Nullable Void visitUnary(UnaryTree node, @Mutable AnnotatedTypeMirror type)
visitUnary
in interface TreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
visitUnary
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
public @Nullable Void visitTypeCast(TypeCastTree node, @Mutable AnnotatedTypeMirror type)
visitTypeCast
in interface TreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>
visitTypeCast
in class SimpleTreeVisitor<@Nullable Void,@Mutable AnnotatedTypeMirror>