public class TreeAnnotator extends SimpleTreeVisitor<Void,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 atypeFactory)
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(String pattern,
AnnotationMirror theQual) |
void |
addTreeClass(Class<? extends Tree> treeClass,
AnnotationMirror theQual) |
void |
addTreeKind(Tree.Kind treeKind,
AnnotationMirror theQual) |
Void |
defaultAction(Tree tree,
AnnotatedTypeMirror type) |
Void |
visitBinary(BinaryTree node,
AnnotatedTypeMirror type) |
Void |
visitCompoundAssignment(CompoundAssignmentTree node,
AnnotatedTypeMirror type) |
Void |
visitLiteral(LiteralTree tree,
AnnotatedTypeMirror type)
Go through the string patterns and add the greatest lower bound of all matching patterns.
|
Void |
visitNewArray(NewArrayTree tree,
AnnotatedTypeMirror type) |
Void |
visitTypeCast(TypeCastTree node,
AnnotatedTypeMirror type) |
Void |
visitUnary(UnaryTree node,
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, visitIntersectionType, 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 atypeFactory)
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 Tree> treeClass, AnnotationMirror theQual)
public void addTreeKind(Tree.Kind treeKind, AnnotationMirror theQual)
public void addStringPattern(String pattern, AnnotationMirror theQual)
public Void defaultAction(Tree tree, AnnotatedTypeMirror type)
defaultAction
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>
public Void visitLiteral(LiteralTree tree, AnnotatedTypeMirror type)
visitLiteral
in interface TreeVisitor<Void,AnnotatedTypeMirror>
visitLiteral
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>
public Void visitNewArray(NewArrayTree tree, AnnotatedTypeMirror type)
visitNewArray
in interface TreeVisitor<Void,AnnotatedTypeMirror>
visitNewArray
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>
public Void visitCompoundAssignment(CompoundAssignmentTree node, AnnotatedTypeMirror type)
visitCompoundAssignment
in interface TreeVisitor<Void,AnnotatedTypeMirror>
visitCompoundAssignment
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>
public Void visitBinary(BinaryTree node, AnnotatedTypeMirror type)
visitBinary
in interface TreeVisitor<Void,AnnotatedTypeMirror>
visitBinary
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>
public Void visitUnary(UnaryTree node, AnnotatedTypeMirror type)
visitUnary
in interface TreeVisitor<Void,AnnotatedTypeMirror>
visitUnary
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>
public Void visitTypeCast(TypeCastTree node, AnnotatedTypeMirror type)
visitTypeCast
in interface TreeVisitor<Void,AnnotatedTypeMirror>
visitTypeCast
in class SimpleTreeVisitor<Void,AnnotatedTypeMirror>