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

Method normalize_fn_ref_value

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

Source from the content-addressed store, hash-verified

1317 }
1318
1319 fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) {
1320 if depth > 4 {
1321 return;
1322 }
1323 match v.kind() {
1324 "simple_identifier" => {
1325 let name = self.text(v);
1326 self.push_fn_ref_cand(from, name, v);
1327 }
1328 "value_argument" => {
1329 // Layer with field 'value' + the label-forward skip (the
1330 // Alamofire A/B finding): label text == value text → dropped.
1331 let label = v.child_by_field_name("name");
1332 let value = v.child_by_field_name("value").or_else(|| {
1333 if v.named_child_count() > 0 {
1334 v.named_child(v.named_child_count() - 1)
1335 } else {
1336 None
1337 }
1338 });
1339 if let (Some(l), Some(val)) = (label, value) {
1340 if self.text(l).trim() == self.text(val).trim() {
1341 return;
1342 }
1343 }
1344 if let Some(inner) = v.child_by_field_name("value") {
1345 self.normalize_fn_ref_value(inner, from, depth + 1);
1346 }
1347 }
1348 "selector_expression" => {
1349 // `#selector(fire)` → fire; dotted → rightmost
1350 // simple_identifier (incl. the `_` quirk); else trimmed text.
1351 let Some(inner) = v.named_child(0) else { return };
1352 if matches!(inner.kind(), "identifier" | "simple_identifier") {
1353 let name = self.text(inner);
1354 self.push_fn_ref_cand(from, name, inner);
1355 return;
1356 }
1357 if let Some(last) = last_simple_identifier(v) {
1358 let name = self.text(last);
1359 self.push_fn_ref_cand(from, name, last);
1360 return;
1361 }
1362 let name = self.text(inner).trim().to_string();
1363 self.push_fn_ref_cand(from, &name, inner);
1364 }
1365 _ => {}
1366 }
1367 }
1368
1369 fn push_fn_ref_cand(&mut self, from: u32, name: &str, node: Node) {
1370 if name.is_empty() || is_stoplisted(name) {

Callers 1

maybe_capture_fn_refsMethod · 0.45

Calls 3

last_simple_identifierFunction · 0.85
textMethod · 0.45
push_fn_ref_candMethod · 0.45

Tested by

no test coverage detected