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

Method extract_static_member_ref

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

1995 /// MEMBER_ACCESS_TYPES for Scala — same node kind here): a capitalized
1996 /// simple receiver's value read.
1997 fn extract_static_member_ref(&mut self, node: Node<'t>) {
1998 if self.variant != Variant::Cpp {
1999 return;
2000 }
2001 if self.stack.is_empty() {
2002 return;
2003 }
2004 if !matches!(node.kind(), "field_expression" | "qualified_identifier") {
2005 return;
2006 }
2007 // Skip `Type.method()` — the access is a call's callee, already linked.
2008 if let Some(parent) = node.parent() {
2009 if parent.kind() == "call_expression" {
2010 let callee = parent
2011 .child_by_field_name("function")
2012 .or_else(|| parent.child_by_field_name("method"))
2013 .or_else(|| parent.named_child(0));
2014 if let Some(callee) = callee {
2015 if callee.start_byte() == node.start_byte() {
2016 return;
2017 }
2018 }
2019 }
2020 }
2021 let recv = node
2022 .child_by_field_name("object")
2023 .or_else(|| node.child_by_field_name("expression"))
2024 .or_else(|| node.child_by_field_name("scope"))
2025 .or_else(|| node.named_child(0));
2026 let Some(recv) = recv else { return };
2027 if !matches!(
2028 recv.kind(),
2029 "identifier" | "type_identifier" | "simple_identifier" | "name" | "scoped_type_identifier"
2030 ) {
2031 return;
2032 }
2033 let text = self.text(recv);
2034 if capitalized_re().is_match(text) {
2035 let owner = self.top_row();
2036 let name = text.to_string();
2037 self.push_ref_at(owner, &name, edge_kind_index("references").unwrap(), recv);
2038 }
2039 }
2040
2041 // --- function bodies -----------------------------------------------------
2042

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