public class ImplicitsTreeAnnotator extends TreeAnnotator
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.addComputedTypeAnnotations(javax.lang.model.element.Element,
org.checkerframework.framework.type.AnnotatedTypeMirror)
and AnnotatedTypeFactory.addComputedTypeAnnotations(com.sun.source.tree.Tree,
org.checkerframework.framework.type.AnnotatedTypeMirror)
.
ImplicitsTreeAnnotator
does not traverse trees deeply by default.
This class takes care of three of the attributes of ImplicitFor
; the others are handled in ImplicitsTypeAnnotator
. TODO: we currently
don't check that any attribute is set, that is, a qualifier could be annotated as @ImplicitFor(),
which might be misleading.
ImplicitsTypeAnnotator
,
TreeAnnotator
Modifier and Type | Field and Description |
---|---|
protected QualifierHierarchy |
qualHierarchy |
atypeFactory
DEFAULT_VALUE
Constructor and Description |
---|
ImplicitsTreeAnnotator(AnnotatedTypeFactory atypeFactory)
Creates a
ImplicitsTypeAnnotator
from the given checker, using that checker to determine the annotations that are in the type
hierarchy. |
Modifier and Type | Method and Description |
---|---|
void |
addLiteralKind(LiteralKind literalKind,
AnnotationMirror theQual)
Added an implicit rule for a particular
LiteralKind |
void |
addStringPattern(String pattern,
AnnotationMirror theQual)
Added an implicit rule for all String literals that match the given pattern
|
void |
addTreeClass(Class<? extends Tree> treeClass,
AnnotationMirror theQual)
Added an implicit rule for a particular
Tree class |
void |
addTreeKind(Tree.Kind treeKind,
AnnotationMirror theQual)
Added an implicit rule for a particular
Tree.Kind |
Void |
defaultAction(Tree tree,
AnnotatedTypeMirror type) |
Void |
visitLiteral(LiteralTree tree,
AnnotatedTypeMirror type)
Go through the string patterns and add the greatest lower bound of all matching patterns.
|
visitBinary, visitMethod
visit, visit, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitMemberReference, visitMemberSelect, visitMethodInvocation, visitModifiers, visitNewArray, visitNewClass, visitOther, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitVariable, visitWhileLoop, visitWildcard
protected final QualifierHierarchy qualHierarchy
public ImplicitsTreeAnnotator(AnnotatedTypeFactory atypeFactory)
ImplicitsTypeAnnotator
from the given checker, using that checker to determine the annotations that are in the type
hierarchy.public void addTreeClass(Class<? extends Tree> treeClass, AnnotationMirror theQual)
Tree
classtreeClass
- tree class that should be implicited to theQual
theQual
- the AnnotationMirror
that should be applied to the treeClass
public void addLiteralKind(LiteralKind literalKind, AnnotationMirror theQual)
LiteralKind
literalKind
- LiteralKind
that should be implicited to theQual
theQual
- the AnnotationMirror
that should be applied to the literalKind
public void addTreeKind(Tree.Kind treeKind, AnnotationMirror theQual)
Tree.Kind
treeKind
- Tree.Kind
that should be implicited to theQual
theQual
- the AnnotationMirror
that should be applied to the treeKind
public void addStringPattern(String pattern, AnnotationMirror theQual)
pattern
- pattern to match Strings againsttheQual
- AnnotationMirror
to apply to Strings that match the patternpublic 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>