java.lang.Object
com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>
org.checkerframework.framework.type.treeannotator.TreeAnnotator
All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<Void,AnnotatedTypeMirror>
Direct Known Subclasses:
AccumulationAnnotatedTypeFactory.AccumulationTreeAnnotator, AliasingAnnotatedTypeFactory.AliasingTreeAnnotator, ClassValAnnotatedTypeFactory.ClassValTreeAnnotator, DependentTypesTreeAnnotator, InitializationAnnotatedTypeFactory.CommitmentTreeAnnotator, KeyForPropagationTreeAnnotator, ListTreeAnnotator, LiteralTreeAnnotator, LockTreeAnnotator, MethodValAnnotatedTypeFactory.MethodValTreeAnnotator, NullnessAnnotatedTypeFactory.NullnessTreeAnnotator, PropagationTreeAnnotator, PropertyKeyAnnotatedTypeFactory.KeyLookupTreeAnnotator, SameLenAnnotatedTypeFactory.SameLenTreeAnnotator, UpperBoundAnnotatedTypeFactory.UpperBoundTreeAnnotator

public abstract class TreeAnnotator extends com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>
TreeAnnotator is an abstract SimpleTreeVisitor to be used with ListTreeAnnotator.

This class does not visit component parts of the tree. By default, the visit methods all call SimpleTreeVisitor.defaultAction(Tree, Object), which does nothing unless overridden. Therefore, subclass do not need to call super unless they override SimpleTreeVisitor.defaultAction(Tree, Object).

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final AnnotatedTypeFactory
    The type factory.

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

    DEFAULT_VALUE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Create a new TreeAnnotator.
  • Method Summary

    Modifier and Type
    Method
    Description
    visitBinary(com.sun.source.tree.BinaryTree node, AnnotatedTypeMirror mirror)
    When overriding this method, getAnnotatedType on the left and right operands should only be called when absolutely necessary.
    visitMethod(com.sun.source.tree.MethodTree node, AnnotatedTypeMirror p)
    This method is not called when checking a method invocation against its declaration.

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

    defaultAction, 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, visitLiteral, 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

    • TreeAnnotator

      protected TreeAnnotator(AnnotatedTypeFactory atypeFactory)
      Create a new TreeAnnotator.
      Parameters:
      atypeFactory - the type factory
  • Method Details

    • visitMethod

      public Void visitMethod(com.sun.source.tree.MethodTree node, AnnotatedTypeMirror p)
      This method is not called when checking a method invocation against its declaration. So, instead of overriding this method, override TypeAnnotator.visitExecutable. TypeAnnotator.visitExecutable is called both when checking method declarations and method invocations.
      Specified by:
      visitMethod in interface com.sun.source.tree.TreeVisitor<Void,AnnotatedTypeMirror>
      Overrides:
      visitMethod in class com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>
      See Also:
    • visitBinary

      public Void visitBinary(com.sun.source.tree.BinaryTree node, AnnotatedTypeMirror mirror)
      When overriding this method, getAnnotatedType on the left and right operands should only be called when absolutely necessary. Otherwise, the checker will be very slow on heavily nested binary trees. (For example, a + b + c + d + e + f + g + h.)

      If a checker's performance is still too slow, the types of binary trees could be computed in a subclass of CFTransfer. When computing the types in a transfer, look up the value in the store rather than the AnnotatedTypeFactory. Then this method should annotate binary trees with top so that the type applied in the transfer is always a subtype of the type the AnnotatedTypeFactory computes.

      Specified by:
      visitBinary in interface com.sun.source.tree.TreeVisitor<Void,AnnotatedTypeMirror>
      Overrides:
      visitBinary in class com.sun.source.util.SimpleTreeVisitor<Void,AnnotatedTypeMirror>