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

Function first_simple_identifier

codegraph-kernel/src/swift.rs:243–262  ·  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

241/// firstSimpleIdentifier (tree-sitter.ts:261): BFS (FIFO), at most 40 nodes
242/// popped, first `simple_identifier` wins.
243fn first_simple_identifier<'t>(node: Option<Node<'t>>) -> Option<Node<'t>> {
244 let mut q: VecDeque<Node<'t>> = VecDeque::new();
245 if let Some(n) = node {
246 q.push_back(n);
247 }
248 let mut guard = 0;
249 while guard < 40 {
250 let Some(n) = q.pop_front() else { break };
251 guard += 1;
252 if n.kind() == "simple_identifier" {
253 return Some(n);
254 }
255 for i in 0..n.named_child_count() {
256 if let Some(c) = n.named_child(i) {
257 q.push_back(c);
258 }
259 }
260 }
261 None
262}
263
264/// lastNamedOfType (function-ref.ts:600): rightmost matching DESCENDANT in
265/// 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