matches

Iterate over all the matches in the order that they were found.

Example

query.matches(tree.rootNode) {
if (name != "ieq?") return@matches true
val node = it[(args[0] as QueryPredicateArg.Capture).value].first()
val value = (args[1] as QueryPredicateArg.Literal).value
value.equals(node.text()?.toString(), ignoreCase = true)
}

Parameters

node

The node that the query will run on.

predicate

A function that handles custom predicates.

expect fun matches(node: Node, predicate: QueryPredicate.(QueryMatch) -> Boolean = { true }): Sequence<QueryMatch>(source)

Iterate over all the matches in the order that they were found.

Example

query.matches(tree.rootNode) {
if (name != "ieq?") return@matches true
val node = it[(args[0] as QueryPredicateArg.Capture).value].first()
val value = (args[1] as QueryPredicateArg.Literal).value
value.equals(node.text()?.toString(), ignoreCase = true)
}

Parameters

node

The node that the query will run on.

predicate

A function that handles custom predicates.

Iterate over all the matches in the order that they were found.

Example

query.matches(tree.rootNode) {
if (name != "ieq?") return@matches true
val node = it[(args[0] as QueryPredicateArg.Capture).value].first()
val value = (args[1] as QueryPredicateArg.Literal).value
value.equals(node.text()?.toString(), ignoreCase = true)
}

Parameters

node

The node that the query will run on.

predicate

A function that handles custom predicates.

actual fun matches(node: Node, predicate: QueryPredicate.(QueryMatch) -> Boolean = { true }): Sequence<QueryMatch>(source)

Iterate over all the matches in the order that they were found.

Example

query.matches(tree.rootNode) {
if (name != "ieq?") return@matches true
val node = it[(args[0] as QueryPredicateArg.Capture).value].first()
val value = (args[1] as QueryPredicateArg.Literal).value
value.equals(node.text()?.toString(), ignoreCase = true)
}

Parameters

node

The node that the query will run on.

predicate

A function that handles custom predicates.