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
FieldsFields inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator
atypeFactoryFields inherited from class com.sun.source.util.SimpleTreeVisitor
DEFAULT_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionLiteralTreeAnnotator(AnnotatedTypeFactory atypeFactory) Creates aLiteralTreeAnnotatorfor the givenatypeFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLiteralKind(LiteralKind literalKind, AnnotationMirror theQual) Added a rule for a particularLiteralKindAdds standard qualifiers for literals.voidaddStringPattern(String regex, AnnotationMirror theQual) Added a rule for all String literals that match the given pattern.voidaddStringPattern(Pattern 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, visitMethodMethods inherited from class com.sun.source.util.SimpleTreeVisitor
visit, visit, visitAnnotatedType, visitAnnotation, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitMemberReference, visitMemberSelect, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitStringTemplate, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
-
Field Details
-
qualHierarchy
The qualifier hierarchy.
-
-
Constructor Details
-
LiteralTreeAnnotator
Creates aLiteralTreeAnnotatorfor 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-LiteralKindthat should be defaulted totheQualtheQual- theAnnotationMirrorthat should be applied to theliteralKind
-
addStringPattern
Added a rule for all String literals that match the given pattern.- Parameters:
regex- regex to match Strings againsttheQual-AnnotationMirrorto apply to Strings that match the regex- See Also:
-
addStringPattern
Added a rule for all String literals that match the given pattern.- Parameters:
pattern- pattern to match Strings againsttheQual-AnnotationMirrorto apply to Strings that match the pattern- See Also:
-
defaultAction
- Overrides:
defaultActionin classSimpleTreeVisitor<Void,AnnotatedTypeMirror>
-
visitLiteral
Go through the string patterns and add the greatest lower bound of all matching patterns.- Specified by:
visitLiteralin interfaceTreeVisitor<Void,AnnotatedTypeMirror> - Overrides:
visitLiteralin classSimpleTreeVisitor<Void,AnnotatedTypeMirror>
-