Class CFGTranslationPhaseOne

java.lang.Object
com.sun.source.util.TreeScanner<Node,Void>
org.checkerframework.dataflow.cfg.builder.CFGTranslationPhaseOne
All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<Node,Void>
Direct Known Subclasses:
CFCFGBuilder.CFCFGTranslationPhaseOne

public class CFGTranslationPhaseOne extends com.sun.source.util.TreeScanner<Node,Void>
Class that performs phase one of the translation process. It generates the following information:
  • A sequence of extended nodes.
  • A set of bindings from Labels to positions in the node sequence.
  • A set of leader nodes that give rise to basic blocks in phase two.
  • A mapping from AST tree nodes to Nodes.

The return type of this scanner is Node. For expressions, the corresponding node is returned to allow linking between different nodes.

However, for statements there is usually no single Node that is created, and thus no node is returned (rather, null is returned).

Every visit* method is assumed to add at least one extended node to the list of nodes (which might only be a jump).

The entry point to process a single body (e.g., method) is process(TreePath, UnderlyingAST).

  • Field Details

    • elements

      protected final Elements elements
      The javac element utilities.
    • treeBuilder

      public final TreeBuilder treeBuilder
      The tree builder.
    • uid

      protected long uid
      The UID for the next unique name.
    • ea

      protected com.sun.source.tree.VariableTree ea
      The VariableTree that indicates whether assertions are enabled or not.
  • Constructor Details

    • CFGTranslationPhaseOne

      public CFGTranslationPhaseOne(TreeBuilder treeBuilder, AnnotationProvider annotationProvider, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, ProcessingEnvironment env)
      Parameters:
      treeBuilder - builder for new AST nodes
      annotationProvider - extracts annotations from AST nodes
      assumeAssertionsDisabled - can assertions be assumed to be disabled?
      assumeAssertionsEnabled - can assertions be assumed to be enabled?
      env - annotation processing environment containing type utilities
  • Method Details

    • process

      public PhaseOneResult process(com.sun.source.util.TreePath bodyPath, UnderlyingAST underlyingAST)
      Performs the actual work of phase one: processing a single body (of a method, lambda, top-level block, etc.).
      Parameters:
      bodyPath - path to the body of the underlying AST's method
      underlyingAST - the AST for which the CFG is to be built
      Returns:
      the result of phase one
    • process

      public PhaseOneResult process(com.sun.source.tree.CompilationUnitTree root, UnderlyingAST underlyingAST)
      Process a single body within root. This method does not process the entire given CompilationUnitTree. Rather, it processes one body (of a method/lambda/etc.) within it, which corresponds to underlyingAST.
      Parameters:
      root - the compilation unit
      underlyingAST - the AST corresponding to the body to process
      Returns:
      a PhaseOneResult
    • handleArtificialTree

      public void handleArtificialTree(com.sun.source.tree.Tree tree)
      Perform any actions required when CFG translation creates a new Tree that is not part of the original AST.
      Parameters:
      tree - the newly created Tree
    • getProcessingEnvironment

      protected ProcessingEnvironment getProcessingEnvironment()
      Allow subclasses to access the processing environment and its associated utilities.
      Returns:
      the ProcessingEnvironment associated with this object
    • getCurrentPath

      public com.sun.source.util.TreePath getCurrentPath()
      Returns the current path for the tree currently being scanned.
      Returns:
      the current path
    • scan

      public Node scan(com.sun.source.tree.Tree tree, Void p)
      Overrides:
      scan in class com.sun.source.util.TreeScanner<Node,Void>
    • visitYield17

      public Node visitYield17(com.sun.source.tree.Tree yieldTree, Void p)
      Visit a SwitchExpressionTree.
      Parameters:
      yieldTree - a YieldTree, typed as Tree to be backward-compatible
      p - parameter
      Returns:
      the result of visiting the switch expression tree
    • visitSwitchExpression17

      public Node visitSwitchExpression17(com.sun.source.tree.Tree switchExpressionTree, Void p)
      Visit a SwitchExpressionTree
      Parameters:
      switchExpressionTree - a SwitchExpressionTree, typed as Tree to be backward-compatible
      p - parameter
      Returns:
      the result of visiting the switch expression tree
    • visitBindingPattern17

      public Node visitBindingPattern17(com.sun.source.tree.Tree bindingPatternTree, Void p)
      Visit a BindingPatternTree
      Parameters:
      bindingPatternTree - a BindingPatternTree, typed as Tree to be backward-compatible
      p - parameter
      Returns:
      the result of visiting the binding pattern tree
    • addToLookupMap

      protected void addToLookupMap(Node node)
      Add a node to the lookup map if it not already present.
      Parameters:
      node - the node to add to the lookup map
    • addToConvertedLookupMap

      protected void addToConvertedLookupMap(Node node)
      Add a node in the post-conversion lookup map. The node should refer to a Tree and that Tree should already be in the pre-conversion lookup map. This method is used to update the Tree-Node mapping with conversion nodes.
      Parameters:
      node - the node to add to the lookup map
    • addToConvertedLookupMap

      protected void addToConvertedLookupMap(com.sun.source.tree.Tree tree, Node node)
      Add a node in the post-conversion lookup map. The tree argument should already be in the pre-conversion lookup map. This method is used to update the Tree-Node mapping with conversion nodes.
      Parameters:
      tree - the tree used as a key in the map
      node - the node to add to the lookup map
    • extendWithNode

      protected void extendWithNode(Node node)
      Extend the list of extended nodes with a node.
      Parameters:
      node - the node to add
    • extendWithNodeWithException

      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithNodeWithException(Node node, TypeMirror cause)
      Extend the list of extended nodes with a node, where node might throw the exception cause.
      Parameters:
      node - the node to add
      cause - an exception that the node might throw
      Returns:
      the node holder
    • extendWithNodeWithExceptions

      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithNodeWithExceptions(Node node, Set<TypeMirror> causes)
      Extend the list of extended nodes with a node, where node might throw any of the exceptions in causes.
      Parameters:
      node - the node to add
      causes - set of exceptions that the node might throw
      Returns:
      the node holder
    • extendWithClassNameNode

      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithClassNameNode(ClassNameNode node)
      Extend a list of extended nodes with a ClassName node.

      Evaluating a class literal kicks off class loading (JLS 15.8.2) which can fail and throw one of the specified subclasses of a LinkageError or an OutOfMemoryError (JLS 12.2.1).

      Parameters:
      node - the ClassName node to add
      Returns:
      the node holder
    • insertNodeAfter

      protected <T extends Node> T insertNodeAfter(T node, Node pred)
      Insert node after pred in the list of extended nodes, or append to the list if pred is not present.
      Parameters:
      node - the node to add
      pred - the desired predecessor of node
      Returns:
      the node holder
    • insertNodeWithExceptionsAfter

      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder insertNodeWithExceptionsAfter(Node node, Set<TypeMirror> causes, Node pred)
      Insert a node that might throw the exceptions in causes after pred in the list of extended nodes, or append to the list if pred is not present.
      Parameters:
      node - the node to add
      causes - set of exceptions that the node might throw
      pred - the desired predecessor of node
      Returns:
      the node holder
    • extendWithExtendedNode

      protected void extendWithExtendedNode(ExtendedNode n)
      Extend the list of extended nodes with an extended node.
      Parameters:
      n - the extended node
    • insertExtendedNodeAfter

      protected void insertExtendedNodeAfter(ExtendedNode n, @FindDistinct Node pred)
      Insert n after the node pred in the list of extended nodes, or append n if pred is not present.
      Parameters:
      n - the extended node
      pred - the desired predecessor
    • addLabelForNextNode

      protected void addLabelForNextNode(Label l)
      Add the label l to the extended node that will be placed next in the sequence.
      Parameters:
      l - the node to add to the forthcoming extended node
    • uniqueName

      protected String uniqueName(String prefix)
      Returns a unique name starting with prefix.
      Parameters:
      prefix - the prefix of the unique name
      Returns:
      a unique name starting with prefix
    • box

      protected Node box(Node node)
      If the input node is an unboxed primitive type, insert a call to the appropriate valueOf method, otherwise leave it alone.
      Parameters:
      node - in input node
      Returns:
      a Node representing the boxed version of the input, which may simply be the input node
    • unbox

      protected Node unbox(Node node)
      If the input node is a boxed type, unbox it, otherwise leave it alone.
      Parameters:
      node - in input node
      Returns:
      a Node representing the unboxed version of the input, which may simply be the input node
    • stringConversion

      protected Node stringConversion(Node node)
      Convert the input node to String type, if it isn't already.
      Parameters:
      node - an input node
      Returns:
      a Node with the value promoted to String, which may be the input node
    • unaryNumericPromotion

      protected Node unaryNumericPromotion(Node node)
      Perform unary numeric promotion on the input node.
      Parameters:
      node - a node producing a value of numeric primitive or boxed type
      Returns:
      a Node with the value promoted to the int, long, float, or double; may return be the input node
    • isNumericOrBoxed

      protected boolean isNumericOrBoxed(TypeMirror type)
      Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise.
    • binaryPromotedType

      protected TypeMirror binaryPromotedType(TypeMirror left, TypeMirror right)
      Compute the type to which two numeric types must be promoted before performing a binary numeric operation on them. The input types must both be numeric and the output type is primitive.
      Parameters:
      left - the type of the left operand
      right - the type of the right operand
      Returns:
      a TypeMirror representing the binary numeric promoted type
    • binaryNumericPromotion

      protected Node binaryNumericPromotion(Node node, TypeMirror exprType)
      Perform binary numeric promotion on the input node to make it match the expression type.
      Parameters:
      node - a node producing a value of numeric primitive or boxed type
      exprType - the type to promote the value to
      Returns:
      a Node with the value promoted to the exprType, which may be the input node
    • widen

      protected Node widen(Node node, TypeMirror destType)
      Perform widening primitive conversion on the input node to make it match the destination type.
      Parameters:
      node - a node producing a value of numeric primitive type
      destType - the type to widen the value to
      Returns:
      a Node with the value widened to the exprType, which may be the input node
    • narrow

      protected Node narrow(Node node, TypeMirror destType)
      Perform narrowing conversion on the input node to make it match the destination type.
      Parameters:
      node - a node producing a value of numeric primitive type
      destType - the type to narrow the value to
      Returns:
      a Node with the value narrowed to the exprType, which may be the input node
    • narrowAndBox

      protected Node narrowAndBox(Node node, TypeMirror destType)
      Perform narrowing conversion and optionally boxing conversion on the input node to make it match the destination type.
      Parameters:
      node - a node producing a value of numeric primitive type
      destType - the type to narrow the value to (possibly boxed)
      Returns:
      a Node with the value narrowed and boxed to the destType, which may be the input node
    • conversionRequiresNarrowing

      protected boolean conversionRequiresNarrowing(TypeMirror varType, Node node)
      Return whether a conversion from the type of the node to varType requires narrowing.
      Parameters:
      varType - the type of a variable (or general LHS) to be converted to
      node - a node whose value is being converted
      Returns:
      whether this conversion requires narrowing to succeed
    • commonConvert

      protected Node commonConvert(Node node, TypeMirror varType, boolean contextAllowsNarrowing)
      Assignment conversion and method invocation conversion are almost identical, except that assignment conversion allows narrowing. We factor out the common logic here.
      Parameters:
      node - a Node producing a value
      varType - the type of a variable
      contextAllowsNarrowing - whether to allow narrowing (for assignment conversion) or not (for method invocation conversion)
      Returns:
      a Node with the value converted to the type of the variable, which may be the input node itself
    • assignConvert

      protected Node assignConvert(Node node, TypeMirror varType)
      Perform assignment conversion so that it can be assigned to a variable of the given type.
      Parameters:
      node - a Node producing a value
      varType - the type of a variable
      Returns:
      a Node with the value converted to the type of the variable, which may be the input node itself
    • methodInvocationConvert

      protected Node methodInvocationConvert(Node node, TypeMirror formalType)
      Perform method invocation conversion so that the node can be passed as a formal parameter of the given type.
      Parameters:
      node - a Node producing a value
      formalType - the type of a formal parameter
      Returns:
      a Node with the value converted to the type of the formal, which may be the input node itself
    • convertCallArguments

      protected List<Node> convertCallArguments(ExecutableElement method, List<? extends com.sun.source.tree.ExpressionTree> actualExprs)
      Given a method element and as list of argument expressions, return a list of Nodes representing the arguments converted for a call of the method. This method applies to both method invocations and constructor calls.
      Parameters:
      method - an ExecutableElement representing a method to be called
      actualExprs - a List of argument expressions to a call
      Returns:
      a List of Nodes representing arguments after conversions required by a call to this method
    • conditionalExprPromotion

      protected Node conditionalExprPromotion(Node node, TypeMirror destType)
      Convert an operand of a conditional expression to the type of the whole expression.
      Parameters:
      node - a node occurring as the second or third operand of a conditional expression
      destType - the type to promote the value to
      Returns:
      a Node with the value promoted to the destType, which may be the input node
    • getLabel

      protected @Nullable Name getLabel(com.sun.source.util.TreePath path)
      Returns the label Name of the leaf in the argument path, or null if the leaf is not a labeled statement.
    • visitAnnotatedType

      public Node visitAnnotatedType(com.sun.source.tree.AnnotatedTypeTree tree, Void p)
      Specified by:
      visitAnnotatedType in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitAnnotatedType in class com.sun.source.util.TreeScanner<Node,Void>
    • visitAnnotation

      public Node visitAnnotation(com.sun.source.tree.AnnotationTree tree, Void p)
      Specified by:
      visitAnnotation in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitAnnotation in class com.sun.source.util.TreeScanner<Node,Void>
    • visitMethodInvocation

      public MethodInvocationNode visitMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, Void p)
      Specified by:
      visitMethodInvocation in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitMethodInvocation in class com.sun.source.util.TreeScanner<Node,Void>
    • visitAssert

      public Node visitAssert(com.sun.source.tree.AssertTree tree, Void p)
      Specified by:
      visitAssert in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitAssert in class com.sun.source.util.TreeScanner<Node,Void>
    • assumeAssertionsEnabledFor

      protected boolean assumeAssertionsEnabledFor(com.sun.source.tree.AssertTree tree)
      Should assertions be assumed to be executed for a given AssertTree? False by default.
    • getAssertionsEnabledVariable

      protected com.sun.source.tree.VariableTree getAssertionsEnabledVariable()
      Get a synthetic VariableTree that indicates whether assertions are enabled or not.
    • translateAssertWithAssertionsEnabled

      protected void translateAssertWithAssertionsEnabled(com.sun.source.tree.AssertTree tree)
      Translates an assertion statement to the correct CFG nodes. The translation assumes that assertions are enabled.
    • visitAssignment

      public Node visitAssignment(com.sun.source.tree.AssignmentTree tree, Void p)
      Specified by:
      visitAssignment in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitAssignment in class com.sun.source.util.TreeScanner<Node,Void>
    • translateAssignment

      protected AssignmentNode translateAssignment(com.sun.source.tree.Tree tree, Node target, com.sun.source.tree.ExpressionTree rhs)
      Translate an assignment.
    • translateAssignment

      protected AssignmentNode translateAssignment(com.sun.source.tree.Tree tree, Node target, Node expression)
      Translate an assignment where the RHS has already been scanned.
    • withoutAssignment

      protected com.sun.source.tree.Tree.Kind withoutAssignment(com.sun.source.tree.Tree.Kind kind)
      Map an operation with assignment to the corresponding operation without assignment.
      Parameters:
      kind - a Tree.Kind representing an operation with assignment
      Returns:
      the Tree.Kind for the same operation without assignment
    • visitCompoundAssignment

      public Node visitCompoundAssignment(com.sun.source.tree.CompoundAssignmentTree tree, Void p)
      Specified by:
      visitCompoundAssignment in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitCompoundAssignment in class com.sun.source.util.TreeScanner<Node,Void>
    • visitBinary

      public Node visitBinary(com.sun.source.tree.BinaryTree tree, Void p)
      Specified by:
      visitBinary in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitBinary in class com.sun.source.util.TreeScanner<Node,Void>
    • visitBlock

      public Node visitBlock(com.sun.source.tree.BlockTree tree, Void p)
      Specified by:
      visitBlock in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitBlock in class com.sun.source.util.TreeScanner<Node,Void>
    • visitBreak

      public Node visitBreak(com.sun.source.tree.BreakTree tree, Void p)
      Specified by:
      visitBreak in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitBreak in class com.sun.source.util.TreeScanner<Node,Void>
    • visitSwitch

      public Node visitSwitch(com.sun.source.tree.SwitchTree tree, Void p)
      Specified by:
      visitSwitch in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitSwitch in class com.sun.source.util.TreeScanner<Node,Void>
    • visitCase

      public Node visitCase(com.sun.source.tree.CaseTree tree, Void p)
      Specified by:
      visitCase in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitCase in class com.sun.source.util.TreeScanner<Node,Void>
    • visitCatch

      public Node visitCatch(com.sun.source.tree.CatchTree tree, Void p)
      Specified by:
      visitCatch in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitCatch in class com.sun.source.util.TreeScanner<Node,Void>
    • visitClass

      public Node visitClass(com.sun.source.tree.ClassTree tree, Void p)
      Specified by:
      visitClass in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitClass in class com.sun.source.util.TreeScanner<Node,Void>
    • visitConditionalExpression

      public Node visitConditionalExpression(com.sun.source.tree.ConditionalExpressionTree tree, Void p)
      Specified by:
      visitConditionalExpression in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitConditionalExpression in class com.sun.source.util.TreeScanner<Node,Void>
    • visitContinue

      public Node visitContinue(com.sun.source.tree.ContinueTree tree, Void p)
      Specified by:
      visitContinue in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitContinue in class com.sun.source.util.TreeScanner<Node,Void>
    • visitDoWhileLoop

      public Node visitDoWhileLoop(com.sun.source.tree.DoWhileLoopTree tree, Void p)
      Specified by:
      visitDoWhileLoop in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitDoWhileLoop in class com.sun.source.util.TreeScanner<Node,Void>
    • visitErroneous

      public Node visitErroneous(com.sun.source.tree.ErroneousTree tree, Void p)
      Specified by:
      visitErroneous in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitErroneous in class com.sun.source.util.TreeScanner<Node,Void>
    • visitExpressionStatement

      public Node visitExpressionStatement(com.sun.source.tree.ExpressionStatementTree tree, Void p)
      Specified by:
      visitExpressionStatement in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitExpressionStatement in class com.sun.source.util.TreeScanner<Node,Void>
    • visitEnhancedForLoop

      public Node visitEnhancedForLoop(com.sun.source.tree.EnhancedForLoopTree tree, Void p)
      Specified by:
      visitEnhancedForLoop in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitEnhancedForLoop in class com.sun.source.util.TreeScanner<Node,Void>
    • createEnhancedForLoopIteratorVariable

      protected com.sun.source.tree.VariableTree createEnhancedForLoopIteratorVariable(com.sun.source.tree.MethodInvocationTree iteratorCall, VariableElement variableElement)
    • createEnhancedForLoopArrayVariable

      protected com.sun.source.tree.VariableTree createEnhancedForLoopArrayVariable(com.sun.source.tree.ExpressionTree expression, VariableElement variableElement)
    • visitForLoop

      public Node visitForLoop(com.sun.source.tree.ForLoopTree tree, Void p)
      Specified by:
      visitForLoop in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitForLoop in class com.sun.source.util.TreeScanner<Node,Void>
    • visitIdentifier

      public Node visitIdentifier(com.sun.source.tree.IdentifierTree tree, Void p)
      Specified by:
      visitIdentifier in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitIdentifier in class com.sun.source.util.TreeScanner<Node,Void>
    • visitIf

      public Node visitIf(com.sun.source.tree.IfTree tree, Void p)
      Specified by:
      visitIf in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitIf in class com.sun.source.util.TreeScanner<Node,Void>
    • visitImport

      public Node visitImport(com.sun.source.tree.ImportTree tree, Void p)
      Specified by:
      visitImport in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitImport in class com.sun.source.util.TreeScanner<Node,Void>
    • visitArrayAccess

      public Node visitArrayAccess(com.sun.source.tree.ArrayAccessTree tree, Void p)
      Specified by:
      visitArrayAccess in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitArrayAccess in class com.sun.source.util.TreeScanner<Node,Void>
    • visitLabeledStatement

      public Node visitLabeledStatement(com.sun.source.tree.LabeledStatementTree tree, Void p)
      Specified by:
      visitLabeledStatement in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitLabeledStatement in class com.sun.source.util.TreeScanner<Node,Void>
    • visitLiteral

      public Node visitLiteral(com.sun.source.tree.LiteralTree tree, Void p)
      Specified by:
      visitLiteral in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitLiteral in class com.sun.source.util.TreeScanner<Node,Void>
    • visitMethod

      public Node visitMethod(com.sun.source.tree.MethodTree tree, Void p)
      Specified by:
      visitMethod in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitMethod in class com.sun.source.util.TreeScanner<Node,Void>
    • visitModifiers

      public Node visitModifiers(com.sun.source.tree.ModifiersTree tree, Void p)
      Specified by:
      visitModifiers in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitModifiers in class com.sun.source.util.TreeScanner<Node,Void>
    • visitNewArray

      public Node visitNewArray(com.sun.source.tree.NewArrayTree tree, Void p)
      Specified by:
      visitNewArray in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitNewArray in class com.sun.source.util.TreeScanner<Node,Void>
    • visitNewClass

      public Node visitNewClass(com.sun.source.tree.NewClassTree tree, Void p)
      Specified by:
      visitNewClass in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitNewClass in class com.sun.source.util.TreeScanner<Node,Void>
    • visitParenthesized

      public Node visitParenthesized(com.sun.source.tree.ParenthesizedTree tree, Void p)
      Specified by:
      visitParenthesized in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitParenthesized in class com.sun.source.util.TreeScanner<Node,Void>
    • visitReturn

      public Node visitReturn(com.sun.source.tree.ReturnTree tree, Void p)
      Specified by:
      visitReturn in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitReturn in class com.sun.source.util.TreeScanner<Node,Void>
    • visitMemberSelect

      public Node visitMemberSelect(com.sun.source.tree.MemberSelectTree tree, Void p)
      Specified by:
      visitMemberSelect in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitMemberSelect in class com.sun.source.util.TreeScanner<Node,Void>
    • visitEmptyStatement

      public Node visitEmptyStatement(com.sun.source.tree.EmptyStatementTree tree, Void p)
      Specified by:
      visitEmptyStatement in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitEmptyStatement in class com.sun.source.util.TreeScanner<Node,Void>
    • visitSynchronized

      public Node visitSynchronized(com.sun.source.tree.SynchronizedTree tree, Void p)
      Specified by:
      visitSynchronized in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitSynchronized in class com.sun.source.util.TreeScanner<Node,Void>
    • visitThrow

      public Node visitThrow(com.sun.source.tree.ThrowTree tree, Void p)
      Specified by:
      visitThrow in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitThrow in class com.sun.source.util.TreeScanner<Node,Void>
    • visitCompilationUnit

      public Node visitCompilationUnit(com.sun.source.tree.CompilationUnitTree tree, Void p)
      Specified by:
      visitCompilationUnit in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitCompilationUnit in class com.sun.source.util.TreeScanner<Node,Void>
    • visitTry

      public Node visitTry(com.sun.source.tree.TryTree tree, Void p)
      Specified by:
      visitTry in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitTry in class com.sun.source.util.TreeScanner<Node,Void>
    • visitParameterizedType

      public Node visitParameterizedType(com.sun.source.tree.ParameterizedTypeTree tree, Void p)
      Specified by:
      visitParameterizedType in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitParameterizedType in class com.sun.source.util.TreeScanner<Node,Void>
    • visitUnionType

      public Node visitUnionType(com.sun.source.tree.UnionTypeTree tree, Void p)
      Specified by:
      visitUnionType in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitUnionType in class com.sun.source.util.TreeScanner<Node,Void>
    • visitArrayType

      public Node visitArrayType(com.sun.source.tree.ArrayTypeTree tree, Void p)
      Specified by:
      visitArrayType in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitArrayType in class com.sun.source.util.TreeScanner<Node,Void>
    • visitTypeCast

      public Node visitTypeCast(com.sun.source.tree.TypeCastTree tree, Void p)
      Specified by:
      visitTypeCast in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitTypeCast in class com.sun.source.util.TreeScanner<Node,Void>
    • visitPrimitiveType

      public Node visitPrimitiveType(com.sun.source.tree.PrimitiveTypeTree tree, Void p)
      Specified by:
      visitPrimitiveType in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitPrimitiveType in class com.sun.source.util.TreeScanner<Node,Void>
    • visitTypeParameter

      public Node visitTypeParameter(com.sun.source.tree.TypeParameterTree tree, Void p)
      Specified by:
      visitTypeParameter in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitTypeParameter in class com.sun.source.util.TreeScanner<Node,Void>
    • visitInstanceOf

      public Node visitInstanceOf(com.sun.source.tree.InstanceOfTree tree, Void p)
      Specified by:
      visitInstanceOf in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitInstanceOf in class com.sun.source.util.TreeScanner<Node,Void>
    • visitUnary

      public Node visitUnary(com.sun.source.tree.UnaryTree tree, Void p)
      Specified by:
      visitUnary in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitUnary in class com.sun.source.util.TreeScanner<Node,Void>
    • visitVariable

      public Node visitVariable(com.sun.source.tree.VariableTree tree, Void p)
      Specified by:
      visitVariable in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitVariable in class com.sun.source.util.TreeScanner<Node,Void>
    • visitWhileLoop

      public Node visitWhileLoop(com.sun.source.tree.WhileLoopTree tree, Void p)
      Specified by:
      visitWhileLoop in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitWhileLoop in class com.sun.source.util.TreeScanner<Node,Void>
    • visitLambdaExpression

      public Node visitLambdaExpression(com.sun.source.tree.LambdaExpressionTree tree, Void p)
      Specified by:
      visitLambdaExpression in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitLambdaExpression in class com.sun.source.util.TreeScanner<Node,Void>
    • visitMemberReference

      public Node visitMemberReference(com.sun.source.tree.MemberReferenceTree tree, Void p)
      Specified by:
      visitMemberReference in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitMemberReference in class com.sun.source.util.TreeScanner<Node,Void>
    • visitWildcard

      public Node visitWildcard(com.sun.source.tree.WildcardTree tree, Void p)
      Specified by:
      visitWildcard in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitWildcard in class com.sun.source.util.TreeScanner<Node,Void>
    • visitOther

      public Node visitOther(com.sun.source.tree.Tree tree, Void p)
      Specified by:
      visitOther in interface com.sun.source.tree.TreeVisitor<Node,Void>
      Overrides:
      visitOther in class com.sun.source.util.TreeScanner<Node,Void>
    • getTypeMirror

      protected TypeMirror getTypeMirror(Class<?> clazz)
      Returns the TypeMirror for the given class.
      Parameters:
      clazz - a class
      Returns:
      the TypeMirror for the class
    • maybeGetTypeMirror

      protected @Nullable TypeMirror maybeGetTypeMirror(Class<?> clazz)
      Returns the TypeMirror for the given class, or null if the type is not present.

      This can be used to handle system types that are not present. For example, in Java code that is translated to JavaScript using j2cl, the custom bootclasspath contains APIs that are emulated in JavaScript, so some types such as OutOfMemoryError are deliberately not present.

      Parameters:
      clazz - a class, which must have a canonical name
      Returns:
      the TypeMirror for the class, or null if the type is not present