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 int
countNodes
(Node root) static int
countNodes
(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> T
findFirstNodeInstance
(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> T
findParent
(Node start, Class<T> clazz) static Node
getNthParent
(Node node, int n) Get the nth parent of a node, where the 0th parent is the node itself.makeRecursiveIterator
(Node node) static void
printCompactTree
(OutputStream out, Node node) static String
printCompactTreeToString
(Node node) static String
static void
printSourceAttributionTree
(OutputStream out, Node node) 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.static void
printTree
(OutputStream out, Node node) Prints a human readable form of aNode
AST to the givenPrintStream
.static void
printTree
(PrintWriter p, Node node) static String
printTreeToString
(Node node) static boolean
replaceChild
(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 aNode
AST 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
-