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

Method normalize_fn_ref_value

codegraph-kernel/src/csharp.rs:1477–1519  ·  view source on GitHub ↗

normalizeValue (function-ref.ts:525) for CSHARP_SPEC: bare identifiers, the transparent `argument` layer, and the `this.Member` special.

(&mut self, v: Node<'t>, from: u32, depth: u32)

Source from the content-addressed store, hash-verified

1475 /// normalizeValue (function-ref.ts:525) for CSHARP_SPEC: bare identifiers,
1476 /// the transparent `argument` layer, and the `this.Member` special.
1477 fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) {
1478 stack_guard!();
1479 if depth > 4 {
1480 return;
1481 }
1482 match v.kind() {
1483 "identifier" => {
1484 let name = self.text(v);
1485 self.push_fn_ref_cand(from, name, v);
1486 }
1487 "argument" => {
1488 // Transparent layer (field=null) → recurse all named children.
1489 for c in v.named_children(&mut v.walk()) {
1490 self.normalize_fn_ref_value(c, from, depth + 1);
1491 }
1492 }
1493 "member_access_expression" => {
1494 // `this.Run0` — receiver must be EXACTLY `this` (the vendored
1495 // grammar yields the anonymous `this` token via the field;
1496 // text-prefix fallback for field-less shapes). Candidate is
1497 // the BARE member name at the name node's position.
1498 let Some(name_node) = v.child_by_field_name("name") else { return };
1499 let is_this = match v.child_by_field_name("expression") {
1500 Some(e) => e.kind() == "this_expression" || e.kind() == "this",
1501 None => self.text(v).starts_with("this."),
1502 };
1503 if is_this {
1504 let name = self.text(name_node);
1505 self.push_fn_ref_cand(from, name, name_node);
1506 } else {
1507 // A method group through a receiver, `worker.Run` (#2906):
1508 // the receiver kept, a `this.` before a field dropped; it
1509 // skips the name gate (flush_fn_ref_candidates).
1510 let stripped = strip_js_ws(self.text(v));
1511 let value = stripped.strip_prefix("this.").unwrap_or(&stripped).to_string();
1512 if member_value_re().is_match(&value) {
1513 self.push_fn_ref_cand(from, &value, name_node);
1514 }
1515 }
1516 }
1517 _ => {}
1518 }
1519 }
1520
1521 fn push_fn_ref_cand(&mut self, from: u32, name: &str, node: Node) {
1522 if name.is_empty() || is_stoplisted(name) {

Callers 1

maybe_capture_fn_refsMethod · 0.45

Calls 5

member_value_reFunction · 0.85
strip_js_wsFunction · 0.70
textMethod · 0.65
push_fn_ref_candMethod · 0.45
walkMethod · 0.45

Tested by

no test coverage detected