Package com.oracle.truffle.api.nodes
Class NodeUtil
java.lang.Object
com.oracle.truffle.api.nodes.NodeUtil
Utility class that manages the special access methods for node instances.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Node>
TcloneNode(T orig) collectNodes(Node parent, Node child) static <T> T[]concat(T[] first, T[] second) static intcountNodes(Node root) static intcountNodes(Node root, NodeUtil.NodeCountFilter filter) static <T> List<T>findAllNodeInstances(Node root, Class<T> clazz) static <T> List<T>findAllParents(Node start, Class<T> clazz) static <T extends Annotation>
TfindAnnotation(Class<?> clazz, Class<T> annotationClass) find annotation in class/interface hierarchy.static <T> TfindFirstNodeInstance(Node root, Class<T> clazz) findNodeChildren(Node node) static <T> List<T>findNodeInstancesShallow(Node root, Class<T> clazz) LikefindAllNodeInstances(Node, Class)but do not visit children of found nodes.static <T> TfindParent(Node start, Class<T> clazz) static NodegetNthParent(Node node, int n) Get the nth parent of a node, where the 0th parent is the node itself.makeRecursiveIterator(Node node) static voidprintCompactTree(OutputStream out, Node node) static StringprintCompactTreeToString(Node node) static Stringstatic voidprintSourceAttributionTree(OutputStream out, Node node) static StringprintSyntaxTags(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.static voidprintTree(OutputStream out, Node node) Prints a human readable form of aNodeAST to the givenPrintStream.static voidprintTree(PrintWriter p, Node node) static StringprintTreeToString(Node node) static booleanreplaceChild(Node parent, Node oldChild, Node newChild) static boolean
-
Constructor Details
-
NodeUtil
public NodeUtil()
-
-
Method Details
-
makeRecursiveIterator
-
cloneNode
-
findNodeChildren
-
replaceChild
-
concat
public static <T> T[] concat(T[] first, T[] second) -
getNthParent
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
find annotation in class/interface hierarchy. -
findParent
-
findAllParents
-
collectNodes
-
findFirstNodeInstance
-
findAllNodeInstances
-
findNodeInstancesShallow
LikefindAllNodeInstances(Node, Class)but do not visit children of found nodes. -
countNodes
-
countNodes
-
printCompactTreeToString
-
printCompactTree
-
printSourceAttributionTree
-
printSourceAttributionTree
-
printSyntaxTags
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
Prints a human readable form of aNodeAST to the givenPrintStream. 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
-
printTree
-
verify
-