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

Method extract_call

codegraph-kernel/src/csharp.rs:1132–1186  ·  view source on GitHub ↗

extractCall — the C# branch (tree-sitter.ts:4502) + shared tail.

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

Source from the content-addressed store, hash-verified

1130
1131 /// extractCall — the C# branch (tree-sitter.ts:4502) + shared tail.
1132 fn extract_call(&mut self, node: Node<'t>) {
1133 if self.stack.is_empty() {
1134 return;
1135 }
1136 let caller = self.top_row();
1137 let func = node
1138 .child_by_field_name("function")
1139 .or_else(|| node.named_child(0));
1140 let Some(func) = func else { return };
1141
1142 let mut callee_name: String;
1143 if func.kind() == "member_access_expression" {
1144 let recv = func.child_by_field_name("expression");
1145 let name_node = func.child_by_field_name("name");
1146 let method_name = name_node.map(|n| self.text(n)).unwrap_or("");
1147 let chained = recv
1148 .map(|r| r.kind() == "invocation_expression" && !method_name.is_empty())
1149 .unwrap_or(false);
1150 if chained {
1151 // Chained factory `Foo.Create(args).Bar()` → `Foo.Create().Bar`
1152 // (inner whitespace stripped, EVERY call-receiver re-encodes —
1153 // no capitalization gate, unlike kotlin/scala).
1154 let inner_func = recv.unwrap().child_by_field_name("function");
1155 let inner_callee = inner_func.map(|f| strip_js_ws(self.text(f))).unwrap_or_default();
1156 callee_name = if inner_callee.is_empty() {
1157 method_name.to_string()
1158 } else {
1159 format!("{inner_callee}().{method_name}")
1160 };
1161 } else {
1162 // RAW full member-access text: `this.Run`, `base.Method`,
1163 // `"lit".ToUpper`, multi-line fluent chains with their
1164 // newlines — no SKIP_RECEIVERS, no literal filter (preserve).
1165 callee_name = self.text(func).to_string();
1166 }
1167 } else {
1168 // Bare `Helper()`, generic `Generic<int>` kept verbatim,
1169 // `nameof(...)` → a calls ref named `nameof`, `?.` chains raw,
1170 // `(myDel)(x)` → parenthesized text (normalized below).
1171 callee_name = self.text(func).to_string();
1172 }
1173
1174 // Shared parenthesized-conversion normalization — the one shared
1175 // normalization C# actually hits: `(myDel)(x)` → `myDel`.
1176 if !callee_name.is_empty() {
1177 if let Some(c) = util::paren_conversion().captures(&callee_name) {
1178 callee_name = c[1].to_string();
1179 }
1180 }
1181 // (template strip + fn-ptr fan-out are c/cpp-gated — not C#.)
1182
1183 if !callee_name.is_empty() {
1184 self.push_ref_at(caller, &callee_name.clone(), edge_kind_index("calls").unwrap(), node);
1185 }
1186 }
1187
1188 fn extract_instantiation(&mut self, node: Node<'t>) {
1189 if self.stack.is_empty() {

Callers 2

visit_nodeMethod · 0.45

Calls 7

edge_kind_indexFunction · 0.85
mapMethod · 0.80
strip_js_wsFunction · 0.70
textMethod · 0.65
unwrapMethod · 0.60
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected