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

Method extract_static_member_ref

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

extractStaticMemberRef — cpp only (c is not in STATIC_MEMBER_LANGS). In this grammar the firing shape is `field_expression` (listed in MEMBER_ACCESS_TYPES for Scala — same node kind here): a capitalized simple receiver's value read.

(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

1447 /// MEMBER_ACCESS_TYPES for Scala — same node kind here): a capitalized
1448 /// simple receiver's value read.
1449 fn extract_static_member_ref(&mut self, node: Node<'t>) {
1450 if self.variant != Variant::Cpp {
1451 return;
1452 }
1453 if self.stack.is_empty() {
1454 return;
1455 }
1456 if !matches!(node.kind(), "field_expression" | "qualified_identifier") {
1457 return;
1458 }
1459 // Skip `Type.method()` — the access is a call's callee, already linked.
1460 if let Some(parent) = node.parent() {
1461 if parent.kind() == "call_expression" {
1462 let callee = parent
1463 .child_by_field_name("function")
1464 .or_else(|| parent.child_by_field_name("method"))
1465 .or_else(|| parent.named_child(0));
1466 if let Some(callee) = callee {
1467 if callee.start_byte() == node.start_byte() {
1468 return;
1469 }
1470 }
1471 }
1472 }
1473 let recv = node
1474 .child_by_field_name("object")
1475 .or_else(|| node.child_by_field_name("expression"))
1476 .or_else(|| node.child_by_field_name("scope"))
1477 .or_else(|| node.named_child(0));
1478 let Some(recv) = recv else { return };
1479 if !matches!(
1480 recv.kind(),
1481 "identifier" | "type_identifier" | "simple_identifier" | "name" | "scoped_type_identifier"
1482 ) {
1483 return;
1484 }
1485 let text = self.text(recv);
1486 if capitalized_re().is_match(text) {
1487 let owner = self.top_row();
1488 let name = text.to_string();
1489 self.push_ref_at(owner, &name, edge_kind_index("references").unwrap(), recv);
1490 }
1491 }
1492
1493 // --- function bodies -----------------------------------------------------
1494

Callers 1

Calls 6

edge_kind_indexFunction · 0.85
capitalized_reFunction · 0.70
unwrapMethod · 0.60
textMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected