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

Method normalize_fn_ref_value

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

Source from the content-addressed store, hash-verified

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