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

Method normalize_fn_ref_value

codegraph-kernel/src/ccpp/mod.rs:2389–2419  ·  view source on GitHub ↗

normalizeValue for cFamilySpec: bare identifiers, and the pointer_expression unwrap (`&fn`; `&Cls::m` keeps the qualified name).

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

Source from the content-addressed store, hash-verified

2387 /// normalizeValue for cFamilySpec: bare identifiers, and the
2388 /// pointer_expression unwrap (`&fn`; `&Cls::m` keeps the qualified name).
2389 fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, mode: Mode, explicit_ref: bool, depth: u32) {
2390 stack_guard!();
2391 if depth > 4 {
2392 return;
2393 }
2394 match v.kind() {
2395 "identifier" => {
2396 let name = self.text(v);
2397 if name.is_empty() || is_stoplisted(name) {
2398 return;
2399 }
2400 self.push_fn_ref_cand(from, name.to_string(), mode, explicit_ref, v);
2401 }
2402 "pointer_expression" => {
2403 // `&x` is a function value; `*x` is a data read.
2404 if v.child(0).map(|c| c.kind() != "&").unwrap_or(true) {
2405 return;
2406 }
2407 let Some(inner) = v.child_by_field_name("argument") else { return };
2408 if inner.kind() == "qualified_identifier" {
2409 let text = self.text(inner).trim();
2410 if qualified_ref_re().is_match(text) && !is_stoplisted(text) {
2411 self.push_fn_ref_cand(from, text.to_string(), mode, explicit_ref, inner);
2412 }
2413 return;
2414 }
2415 self.normalize_fn_ref_value(inner, from, mode, explicit_ref, depth + 1);
2416 }
2417 _ => {}
2418 }
2419 }
2420
2421 fn push_fn_ref_cand(&mut self, from: u32, name: String, mode: Mode, explicit_ref: bool, node: Node) {
2422 let p = node.start_position();

Callers 1

maybe_capture_fn_refsMethod · 0.45

Calls 5

qualified_ref_reFunction · 0.85
mapMethod · 0.80
is_stoplistedFunction · 0.70
textMethod · 0.65
push_fn_ref_candMethod · 0.45

Tested by

no test coverage detected