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

Method normalize_fn_ref_value

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

Source from the content-addressed store, hash-verified

1330 }
1331
1332 fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) {
1333 stack_guard!();
1334 if depth > 4 {
1335 return;
1336 }
1337 match v.kind() {
1338 "simple_identifier" => {
1339 let name = self.text(v);
1340 self.push_fn_ref_cand(from, name, v);
1341 }
1342 "value_argument" => {
1343 // Layer with field 'value' + the label-forward skip (the
1344 // Alamofire A/B finding): label text == value text → dropped.
1345 let label = v.child_by_field_name("name");
1346 let value = v.child_by_field_name("value").or_else(|| {
1347 if v.named_child_count() > 0 {
1348 v.named_child(v.named_child_count() - 1)
1349 } else {
1350 None
1351 }
1352 });
1353 if let (Some(l), Some(val)) = (label, value) {
1354 if self.text(l).trim() == self.text(val).trim() {
1355 return;
1356 }
1357 }
1358 if let Some(inner) = v.child_by_field_name("value") {
1359 self.normalize_fn_ref_value(inner, from, depth + 1);
1360 }
1361 }
1362 "selector_expression" => {
1363 // `#selector(fire)` → fire; dotted → rightmost
1364 // simple_identifier (incl. the `_` quirk); else trimmed text.
1365 let Some(inner) = v.named_child(0) else { return };
1366 if matches!(inner.kind(), "identifier" | "simple_identifier") {
1367 let name = self.text(inner);
1368 self.push_fn_ref_cand(from, name, inner);
1369 return;
1370 }
1371 if let Some(last) = last_simple_identifier(v) {
1372 let name = self.text(last);
1373 self.push_fn_ref_cand(from, name, last);
1374 return;
1375 }
1376 let name = self.text(inner).trim().to_string();
1377 self.push_fn_ref_cand(from, &name, inner);
1378 }
1379 _ => {}
1380 }
1381 }
1382
1383 fn push_fn_ref_cand(&mut self, from: u32, name: &str, node: Node) {
1384 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