Package com.strumenta.kolasu.javalib
Class Traversing
-
- All Implemented Interfaces:
public class Traversing
-
-
Constructor Summary
Constructors Constructor Description Traversing()
-
Method Summary
Modifier and Type Method Description static Stream<Node>walk(Node node)static Stream<Node>walkLeavesFirst(Node node)Performs a post-order (or leaves-first) node traversal starting with a given node. static Stream<Node>walkAncestors(Node node)static Stream<Node>walkDescendantsBreadthFirst(Node node)static Stream<Node>walkDescendantsLeavesFirst(Node node)static <N> Stream<N>walkDescendantsBreadthFirst(Node node, Class<N> clazz)static <N> Stream<N>walkDescendantsLeavesFirst(Node node, Class<N> clazz)static voidwalk(Node node, Consumer<Node> consumer)static voidwalkLeavesFirst(Node node, Consumer<Node> consumer)Performs a post-order (or leaves-first) node traversal starting with a given node. static voidwalkAncestors(Node node, Consumer<Node> consumer)static voidwalkDescendantsBreadthFirst(Node node, Consumer<Node> consumer)static voidwalkDescendantsLeavesFirst(Node node, Consumer<Node> consumer)static <N> voidwalkDescendantsBreadthFirst(Node node, Class<N> clazz, Consumer<Node> consumer)static <N> voidwalkDescendantsLeavesFirst(Node node, Class<N> clazz, Consumer<Node> consumer)static <N> voidwalkWithin(Node node, Position position, Consumer<Node> consumer)Walks the AST within the given position starting from the given node and returns the result as sequence to consume. static <N> voidwalkWithin(List<Node> nodes, Position position, Consumer<Node> consumer)Walks the AST within the given position starting from each give node and concatenates all results in a single sequence to consume. static <T> TfindAncestorOfType(Node node, Class<T> clazz)-
-
Method Detail
-
walkLeavesFirst
static Stream<Node> walkLeavesFirst(Node node)
Performs a post-order (or leaves-first) node traversal starting with a given node.
-
walkAncestors
static Stream<Node> walkAncestors(Node node)
-
walkDescendantsBreadthFirst
static Stream<Node> walkDescendantsBreadthFirst(Node node)
-
walkDescendantsLeavesFirst
static Stream<Node> walkDescendantsLeavesFirst(Node node)
-
walkDescendantsBreadthFirst
static <N> Stream<N> walkDescendantsBreadthFirst(Node node, Class<N> clazz)
-
walkDescendantsLeavesFirst
static <N> Stream<N> walkDescendantsLeavesFirst(Node node, Class<N> clazz)
-
walkLeavesFirst
static void walkLeavesFirst(Node node, Consumer<Node> consumer)
Performs a post-order (or leaves-first) node traversal starting with a given node.
-
walkAncestors
static void walkAncestors(Node node, Consumer<Node> consumer)
-
walkDescendantsBreadthFirst
static void walkDescendantsBreadthFirst(Node node, Consumer<Node> consumer)
-
walkDescendantsLeavesFirst
static void walkDescendantsLeavesFirst(Node node, Consumer<Node> consumer)
-
walkDescendantsBreadthFirst
static <N> void walkDescendantsBreadthFirst(Node node, Class<N> clazz, Consumer<Node> consumer)
-
walkDescendantsLeavesFirst
static <N> void walkDescendantsLeavesFirst(Node node, Class<N> clazz, Consumer<Node> consumer)
-
walkWithin
static <N> void walkWithin(Node node, Position position, Consumer<Node> consumer)
Walks the AST within the given position starting from the given node and returns the result as sequence to consume.
- Parameters:
node- the node from which the walk should startposition- the position within which the walk should remain
-
walkWithin
static <N> void walkWithin(List<Node> nodes, Position position, Consumer<Node> consumer)
Walks the AST within the given position starting from each give node and concatenates all results in a single sequence to consume.
- Parameters:
nodes- the nodes from which the walk should startposition- the position within which the walk should remain
-
findAncestorOfType
static <T> T findAncestorOfType(Node node, Class<T> clazz)
-
-
-
-