findFirst

open fun <T> findFirst(traversal: Node.TreeTraversal, consumer: (Node) -> Optional<T>): Optional<T>(source)

Walks the AST, applying the function for every node, with traversal algorithm "traversal". If the function returns something else than null, the traversal is stopped and the function result is returned. This is the most general findFirst method. All other findFirst methods are based on this.


open fun <N : Node?> findFirst(nodeType: Class<N>): Optional<N>(source)

Walks the AST with pre-order traversal, returning the first node of type "nodeType" or empty() if none is found.


open fun <N : Node?> findFirst(nodeType: Class<N>, predicate: Predicate<N>): Optional<N>(source)

Walks the AST with pre-order traversal, returning the first node of type "nodeType" that matches "predicate" or empty() if none is found.