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

Method normalize_fn_ref_value

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

Source from the content-addressed store, hash-verified

1426 }
1427
1428 fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) {
1429 stack_guard!();
1430 if depth > 4 {
1431 return;
1432 }
1433 match v.kind() {
1434 "simple_identifier" => {
1435 let name = self.text(v);
1436 self.push_fn_ref_cand(from, name, v);
1437 }
1438 "value_argument" => {
1439 // Layer with field 'value' + the label-forward skip (the
1440 // Alamofire A/B finding): label text == value text → dropped.
1441 let label = v.child_by_field_name("name");
1442 let value = v.child_by_field_name("value").or_else(|| {
1443 if v.named_child_count() > 0 {
1444 v.named_child(v.named_child_count() - 1)
1445 } else {
1446 None
1447 }
1448 });
1449 if let (Some(l), Some(val)) = (label, value) {
1450 if self.text(l).trim() == self.text(val).trim() {
1451 return;
1452 }
1453 }
1454 if let Some(inner) = v.child_by_field_name("value") {
1455 self.normalize_fn_ref_value(inner, from, depth + 1);
1456 }
1457 }
1458 "selector_expression" => {
1459 // `#selector(fire)` → fire; dotted → rightmost
1460 // simple_identifier (incl. the `_` quirk); else trimmed text.
1461 let Some(inner) = v.named_child(0) else { return };
1462 if matches!(inner.kind(), "identifier" | "simple_identifier") {
1463 let name = self.text(inner);
1464 self.push_fn_ref_cand(from, name, inner);
1465 return;
1466 }
1467 if let Some(last) = last_simple_identifier(v) {
1468 let name = self.text(last);
1469 self.push_fn_ref_cand(from, name, last);
1470 return;
1471 }
1472 let name = self.text(inner).trim().to_string();
1473 self.push_fn_ref_cand(from, &name, inner);
1474 }
1475 _ => {}
1476 }
1477 }
1478
1479 fn push_fn_ref_cand(&mut self, from: u32, name: &str, node: Node) {
1480 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