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