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

Method extract_static_member_ref

codegraph-kernel/src/swift.rs:1176–1216  ·  view source on GitHub ↗

extractStaticMemberRef — swift's navigation_expression value reads, body walker + walkAttrArgs only.

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

Source from the content-addressed store, hash-verified

1174 /// extractStaticMemberRef — swift's navigation_expression value reads,
1175 /// body walker + walkAttrArgs only.
1176 fn extract_static_member_ref(&mut self, node: Node<'t>) {
1177 if node.kind() != "navigation_expression" {
1178 return;
1179 }
1180 if self.stack.is_empty() {
1181 return;
1182 }
1183 let owner = self.top_row();
1184 // Skip the callee nav of a call.
1185 if let Some(parent) = node.parent() {
1186 if parent.kind() == "call_expression" {
1187 let callee = parent
1188 .child_by_field_name("function")
1189 .or_else(|| parent.child_by_field_name("method"))
1190 .or_else(|| parent.named_child(0));
1191 if let Some(callee) = callee {
1192 if callee.start_byte() == node.start_byte() {
1193 return;
1194 }
1195 }
1196 }
1197 }
1198 let recv = node
1199 .child_by_field_name("object")
1200 .or_else(|| node.child_by_field_name("expression"))
1201 .or_else(|| node.child_by_field_name("scope"))
1202 .or_else(|| node.named_child(0));
1203 let Some(recv) = recv else { return };
1204 // A prefix operator binds to the head: `!Config.shared.isOn` is
1205 // `(!Config).shared.isOn` (tree-sitter.ts).
1206 let recv = peel_call_wrappers(recv, self.src);
1207 if matches!(
1208 recv.kind(),
1209 "identifier" | "type_identifier" | "simple_identifier" | "name" | "scoped_type_identifier"
1210 ) {
1211 let text = self.text(recv);
1212 if capitalized_re().is_match(text) {
1213 self.push_ref_at(owner, &text.to_string(), edge_kind_index("references").unwrap(), recv);
1214 }
1215 }
1216 }
1217
1218 /// extractInheritance — the swift inheritance_specifier case: FIRST
1219 /// type_identifier of each specifier's user_type, everything as `extends`

Callers 2

walk_attr_argsMethod · 0.45

Calls 7

peel_call_wrappersFunction · 0.85
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