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

Method extract_static_member_ref

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

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

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