(&mut self, node: Node<'t>)
| 1349 | // --- function-as-value refs (SWIFT_SPEC, function-ref.ts:288) ------------------- |
| 1350 | |
| 1351 | fn maybe_capture_fn_refs(&mut self, node: Node<'t>) { |
| 1352 | enum Mode { |
| 1353 | Args, |
| 1354 | Rhs, |
| 1355 | List, |
| 1356 | Varinit, |
| 1357 | } |
| 1358 | let mode = match node.kind() { |
| 1359 | "value_arguments" => Mode::Args, |
| 1360 | "assignment" => Mode::Rhs, // field 'result' |
| 1361 | "array_literal" => Mode::List, |
| 1362 | "property_declaration" => Mode::Varinit, // field 'value' |
| 1363 | _ => return, |
| 1364 | }; |
| 1365 | if self.stack.is_empty() { |
| 1366 | return; |
| 1367 | } |
| 1368 | let from = self.top_row(); |
| 1369 | |
| 1370 | let mut values: Vec<Node> = Vec::new(); |
| 1371 | match mode { |
| 1372 | Mode::Args | Mode::List => { |
| 1373 | for i in 0..node.named_child_count() { |
| 1374 | if let Some(c) = node.named_child(i) { |
| 1375 | values.push(c); |
| 1376 | } |
| 1377 | } |
| 1378 | } |
| 1379 | Mode::Rhs => { |
| 1380 | if let Some(rhs) = node.child_by_field_name("result") { |
| 1381 | // Param-storage skip — swift's LHS field is `target`. |
| 1382 | let lhs = node |
| 1383 | .child_by_field_name("left") |
| 1384 | .or_else(|| node.child_by_field_name("lhs")) |
| 1385 | .or_else(|| node.child_by_field_name("target")) |
| 1386 | .or_else(|| { |
| 1387 | if node.named_child_count() >= 2 { node.named_child(0) } else { None } |
| 1388 | }); |
| 1389 | let lhs_text = lhs.map(|l| self.text(l)).unwrap_or(""); |
| 1390 | let lhs_last = util::lhs_last_name() |
| 1391 | .captures(lhs_text) |
| 1392 | .and_then(|c| c.get(1)) |
| 1393 | .map(|m| m.as_str()); |
| 1394 | let rhs_text = self.text(rhs).trim(); |
| 1395 | if !(lhs_last.is_some() && lhs_last == Some(rhs_text)) { |
| 1396 | values.push(rhs); |
| 1397 | } |
| 1398 | } |
| 1399 | } |
| 1400 | Mode::Varinit => { |
| 1401 | // Destructuring gate: swift's name field is a `pattern` node — |
| 1402 | // never in the pattern-kind set → never skipped. |
| 1403 | let name_child = node |
| 1404 | .child_by_field_name("name") |
| 1405 | .or_else(|| node.child_by_field_name("pattern")); |
| 1406 | let is_destructuring = name_child |
| 1407 | .map(|nc| { |
| 1408 | matches!( |
no test coverage detected