Class NodeUtil

java.lang.Object
com.oracle.truffle.api.nodes.NodeUtil

public final class NodeUtil extends Object
Utility class that manages the special access methods for node instances.
  • Constructor Details

    • NodeUtil

      public NodeUtil()
  • Method Details

    • makeRecursiveIterator

      public static Iterator<Node> makeRecursiveIterator(Node node)
    • cloneNode

      public static <T extends Node> T cloneNode(T orig)
    • findNodeChildren

      public static List<Node> findNodeChildren(Node node)
    • replaceChild

      public static boolean replaceChild(Node parent, Node oldChild, Node newChild)
    • concat

      public static <T> T[] concat(T[] first, T[] second)
    • getNthParent

      public static Node getNthParent(Node node, int n)
      Get the nth parent of a node, where the 0th parent is the node itself. Returns null if there are less than n ancestors.
    • findAnnotation

      public static <T extends Annotation> T findAnnotation(Class<?> clazz, Class<T> annotationClass)
      find annotation in class/interface hierarchy.
    • findParent

      public static <T> T findParent(Node start, Class<T> clazz)
    • findAllParents

      public static <T> List<T> findAllParents(Node start, Class<T> clazz)
    • collectNodes

      public static List<Node> collectNodes(Node parent, Node child)
    • findFirstNodeInstance

      public static <T> T findFirstNodeInstance(Node root, Class<T> clazz)
    • findAllNodeInstances

      public static <T> List<T> findAllNodeInstances(Node root, Class<T> clazz)
    • findNodeInstancesShallow

      public static <T> List<T> findNodeInstancesShallow(Node root, Class<T> clazz)
      Like findAllNodeInstances(Node, Class) but do not visit children of found nodes.
    • countNodes

      public static int countNodes(Node root)
    • countNodes

      public static int countNodes(Node root, NodeUtil.NodeCountFilter filter)
    • printCompactTreeToString

      public static String printCompactTreeToString(Node node)
    • printCompactTree

      public static void printCompactTree(OutputStream out, Node node)
    • printSourceAttributionTree

      public static String printSourceAttributionTree(Node node)
    • printSourceAttributionTree

      public static void printSourceAttributionTree(OutputStream out, Node node)
    • printSyntaxTags

      public static String printSyntaxTags(Object node)
      Returns a string listing the syntax tags, if any, associated with a node:
      • "[STATEMENT, ASSIGNMENT]" if tags have been applied;
      • "[]" if the node supports tags, but none are present; and
      • "" if the node does not support tags.
    • printTree

      public static void printTree(OutputStream out, Node node)
      Prints a human readable form of a Node AST to the given PrintStream. This print method does not check for cycles in the node structure.
      Parameters:
      out - the stream to print to.
      node - the root node to write
    • printTreeToString

      public static String printTreeToString(Node node)
    • printTree

      public static void printTree(PrintWriter p, Node node)
    • verify

      public static boolean verify(Node root)