Class SourceVisitor<R,P>

java.lang.Object
com.sun.source.util.TreeScanner<R,P>
com.sun.source.util.TreePathScanner<R,P>
org.checkerframework.framework.source.SourceVisitor<R,P>
All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<R,P>
Direct Known Subclasses:
BaseTypeVisitor

public abstract class SourceVisitor<R,P> extends com.sun.source.util.TreePathScanner<R,P>
An AST visitor that provides a variety of compiler utilities and interfaces to facilitate type-checking.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Elements
    The Elements helper to use when scanning.
    protected com.sun.source.tree.CompilationUnitTree
    The root of the AST that this SourceVisitor will scan.
    protected final com.sun.source.util.Trees
    The Trees instance to use for scanning.
    final List<com.sun.source.tree.Tree>
    The trees that are annotated with @SuppressWarnings.
    protected final Types
    The Types helper to use when scanning.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a SourceVisitor to use for scanning a source tree.
  • Method Summary

    Modifier and Type
    Method
    Description
    scan(com.sun.source.tree.Tree tree, P p)
     
    void
    setRoot(com.sun.source.tree.CompilationUnitTree root)
    Set the CompilationUnitTree to be used during any visits.
    void
    visit(com.sun.source.util.TreePath path)
    Entry point for a type processor: the TreePath leaf is a top-level type tree within root.
    visitClass(com.sun.source.tree.ClassTree classTree, P p)
     
    visitMethod(com.sun.source.tree.MethodTree node, P p)
     
    visitVariable(com.sun.source.tree.VariableTree variableTree, P p)
     

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

    getCurrentPath, scan

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

    reduce, scan, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, 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, visitWhileLoop, visitWildcard, visitYield

    Methods inherited from class java.lang.Object

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

    • trees

      protected final com.sun.source.util.Trees trees
      The Trees instance to use for scanning.
    • elements

      protected final Elements elements
      The Elements helper to use when scanning.
    • types

      protected final Types types
      The Types helper to use when scanning.
    • root

      protected com.sun.source.tree.CompilationUnitTree root
      The root of the AST that this SourceVisitor will scan.

      Is set by setRoot(com.sun.source.tree.CompilationUnitTree).

    • treesWithSuppressWarnings

      public final List<com.sun.source.tree.Tree> treesWithSuppressWarnings
      The trees that are annotated with @SuppressWarnings.
  • Constructor Details

    • SourceVisitor

      protected SourceVisitor(SourceChecker checker)
      Creates a SourceVisitor to use for scanning a source tree.
      Parameters:
      checker - the checker to invoke on the input source tree
  • Method Details

    • setRoot

      public void setRoot(com.sun.source.tree.CompilationUnitTree root)
      Set the CompilationUnitTree to be used during any visits. For any later calls of com.sun.source.util.TreePathScanner.scan(TreePath, P), the CompilationUnitTree of the TreePath has to be equal to root.
    • visit

      public void visit(com.sun.source.util.TreePath path)
      Entry point for a type processor: the TreePath leaf is a top-level type tree within root.
    • scan

      public R scan(com.sun.source.tree.Tree tree, P p)
      Overrides:
      scan in class com.sun.source.util.TreePathScanner<R,P>
    • visitClass

      public R visitClass(com.sun.source.tree.ClassTree classTree, P p)
      Specified by:
      visitClass in interface com.sun.source.tree.TreeVisitor<R,P>
      Overrides:
      visitClass in class com.sun.source.util.TreeScanner<R,P>
    • visitVariable

      public R visitVariable(com.sun.source.tree.VariableTree variableTree, P p)
      Specified by:
      visitVariable in interface com.sun.source.tree.TreeVisitor<R,P>
      Overrides:
      visitVariable in class com.sun.source.util.TreeScanner<R,P>
    • visitMethod

      public R visitMethod(com.sun.source.tree.MethodTree node, P p)
      Specified by:
      visitMethod in interface com.sun.source.tree.TreeVisitor<R,P>
      Overrides:
      visitMethod in class com.sun.source.util.TreeScanner<R,P>