Class CFGTranslationPhaseOne

  • All Implemented Interfaces:
    com.sun.source.tree.TreeVisitor<Node,​java.lang.Void>
    Direct Known Subclasses:
    CFCFGBuilder.CFCFGTranslationPhaseOne

    public class CFGTranslationPhaseOne
    extends com.sun.source.util.TreeScanner<Node,​java.lang.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).

    • Constructor Summary

      Constructors 
      Constructor Description
      CFGTranslationPhaseOne​(TreeBuilder treeBuilder, AnnotationProvider annotationProvider, boolean assumeAssertionsEnabled, boolean assumeAssertionsDisabled, javax.annotation.processing.ProcessingEnvironment env)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addLabelForNextNode​(Label l)
      Add the label l to the extended node that will be placed next in the sequence.
      protected void addToConvertedLookupMap​(com.sun.source.tree.Tree tree, Node node)
      Add a node in the post-conversion lookup map.
      protected void addToConvertedLookupMap​(Node node)
      Add a node in the post-conversion lookup map.
      protected void addToLookupMap​(Node node)
      Add a node to the lookup map if it not already present.
      protected Node assignConvert​(Node node, javax.lang.model.type.TypeMirror varType)
      Perform assignment conversion so that it can be assigned to a variable of the given type.
      protected boolean assumeAssertionsEnabledFor​(com.sun.source.tree.AssertTree tree)
      Should assertions be assumed to be executed for a given AssertTree? False by default.
      protected Node binaryNumericPromotion​(Node node, javax.lang.model.type.TypeMirror exprType)
      Perform binary numeric promotion on the input node to make it match the expression type.
      protected javax.lang.model.type.TypeMirror binaryPromotedType​(javax.lang.model.type.TypeMirror left, javax.lang.model.type.TypeMirror right)
      Compute the type to which two numeric types must be promoted before performing a binary numeric operation on them.
      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.
      protected Node commonConvert​(Node node, javax.lang.model.type.TypeMirror varType, boolean contextAllowsNarrowing)
      Assignment conversion and method invocation conversion are almost identical, except that assignment conversion allows narrowing.
      protected Node conditionalExprPromotion​(Node node, javax.lang.model.type.TypeMirror destType)
      Convert an operand of a conditional expression to the type of the whole expression.
      protected boolean conversionRequiresNarrowing​(javax.lang.model.type.TypeMirror varType, Node node)
      Return whether a conversion from the type of the node to varType requires narrowing.
      protected java.util.List<Node> convertCallArguments​(javax.lang.model.element.ExecutableElement executable, javax.lang.model.type.ExecutableType executableType, java.util.List<? extends com.sun.source.tree.ExpressionTree> actualExprs, @Nullable com.sun.source.tree.NewClassTree newClassTree)
      Given a method element, its type at the call site, and a list of argument expressions, return a list of Nodes representing the arguments converted for a call of the method.
      protected com.sun.source.tree.VariableTree createEnhancedForLoopArrayVariable​(com.sun.source.tree.ExpressionTree expression, javax.lang.model.element.VariableElement variableElement)  
      protected com.sun.source.tree.VariableTree createEnhancedForLoopIteratorVariable​(com.sun.source.tree.MethodInvocationTree iteratorCall, javax.lang.model.element.VariableElement variableElement)  
      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithClassNameNode​(ClassNameNode node)
      Extend a list of extended nodes with a ClassName node.
      protected void extendWithExtendedNode​(ExtendedNode n)
      Extend the list of extended nodes with an extended node.
      protected void extendWithNode​(Node node)
      Extend the list of extended nodes with a node.
      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithNodeWithException​(Node node, javax.lang.model.type.TypeMirror cause)
      Extend the list of extended nodes with a node, where node might throw the exception cause.
      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder extendWithNodeWithExceptions​(Node node, java.util.Set<javax.lang.model.type.TypeMirror> causes)
      Extend the list of extended nodes with a node, where node might throw any of the exceptions in causes.
      protected com.sun.source.tree.VariableTree getAssertionsEnabledVariable()
      Get a synthetic VariableTree that indicates whether assertions are enabled or not.
      com.sun.source.util.TreePath getCurrentPath()
      Returns the current path for the tree currently being scanned.
      protected @Nullable javax.lang.model.element.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.
      protected javax.lang.model.type.TypeMirror getTypeMirror​(java.lang.Class<?> clazz)
      Returns the TypeMirror for the given class.
      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.
      protected void insertExtendedNodeAfter​(ExtendedNode n, Node pred)
      Insert n after the node pred in the list of extended nodes, or append n if pred is not present.
      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.
      protected org.checkerframework.dataflow.cfg.builder.NodeWithExceptionsHolder insertNodeWithExceptionsAfter​(Node node, java.util.Set<javax.lang.model.type.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.
      protected boolean isNumericOrBoxed​(javax.lang.model.type.TypeMirror type)
      Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise.
      protected @Nullable javax.lang.model.type.TypeMirror maybeGetTypeMirror​(java.lang.Class<?> clazz)
      Returns the TypeMirror for the given class, or null if the type is not present.
      protected Node methodInvocationConvert​(Node node, javax.lang.model.type.TypeMirror formalType)
      Perform method invocation conversion so that the node can be passed as a formal parameter of the given type.
      protected Node narrow​(Node node, javax.lang.model.type.TypeMirror destType)
      Perform narrowing conversion on the input node to make it match the destination type.
      protected Node narrowAndBox​(Node node, javax.lang.model.type.TypeMirror destType)
      Perform narrowing conversion and optionally boxing conversion on the input node to make it match the destination type.
      PhaseOneResult process​(com.sun.source.tree.CompilationUnitTree root, UnderlyingAST underlyingAST)
      Process a single body within root.
      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.).
      Node scan​(com.sun.source.tree.Tree tree, java.lang.Void p)  
      protected Node stringConversion​(Node node)
      Convert the input node to String type, if it isn't already.
      protected void translateAssertWithAssertionsEnabled​(com.sun.source.tree.AssertTree tree)
      Translates an assertion statement to the correct CFG nodes.
      protected AssignmentNode translateAssignment​(com.sun.source.tree.Tree tree, Node target, com.sun.source.tree.ExpressionTree rhs)
      Translate an assignment.
      protected AssignmentNode translateAssignment​(com.sun.source.tree.Tree tree, Node target, Node expression)
      Translate an assignment where the RHS has already been scanned.
      protected Node unaryNumericPromotion​(Node node)
      Perform unary numeric promotion on the input node.
      protected Node unbox​(Node node)
      If the input node is a boxed type, unbox it, otherwise leave it alone.
      protected java.lang.String uniqueName​(java.lang.String prefix)
      Returns a unique name starting with prefix.
      Node visitAnnotatedType​(com.sun.source.tree.AnnotatedTypeTree tree, java.lang.Void p)  
      Node visitAnnotation​(com.sun.source.tree.AnnotationTree tree, java.lang.Void p)  
      Node visitArrayAccess​(com.sun.source.tree.ArrayAccessTree tree, java.lang.Void p)  
      Node visitArrayType​(com.sun.source.tree.ArrayTypeTree tree, java.lang.Void p)  
      Node visitAssert​(com.sun.source.tree.AssertTree tree, java.lang.Void p)  
      Node visitAssignment​(com.sun.source.tree.AssignmentTree tree, java.lang.Void p)  
      Node visitBinary​(com.sun.source.tree.BinaryTree tree, java.lang.Void p)  
      Node visitBindingPattern17​(com.sun.source.tree.Tree bindingPatternTree, java.lang.Void p)
      Visit a BindingPatternTree
      Node visitBlock​(com.sun.source.tree.BlockTree tree, java.lang.Void p)  
      Node visitBreak​(com.sun.source.tree.BreakTree tree, java.lang.Void p)  
      Node visitCase​(com.sun.source.tree.CaseTree tree, java.lang.Void p)  
      Node visitCatch​(com.sun.source.tree.CatchTree tree, java.lang.Void p)  
      Node visitClass​(com.sun.source.tree.ClassTree tree, java.lang.Void p)  
      Node visitCompilationUnit​(com.sun.source.tree.CompilationUnitTree tree, java.lang.Void p)  
      Node visitCompoundAssignment​(com.sun.source.tree.CompoundAssignmentTree tree, java.lang.Void p)  
      Node visitConditionalExpression​(com.sun.source.tree.ConditionalExpressionTree tree, java.lang.Void p)  
      Node visitContinue​(com.sun.source.tree.ContinueTree tree, java.lang.Void p)  
      Node visitDeconstructionPattern21​(com.sun.source.tree.Tree deconstructionPatternTree, java.lang.Void p)
      Visit a DeconstructionPatternTree.
      Node visitDoWhileLoop​(com.sun.source.tree.DoWhileLoopTree tree, java.lang.Void p)  
      Node visitEmptyStatement​(com.sun.source.tree.EmptyStatementTree tree, java.lang.Void p)  
      Node visitEnhancedForLoop​(com.sun.source.tree.EnhancedForLoopTree tree, java.lang.Void p)  
      Node visitErroneous​(com.sun.source.tree.ErroneousTree tree, java.lang.Void p)  
      Node visitExpressionStatement​(com.sun.source.tree.ExpressionStatementTree tree, java.lang.Void p)  
      Node visitForLoop​(com.sun.source.tree.ForLoopTree tree, java.lang.Void p)  
      Node visitIdentifier​(com.sun.source.tree.IdentifierTree tree, java.lang.Void p)  
      Node visitIf​(com.sun.source.tree.IfTree tree, java.lang.Void p)  
      Node visitImport​(com.sun.source.tree.ImportTree tree, java.lang.Void p)  
      Node visitInstanceOf​(com.sun.source.tree.InstanceOfTree tree, java.lang.Void p)  
      Node visitLabeledStatement​(com.sun.source.tree.LabeledStatementTree tree, java.lang.Void p)  
      Node visitLambdaExpression​(com.sun.source.tree.LambdaExpressionTree tree, java.lang.Void p)  
      Node visitLiteral​(com.sun.source.tree.LiteralTree tree, java.lang.Void p)  
      Node visitMemberReference​(com.sun.source.tree.MemberReferenceTree tree, java.lang.Void p)  
      Node visitMemberSelect​(com.sun.source.tree.MemberSelectTree tree, java.lang.Void p)  
      Node visitMethod​(com.sun.source.tree.MethodTree tree, java.lang.Void p)  
      MethodInvocationNode visitMethodInvocation​(com.sun.source.tree.MethodInvocationTree tree, java.lang.Void p)  
      Node visitModifiers​(com.sun.source.tree.ModifiersTree tree, java.lang.Void p)  
      Node visitNewArray​(com.sun.source.tree.NewArrayTree tree, java.lang.Void p)  
      Node visitNewClass​(com.sun.source.tree.NewClassTree tree, java.lang.Void p)  
      Node visitOther​(com.sun.source.tree.Tree tree, java.lang.Void p)  
      Node visitParameterizedType​(com.sun.source.tree.ParameterizedTypeTree tree, java.lang.Void p)  
      Node visitParenthesized​(com.sun.source.tree.ParenthesizedTree tree, java.lang.Void p)  
      Node visitPrimitiveType​(com.sun.source.tree.PrimitiveTypeTree tree, java.lang.Void p)  
      Node visitReturn​(com.sun.source.tree.ReturnTree tree, java.lang.Void p)  
      Node visitSwitch​(com.sun.source.tree.SwitchTree tree, java.lang.Void p)  
      Node visitSwitchExpression17​(com.sun.source.tree.Tree switchExpressionTree, java.lang.Void p)
      Visit a SwitchExpressionTree
      Node visitSynchronized​(com.sun.source.tree.SynchronizedTree tree, java.lang.Void p)  
      Node visitThrow​(com.sun.source.tree.ThrowTree tree, java.lang.Void p)  
      Node visitTry​(com.sun.source.tree.TryTree tree, java.lang.Void p)  
      Node visitTypeCast​(com.sun.source.tree.TypeCastTree tree, java.lang.Void p)  
      Node visitTypeParameter​(com.sun.source.tree.TypeParameterTree tree, java.lang.Void p)  
      Node visitUnary​(com.sun.source.tree.UnaryTree tree, java.lang.Void p)  
      Node visitUnionType​(com.sun.source.tree.UnionTypeTree tree, java.lang.Void p)  
      Node visitVariable​(com.sun.source.tree.VariableTree tree, java.lang.Void p)  
      Node visitWhileLoop​(com.sun.source.tree.WhileLoopTree tree, java.lang.Void p)  
      Node visitWildcard​(com.sun.source.tree.WildcardTree tree, java.lang.Void p)  
      Node visitYield17​(com.sun.source.tree.Tree yieldTree, java.lang.Void p)
      Visit a SwitchExpressionTree.
      protected Node widen​(Node node, javax.lang.model.type.TypeMirror destType)
      Perform widening primitive conversion on the input node to make it match the destination type.
      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.
      • Methods inherited from class com.sun.source.util.TreeScanner

        reduce, scan, visitExports, visitIntersectionType, visitModule, visitOpens, visitPackage, visitProvides, visitRequires, visitUses
      • Methods inherited from class java.lang.Object

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

      • env

        protected final javax.annotation.processing.ProcessingEnvironment env
        Annotation processing environment.
      • elements

        protected final javax.lang.model.util.Elements elements
        Element utilities.
      • types

        protected final javax.lang.model.util.Types types
        Type utilities.
      • trees

        protected final com.sun.source.util.Trees trees
        Tree utilities.
      • treeBuilder

        protected final TreeBuilder treeBuilder
        TreeBuilder instance.
      • annotationProvider

        protected final AnnotationProvider annotationProvider
        The annotation provider, e.g., a type factory.
      • assumeAssertionsDisabled

        protected final boolean assumeAssertionsDisabled
        Can assertions be assumed to be disabled?
      • assumeAssertionsEnabled

        protected final boolean assumeAssertionsEnabled
        Can assertions be assumed to be enabled?
      • arithmeticExceptionType

        protected final javax.lang.model.type.TypeMirror arithmeticExceptionType
        The ArithmeticException type.
      • arrayIndexOutOfBoundsExceptionType

        protected final javax.lang.model.type.TypeMirror arrayIndexOutOfBoundsExceptionType
        The ArrayIndexOutOfBoundsException type.
      • assertionErrorType

        protected final javax.lang.model.type.TypeMirror assertionErrorType
        The AssertionError type.
      • classCastExceptionType

        protected final javax.lang.model.type.TypeMirror classCastExceptionType
        The ClassCastException type .
      • iterableType

        protected final javax.lang.model.type.TypeMirror iterableType
        The Iterable type (erased).
      • negativeArraySizeExceptionType

        protected final javax.lang.model.type.TypeMirror negativeArraySizeExceptionType
        The NegativeArraySizeException type.
      • nullPointerExceptionType

        protected final javax.lang.model.type.TypeMirror nullPointerExceptionType
        The NullPointerException type .
      • outOfMemoryErrorType

        protected final @Nullable javax.lang.model.type.TypeMirror outOfMemoryErrorType
        The OutOfMemoryError type.
      • classCircularityErrorType

        protected final @Nullable javax.lang.model.type.TypeMirror classCircularityErrorType
        The ClassCircularityError type.
      • classFormatErrorType

        protected final @Nullable javax.lang.model.type.TypeMirror classFormatErrorType
        The ClassFormatErrorType type.
      • noClassDefFoundErrorType

        protected final @Nullable javax.lang.model.type.TypeMirror noClassDefFoundErrorType
        The NoClassDefFoundError type.
      • stringType

        protected final javax.lang.model.type.TypeMirror stringType
        The String type.
      • throwableType

        protected final javax.lang.model.type.TypeMirror throwableType
        The Throwable type.
      • uncheckedExceptionTypes

        protected final java.util.Set<javax.lang.model.type.TypeMirror> uncheckedExceptionTypes
        Supertypes of all unchecked exceptions. The size is 2 and the contents are RuntimeException and Error.
      • newArrayExceptionTypes

        protected final java.util.Set<javax.lang.model.type.TypeMirror> newArrayExceptionTypes
        Exceptions that can be thrown by array creation "new SomeType[]". The size is 2 and the contents are NegativeArraySizeException and OutOfMemoryError. This list comes from JLS 15.10.1 "Run-Time Evaluation of Array Creation Expressions".
      • 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 Detail

      • CFGTranslationPhaseOne

        public CFGTranslationPhaseOne​(TreeBuilder treeBuilder,
                                      AnnotationProvider annotationProvider,
                                      boolean assumeAssertionsEnabled,
                                      boolean assumeAssertionsDisabled,
                                      javax.annotation.processing.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 Detail

      • 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
      • 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,
                         java.lang.Void p)
        Overrides:
        scan in class com.sun.source.util.TreeScanner<Node,​java.lang.Void>
      • visitYield17

        public Node visitYield17​(com.sun.source.tree.Tree yieldTree,
                                 java.lang.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,
                                            java.lang.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,
                                          java.lang.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
      • visitDeconstructionPattern21

        public Node visitDeconstructionPattern21​(com.sun.source.tree.Tree deconstructionPatternTree,
                                                 java.lang.Void p)
        Visit a DeconstructionPatternTree.
        Parameters:
        deconstructionPatternTree - a DeconstructionPatternTree, typed as Tree so the Checker Framework compiles under JDK 20 and earlier
        p - an unused parameter
        Returns:
        the result of visiting the 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,
                                                                                                                 javax.lang.model.type.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,
                                                                                                                  java.util.Set<javax.lang.model.type.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,
                                                                                                                   java.util.Set<javax.lang.model.type.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 java.lang.String uniqueName​(java.lang.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​(javax.lang.model.type.TypeMirror type)
        Returns true if the argument type is a numeric primitive or a boxed numeric primitive and false otherwise.
      • binaryPromotedType

        protected javax.lang.model.type.TypeMirror binaryPromotedType​(javax.lang.model.type.TypeMirror left,
                                                                      javax.lang.model.type.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,
                                              javax.lang.model.type.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,
                             javax.lang.model.type.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,
                              javax.lang.model.type.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,
                                    javax.lang.model.type.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​(javax.lang.model.type.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,
                                     javax.lang.model.type.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,
                                     javax.lang.model.type.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,
                                               javax.lang.model.type.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 java.util.List<Node> convertCallArguments​(javax.lang.model.element.ExecutableElement executable,
                                                            javax.lang.model.type.ExecutableType executableType,
                                                            java.util.List<? extends com.sun.source.tree.ExpressionTree> actualExprs,
                                                            @Nullable com.sun.source.tree.NewClassTree newClassTree)
        Given a method element, its type at the call site, and a 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. The argument of newClassTree is null when we visit MethodInvocationTree, and is non-null when we visit NewClassTree.
        Parameters:
        executable - an ExecutableElement representing a method/constructor to be called
        executableType - an ExecutableType representing the type of the method/constructor call; the type must be viewpoint-adapted to the call
        actualExprs - a List of argument expressions to a call
        newClassTree - the NewClassTree if the method is the invocation of a constructor
        Returns:
        a List of Nodes representing arguments after conversions required by a call to this method
      • conditionalExprPromotion

        protected Node conditionalExprPromotion​(Node node,
                                                javax.lang.model.type.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 javax.lang.model.element.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,
                                       java.lang.Void p)
        Specified by:
        visitAnnotatedType in interface com.sun.source.tree.TreeVisitor<Node,​java.lang.Void>
        Overrides:
        visitAnnotatedType in class com.sun.source.util.TreeScanner<Node,​java.lang.Void>
      • visitAnnotation

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

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

        public Node visitAssert​(com.sun.source.tree.AssertTree tree,
                                java.lang.Void p)
        Specified by:
        visitAssert in interface com.sun.source.tree.TreeVisitor<Node,​java.lang.Void>
        Overrides:
        visitAssert in class com.sun.source.util.TreeScanner<Node,​java.lang.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,
                                    java.lang.Void p)
        Specified by:
        visitAssignment in interface com.sun.source.tree.TreeVisitor<Node,​java.lang.Void>
        Overrides:
        visitAssignment in class com.sun.source.util.TreeScanner<Node,​java.lang.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,
                                            java.lang.Void p)
        Specified by:
        visitCompoundAssignment in interface com.sun.source.tree.TreeVisitor<Node,​java.lang.Void>
        Overrides:
        visitCompoundAssignment in class com.sun.source.util.TreeScanner<Node,​java.lang.Void>
      • visitBinary

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

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

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

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

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

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

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

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

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

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

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

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

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

        protected com.sun.source.tree.VariableTree createEnhancedForLoopIteratorVariable​(com.sun.source.tree.MethodInvocationTree iteratorCall,
                                                                                         javax.lang.model.element.VariableElement variableElement)
      • createEnhancedForLoopArrayVariable

        protected com.sun.source.tree.VariableTree createEnhancedForLoopArrayVariable​(com.sun.source.tree.ExpressionTree expression,
                                                                                      javax.lang.model.element.VariableElement variableElement)
      • visitForLoop

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        protected javax.lang.model.type.TypeMirror getTypeMirror​(java.lang.Class<?> clazz)
        Returns the TypeMirror for the given class.
        Parameters:
        clazz - a class
        Returns:
        the TypeMirror for the class
      • maybeGetTypeMirror

        protected @Nullable javax.lang.model.type.TypeMirror maybeGetTypeMirror​(java.lang.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