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:
com.sun.source.tree.TreeVisitor<Void,AnnotatedTypeMirror>

public class LiteralTreeAnnotator extends TreeAnnotator
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
    Modifier and Type
    Field
    Description
    protected final QualifierHierarchy
     

    Fields inherited from class org.checkerframework.framework.type.treeannotator.TreeAnnotator

    atypeFactory

    Fields inherited from class com.sun.source.util.SimpleTreeVisitor

    DEFAULT_VALUE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a LiteralTreeAnnotator for the given atypeFactory.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Added a rule for a particular LiteralKind
    Adds standard qualifiers for literals.
    void
    Added a rule for all String literals that match the given pattern.
    defaultAction(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type)
     
    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

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • LiteralTreeAnnotator

      public LiteralTreeAnnotator(AnnotatedTypeFactory atypeFactory)
      Creates a LiteralTreeAnnotator for the given atypeFactory.
      Parameters:
      atypeFactory - the type factory to make an annotator for
  • Method Details

    • 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, see DefaultForTypeAnnotator.addStandardDefaults().
      Returns:
      this
    • addLiteralKind

      public void addLiteralKind(LiteralKind literalKind, AnnotationMirror theQual)
      Added a rule for a particular LiteralKind
      Parameters:
      literalKind - LiteralKind that should be defaulted to theQual
      theQual - the AnnotationMirror that should be applied to the literalKind
    • addStringPattern

      public void addStringPattern(String pattern, AnnotationMirror theQual)
      Added a rule for all String literals that match the given pattern.
      Parameters:
      pattern - pattern to match Strings against
      theQual - AnnotationMirror to apply to Strings that match the pattern
    • defaultAction

      public Void defaultAction(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type)
      Overrides:
      defaultAction in class com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>
    • visitLiteral

      public 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 interface com.sun.source.tree.TreeVisitor<Void,AnnotatedTypeMirror>
      Overrides:
      visitLiteral in class com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>