Class LiteralTreeAnnotator
java.lang.Object
com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>
org.checkerframework.framework.type.treeannotator.TreeAnnotator
org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator
- All Implemented Interfaces:
TreeVisitor<Void,
AnnotatedTypeMirror>
Adds annotations to a type based on the contents of a tree. This class applies annotations
specified by
QualifierForLiterals
; it is designed to
be added to a ListTreeAnnotator
via GenericAnnotatedTypeFactory.createTreeAnnotator()
LiteralTreeAnnotator
does not traverse trees deeply.
- See Also:
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator
atypeFactory
Fields inherited from class com.sun.source.util.SimpleTreeVisitor
DEFAULT_VALUE
-
Constructor Summary
ConstructorDescriptionLiteralTreeAnnotator
(AnnotatedTypeFactory atypeFactory) Creates aLiteralTreeAnnotator
for the givenatypeFactory
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLiteralKind
(LiteralKind literalKind, AnnotationMirror theQual) Added a rule for a particularLiteralKind
Adds standard qualifiers for literals.void
addStringPattern
(String pattern, AnnotationMirror theQual) Added a rule for all String literals that match the given pattern.defaultAction
(Tree tree, AnnotatedTypeMirror type) visitLiteral
(LiteralTree tree, AnnotatedTypeMirror type) Go through the string patterns and add the greatest lower bound of all matching patterns.Methods inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator
log, visitBinary, visitMethod
Methods inherited from class com.sun.source.util.SimpleTreeVisitor
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, 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
-
qualHierarchy
The qualifier hierarchy.
-
-
Constructor Details
-
LiteralTreeAnnotator
Creates aLiteralTreeAnnotator
for the givenatypeFactory
.- Parameters:
atypeFactory
- the type factory to make an annotator for
-
-
Method Details
-
addStandardLiteralQualifiers
Adds standard qualifiers for literals. Currently sets the null literal to bottom if no other default is set for null literals. Also, seeDefaultForTypeAnnotator.addStandardDefaults()
.- Returns:
- this
-
addLiteralKind
Added a rule for a particularLiteralKind
- Parameters:
literalKind
-LiteralKind
that should be defaulted totheQual
theQual
- theAnnotationMirror
that should be applied to theliteralKind
-
addStringPattern
Added a rule for all String literals that match the given pattern.- Parameters:
pattern
- pattern to match Strings againsttheQual
-AnnotationMirror
to apply to Strings that match the pattern
-
defaultAction
- Overrides:
defaultAction
in classSimpleTreeVisitor<Void,
AnnotatedTypeMirror>
-
visitLiteral
Go through the string patterns and add the greatest lower bound of all matching patterns.- Specified by:
visitLiteral
in interfaceTreeVisitor<Void,
AnnotatedTypeMirror> - Overrides:
visitLiteral
in classSimpleTreeVisitor<Void,
AnnotatedTypeMirror>
-