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