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

Method extract_static_member_ref

codegraph-kernel/src/ccpp/mod.rs:1465–1507  ·  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

1463 /// MEMBER_ACCESS_TYPES for Scala — same node kind here): a capitalized
1464 /// simple receiver's value read.
1465 fn extract_static_member_ref(&mut self, node: Node<'t>) {
1466 if self.variant != Variant::Cpp {
1467 return;
1468 }
1469 if self.stack.is_empty() {
1470 return;
1471 }
1472 if !matches!(node.kind(), "field_expression" | "qualified_identifier") {
1473 return;
1474 }
1475 // Skip `Type.method()` — the access is a call's callee, already linked.
1476 if let Some(parent) = node.parent() {
1477 if parent.kind() == "call_expression" {
1478 let callee = parent
1479 .child_by_field_name("function")
1480 .or_else(|| parent.child_by_field_name("method"))
1481 .or_else(|| parent.named_child(0));
1482 if let Some(callee) = callee {
1483 if callee.start_byte() == node.start_byte() {
1484 return;
1485 }
1486 }
1487 }
1488 }
1489 let recv = node
1490 .child_by_field_name("object")
1491 .or_else(|| node.child_by_field_name("expression"))
1492 .or_else(|| node.child_by_field_name("scope"))
1493 .or_else(|| node.named_child(0));
1494 let Some(recv) = recv else { return };
1495 if !matches!(
1496 recv.kind(),
1497 "identifier" | "type_identifier" | "simple_identifier" | "name" | "scoped_type_identifier"
1498 ) {
1499 return;
1500 }
1501 let text = self.text(recv);
1502 if capitalized_re().is_match(text) {
1503 let owner = self.top_row();
1504 let name = text.to_string();
1505 self.push_ref_at(owner, &name, edge_kind_index("references").unwrap(), recv);
1506 }
1507 }
1508
1509 // --- function bodies -----------------------------------------------------
1510

Callers 1

Calls 6

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

Tested by

no test coverage detected