(&mut self, node: Node<'t>)
| 553 | // --- extractVariable — the lua/luau branch (2538-2549, 2789-2805) ----- |
| 554 | |
| 555 | fn extract_variable(&mut self, node: Node<'t>) { |
| 556 | // isConst absent → kind is ALWAYS `variable`; docstring from the |
| 557 | // DECLARATION node; isExported = hook ?? false → false for BOTH |
| 558 | // dialects (luau's slice sees `local …`). |
| 559 | let docstring = preceding_docstring(node, self.src); |
| 560 | let is_exported = self.is_exported_of(node).unwrap_or(false); |
| 561 | |
| 562 | let mut cursor = node.walk(); |
| 563 | let assign = node |
| 564 | .named_children(&mut cursor) |
| 565 | .find(|c| c.kind() == "assignment_statement") |
| 566 | .unwrap_or(node); |
| 567 | let mut ac = assign.walk(); |
| 568 | let var_list = assign.named_children(&mut ac).find(|c| c.kind() == "variable_list"); |
| 569 | let mut ec = assign.walk(); |
| 570 | let expr_list = assign.named_children(&mut ec).find(|c| c.kind() == "expression_list"); |
| 571 | let values: Vec<Node<'t>> = match expr_list { |
| 572 | Some(el) => { |
| 573 | let mut c = el.walk(); |
| 574 | el.named_children(&mut c).collect() |
| 575 | } |
| 576 | None => Vec::new(), |
| 577 | }; |
| 578 | let names: Vec<Node<'t>> = match var_list { |
| 579 | Some(vl) => { |
| 580 | let mut c = vl.walk(); |
| 581 | vl.named_children(&mut c).filter(|n| n.kind() == "identifier").collect() |
| 582 | } |
| 583 | None => Vec::new(), |
| 584 | }; |
| 585 | for (i, name_node) in names.iter().enumerate() { |
| 586 | let name = self.text(*name_node); |
| 587 | if name.is_empty() { |
| 588 | continue; |
| 589 | } |
| 590 | // Positional value pairing; a missing value → NO signature key. |
| 591 | let signature = values.get(i).map(|v| util::init_signature(self.text(*v))); |
| 592 | let name = name.to_string(); |
| 593 | self.create_node( |
| 594 | "variable", |
| 595 | &name, |
| 596 | *name_node, // positioned at the IDENTIFIER |
| 597 | Extra { |
| 598 | docstring: docstring.clone(), |
| 599 | signature, |
| 600 | is_exported: Some(is_exported), |
| 601 | ..Default::default() |
| 602 | }, |
| 603 | ); |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | // --- extractTypeAlias (2890; plain path 2967-2991) — luau only -------- |
| 608 |
no test coverage detected