Class LiteralTreeAnnotator
- java.lang.Object
-
- com.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
-
- org.checkerframework.framework.type.treeannotator.TreeAnnotator
-
- org.checkerframework.framework.type.treeannotator.LiteralTreeAnnotator
-
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
public class LiteralTreeAnnotator extends TreeAnnotator
Adds annotations to a type based on the contents of a tree. This class applies annotations specified byQualifierForLiterals
; it is designed to be added to aListTreeAnnotator
viaGenericAnnotatedTypeFactory.createTreeAnnotator()
LiteralTreeAnnotator
does not traverse trees deeply.- See Also:
TreeAnnotator
-
-
Field Summary
Fields Modifier and Type Field Description protected QualifierHierarchy
qualHierarchy
The qualifier hierarchy.-
Fields inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator
atypeFactory
-
-
Constructor Summary
Constructors Constructor Description LiteralTreeAnnotator(AnnotatedTypeFactory atypeFactory)
Creates aLiteralTreeAnnotator
for the givenatypeFactory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLiteralKind(LiteralKind literalKind, javax.lang.model.element.AnnotationMirror theQual)
Added a rule for a particularLiteralKind
LiteralTreeAnnotator
addStandardLiteralQualifiers()
Adds standard qualifiers for literals.void
addStringPattern(java.lang.String pattern, javax.lang.model.element.AnnotationMirror theQual)
Added a rule for all String literals that match the given pattern.java.lang.Void
defaultAction(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type)
java.lang.Void
visitLiteral(com.sun.source.tree.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, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, 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, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard
-
-
-
-
Field Detail
-
qualHierarchy
protected final QualifierHierarchy qualHierarchy
The qualifier hierarchy.
-
-
Constructor Detail
-
LiteralTreeAnnotator
public LiteralTreeAnnotator(AnnotatedTypeFactory atypeFactory)
Creates aLiteralTreeAnnotator
for the givenatypeFactory
.- Parameters:
atypeFactory
- the type factory to make an annotator for
-
-
Method Detail
-
addStandardLiteralQualifiers
public LiteralTreeAnnotator 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
public void addLiteralKind(LiteralKind literalKind, javax.lang.model.element.AnnotationMirror theQual)
Added a rule for a particularLiteralKind
- Parameters:
literalKind
-LiteralKind
that should be defaulted totheQual
theQual
- theAnnotationMirror
that should be applied to theliteralKind
-
addStringPattern
public void addStringPattern(java.lang.String pattern, javax.lang.model.element.AnnotationMirror theQual)
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
public java.lang.Void defaultAction(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type)
- Overrides:
defaultAction
in classcom.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
-
visitLiteral
public java.lang.Void visitLiteral(com.sun.source.tree.LiteralTree tree, AnnotatedTypeMirror type)
Go through the string patterns and add the greatest lower bound of all matching patterns.- Specified by:
visitLiteral
in interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,AnnotatedTypeMirror>
- Overrides:
visitLiteral
in classcom.sun.source.util.SimpleTreeVisitor<java.lang.Void,AnnotatedTypeMirror>
-
-