ObservableAstIterator

An iterator that performs a DFS traversal through the nodes of an AST, allowing the registration of observers that will be notified when a node of a certain type is visited.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Hooks that will be called when a node of a certain type is visited.

Functions

Link copied to clipboard

Attaches a hook to this iterator.

Link copied to clipboard
inline fun <T : Node> collect(crossinline condition: (T) -> Boolean): List<T>

Collects the visited nodes of type T into a collection, as long as they satisfy a condition.

Link copied to clipboard
inline fun <T : Node> collectAll(): List<T>

Collects all the visited nodes of type T into a collection.

Link copied to clipboard
inline fun <T : Node> on(noinline hook: (T) -> Unit): ObservableAstIterator

Registers a hook that will be called when a node of type T is visited.

Link copied to clipboard

Registers a hook that will be called when the tree traversal fully finishes.

Link copied to clipboard
open override fun traverse(root: NestableNode)

Runs the iterator from the given root node, traversing the node tree and visiting each node.