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

Method extract_static_member_ref

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

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

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