(&mut self, node: Node<'t>)
| 1241 | // --- function-as-value refs (SWIFT_SPEC, function-ref.ts:288) ------------------- |
| 1242 | |
| 1243 | fn maybe_capture_fn_refs(&mut self, node: Node<'t>) { |
| 1244 | enum Mode { |
| 1245 | Args, |
| 1246 | Rhs, |
| 1247 | List, |
| 1248 | Varinit, |
| 1249 | } |
| 1250 | let mode = match node.kind() { |
| 1251 | "value_arguments" => Mode::Args, |
| 1252 | "assignment" => Mode::Rhs, // field 'result' |
| 1253 | "array_literal" => Mode::List, |
| 1254 | "property_declaration" => Mode::Varinit, // field 'value' |
| 1255 | _ => return, |
| 1256 | }; |
| 1257 | if self.stack.is_empty() { |
| 1258 | return; |
| 1259 | } |
| 1260 | let from = self.top_row(); |
| 1261 | |
| 1262 | let mut values: Vec<Node> = Vec::new(); |
| 1263 | match mode { |
| 1264 | Mode::Args | Mode::List => { |
| 1265 | for i in 0..node.named_child_count() { |
| 1266 | if let Some(c) = node.named_child(i) { |
| 1267 | values.push(c); |
| 1268 | } |
| 1269 | } |
| 1270 | } |
| 1271 | Mode::Rhs => { |
| 1272 | if let Some(rhs) = node.child_by_field_name("result") { |
| 1273 | // Param-storage skip — swift's LHS field is `target`. |
| 1274 | let lhs = node |
| 1275 | .child_by_field_name("left") |
| 1276 | .or_else(|| node.child_by_field_name("lhs")) |
| 1277 | .or_else(|| node.child_by_field_name("target")) |
| 1278 | .or_else(|| { |
| 1279 | if node.named_child_count() >= 2 { node.named_child(0) } else { None } |
| 1280 | }); |
| 1281 | let lhs_text = lhs.map(|l| self.text(l)).unwrap_or(""); |
| 1282 | let lhs_last = util::lhs_last_name() |
| 1283 | .captures(lhs_text) |
| 1284 | .and_then(|c| c.get(1)) |
| 1285 | .map(|m| m.as_str()); |
| 1286 | let rhs_text = self.text(rhs).trim(); |
| 1287 | if !(lhs_last.is_some() && lhs_last == Some(rhs_text)) { |
| 1288 | values.push(rhs); |
| 1289 | } |
| 1290 | } |
| 1291 | } |
| 1292 | Mode::Varinit => { |
| 1293 | // Destructuring gate: swift's name field is a `pattern` node — |
| 1294 | // never in the pattern-kind set → never skipped. |
| 1295 | let name_child = node |
| 1296 | .child_by_field_name("name") |
| 1297 | .or_else(|| node.child_by_field_name("pattern")); |
| 1298 | let is_destructuring = name_child |
| 1299 | .map(|nc| { |
| 1300 | matches!( |
no test coverage detected