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

Method normalize_fn_ref_value

codegraph-kernel/src/swift.rs:1380–1429  ·  view source on GitHub ↗
(&mut self, v: Node<'t>, from: u32, depth: u32)

Source from the content-addressed store, hash-verified

1378 }
1379
1380 fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) {
1381 stack_guard!();
1382 if depth > 4 {
1383 return;
1384 }
1385 match v.kind() {
1386 "simple_identifier" => {
1387 let name = self.text(v);
1388 self.push_fn_ref_cand(from, name, v);
1389 }
1390 "value_argument" => {
1391 // Layer with field 'value' + the label-forward skip (the
1392 // Alamofire A/B finding): label text == value text → dropped.
1393 let label = v.child_by_field_name("name");
1394 let value = v.child_by_field_name("value").or_else(|| {
1395 if v.named_child_count() > 0 {
1396 v.named_child(v.named_child_count() - 1)
1397 } else {
1398 None
1399 }
1400 });
1401 if let (Some(l), Some(val)) = (label, value) {
1402 if self.text(l).trim() == self.text(val).trim() {
1403 return;
1404 }
1405 }
1406 if let Some(inner) = v.child_by_field_name("value") {
1407 self.normalize_fn_ref_value(inner, from, depth + 1);
1408 }
1409 }
1410 "selector_expression" => {
1411 // `#selector(fire)` → fire; dotted → rightmost
1412 // simple_identifier (incl. the `_` quirk); else trimmed text.
1413 let Some(inner) = v.named_child(0) else { return };
1414 if matches!(inner.kind(), "identifier" | "simple_identifier") {
1415 let name = self.text(inner);
1416 self.push_fn_ref_cand(from, name, inner);
1417 return;
1418 }
1419 if let Some(last) = last_simple_identifier(v) {
1420 let name = self.text(last);
1421 self.push_fn_ref_cand(from, name, last);
1422 return;
1423 }
1424 let name = self.text(inner).trim().to_string();
1425 self.push_fn_ref_cand(from, &name, inner);
1426 }
1427 _ => {}
1428 }
1429 }
1430
1431 fn push_fn_ref_cand(&mut self, from: u32, name: &str, node: Node) {
1432 if name.is_empty() || is_stoplisted(name) {

Callers 1

maybe_capture_fn_refsMethod · 0.45

Calls 3

last_simple_identifierFunction · 0.85
textMethod · 0.65
push_fn_ref_candMethod · 0.45

Tested by

no test coverage detected