MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / first_simple_identifier

Function first_simple_identifier

codegraph-kernel/src/swift.rs:314–333  ·  view source on GitHub ↗

firstSimpleIdentifier (tree-sitter.ts:261): BFS (FIFO), at most 40 nodes popped, first `simple_identifier` wins.

(node: Option<Node<'t>>)

Source from the content-addressed store, hash-verified

312/// firstSimpleIdentifier (tree-sitter.ts:261): BFS (FIFO), at most 40 nodes
313/// popped, first `simple_identifier` wins.
314fn first_simple_identifier<'t>(node: Option<Node<'t>>) -> Option<Node<'t>> {
315 let mut q: VecDeque<Node<'t>> = VecDeque::new();
316 if let Some(n) = node {
317 q.push_back(n);
318 }
319 let mut guard = 0;
320 while guard < 40 {
321 let Some(n) = q.pop_front() else { break };
322 guard += 1;
323 if n.kind() == "simple_identifier" {
324 return Some(n);
325 }
326 for i in 0..n.named_child_count() {
327 if let Some(c) = n.named_child(i) {
328 q.push_back(c);
329 }
330 }
331 }
332 None
333}
334
335/// lastNamedOfType (function-ref.ts:600): rightmost matching DESCENDANT in
336/// document order (deeper matches override).

Callers 2

swift_property_infoMethod · 0.85
flush_value_refsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected