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.annotateImplicit(javax.lang.model.element.Element, org.checkerframework.framework.type.AnnotatedTypeMirror)
and AnnotatedTypeFactory.annotateImplicit(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 |
atypeFactoryDEFAULT_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.
|
visitMethodvisit, visit, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, 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, visitWildcardprotected 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 theQualtheQual - the AnnotationMirror that should be applied to the treeClasspublic void addLiteralKind(LiteralKind literalKind, AnnotationMirror theQual)
LiteralKindliteralKind - LiteralKind that should be implicited to theQualtheQual - the AnnotationMirror that should be applied to the literalKindpublic void addTreeKind(Tree.Kind treeKind, AnnotationMirror theQual)
Tree.KindtreeKind - Tree.Kind that should be implicited to theQualtheQual - the AnnotationMirror that should be applied to the treeKindpublic 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>