public final class NodeUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
NodeUtil.FieldOffsetProvider
Interface that allows the customization of field offsets used for
Unsafe field
accesses. |
static class |
NodeUtil.NodeClass
Information about a
Node class. |
static interface |
NodeUtil.NodeCountFilter |
static class |
NodeUtil.NodeField
Information about a field in a
Node class. |
static class |
NodeUtil.NodeFieldKind |
Constructor and Description |
---|
NodeUtil() |
Modifier and Type | Method and Description |
---|---|
static <T extends Node> |
cloneNode(T orig) |
static java.util.List<Node> |
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> java.util.List<T> |
findAllNodeInstances(Node root,
java.lang.Class<T> clazz) |
static <T> java.util.List<T> |
findAllParents(Node start,
java.lang.Class<T> clazz) |
static <T extends java.lang.annotation.Annotation> |
findAnnotation(java.lang.Class<?> clazz,
java.lang.Class<T> annotationClass)
find annotation in class/interface hierarchy.
|
static <T> T |
findFirstNodeInstance(Node root,
java.lang.Class<T> clazz) |
static java.util.List<Node> |
findNodeChildren(Node node) |
static <T> java.util.List<T> |
findNodeInstancesShallow(Node root,
java.lang.Class<T> clazz)
Like
findAllNodeInstances(Node, Class) but do not visit children of found nodes. |
static <T> T |
findParent(Node start,
java.lang.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.
|
static java.util.Iterator<Node> |
makeRecursiveIterator(Node node) |
static void |
printCompactTree(java.io.OutputStream out,
Node node) |
static java.lang.String |
printCompactTreeToString(Node node) |
static java.lang.String |
printSourceAttributionTree(Node node) |
static void |
printSourceAttributionTree(java.io.OutputStream out,
Node node) |
static java.lang.String |
printSyntaxTags(java.lang.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(java.io.OutputStream out,
Node node)
Prints a human readable form of a
Node AST to the given PrintStream . |
static void |
printTree(java.io.PrintWriter p,
Node node) |
static java.lang.String |
printTreeToString(Node node) |
static boolean |
replaceChild(Node parent,
Node oldChild,
Node newChild) |
static boolean |
verify(Node root) |
public static <T extends Node> T cloneNode(T orig)
public static <T> T[] concat(T[] first, T[] second)
public static Node getNthParent(Node node, int n)
public static <T extends java.lang.annotation.Annotation> T findAnnotation(java.lang.Class<?> clazz, java.lang.Class<T> annotationClass)
public static <T> T findParent(Node start, java.lang.Class<T> clazz)
public static <T> java.util.List<T> findAllParents(Node start, java.lang.Class<T> clazz)
public static <T> T findFirstNodeInstance(Node root, java.lang.Class<T> clazz)
public static <T> java.util.List<T> findAllNodeInstances(Node root, java.lang.Class<T> clazz)
public static <T> java.util.List<T> findNodeInstancesShallow(Node root, java.lang.Class<T> clazz)
findAllNodeInstances(Node, Class)
but do not visit children of found nodes.public static int countNodes(Node root)
public static int countNodes(Node root, NodeUtil.NodeCountFilter filter)
public static java.lang.String printCompactTreeToString(Node node)
public static void printCompactTree(java.io.OutputStream out, Node node)
public static java.lang.String printSourceAttributionTree(Node node)
public static void printSourceAttributionTree(java.io.OutputStream out, Node node)
public static java.lang.String printSyntaxTags(java.lang.Object node)
public static void printTree(java.io.OutputStream out, Node node)
Node
AST to the given PrintStream
. This
print method does not check for cycles in the node structure.out
- the stream to print to.node
- the root node to writepublic static java.lang.String printTreeToString(Node node)
public static void printTree(java.io.PrintWriter p, Node node)
public static boolean verify(Node root)