MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / find_first_kind

Function find_first_kind

tests/graph_suite/complexity_test.rs:19–35  ·  view source on GitHub ↗

Recursively find the first node of the given kind.

(node: tree_sitter::Node<'a>, kind: &str)

Source from the content-addressed store, hash-verified

17
18/// Recursively find the first node of the given kind.
19fn find_first_kind<'a>(node: tree_sitter::Node<'a>, kind: &str) -> Option<tree_sitter::Node<'a>> {
20 if node.kind() == kind {
21 return Some(node);
22 }
23 let mut cursor = node.walk();
24 if cursor.goto_first_child() {
25 loop {
26 if let Some(found) = find_first_kind(cursor.node(), kind) {
27 return Some(found);
28 }
29 if !cursor.goto_next_sibling() {
30 break;
31 }
32 }
33 }
34 None
35}
36
37// ── Branch counting ─────────────────────────────────────────────────────────
38

Callers 1

rust_fn_complexityFunction · 0.70

Calls 1

kindMethod · 0.80

Tested by

no test coverage detected