extractVariable's generic fallback: kind is ALWAYS `variable` (no isConst hook), every direct `identifier` child mints a node positioned at the CHILD, docstring shared, isExported present-false, no signature. The initializer is walked under the declared symbol (#693), and returned then for the declaration scan to skip.
(&mut self, node: Node<'t>)
| 717 | /// The initializer is walked under the declared symbol (#693), and returned |
| 718 | /// then for the declaration scan to skip. |
| 719 | fn extract_variable(&mut self, node: Node<'t>) -> Vec<usize> { |
| 720 | let docstring = preceding_docstring(node, self.src); |
| 721 | let name_field = node.child_by_field_name("name"); |
| 722 | // An impl's associated const is its type's (`Limits::MAX`), as its methods are. |
| 723 | let owner = self.impl_item_owner(node); |
| 724 | let mut declared: Option<(u32, String)> = None; |
| 725 | for child in node.named_children(&mut node.walk()) { |
| 726 | if child.kind() != "identifier" { |
| 727 | continue; |
| 728 | } |
| 729 | let name = self.text(child).to_string(); |
| 730 | if !name.is_empty() { |
| 731 | let row = self.create_node( |
| 732 | "variable", |
| 733 | &name, |
| 734 | child, |
| 735 | Extra { |
| 736 | docstring: docstring.clone(), |
| 737 | is_exported: Some(false), |
| 738 | qualified_name: owner.as_ref().map(|o| format!("{o}::{name}")), |
| 739 | ..Extra::default() |
| 740 | }, |
| 741 | ); |
| 742 | if let (Some(row), Some(nf)) = (row, name_field) { |
| 743 | if child.start_byte() == nf.start_byte() { |
| 744 | declared = Some((row, name)); |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | // Walk the initializer ATTRIBUTED to the declared symbol (#693): |
| 750 | // `const N: usize = compute()` and |
| 751 | // `static REGISTRY: Lazy<T> = Lazy::new(|| build())` dropped every call |
| 752 | // inside the initializer, so a handler table or a lazily-built |
| 753 | // singleton linked to nothing. |
| 754 | let mut walked = Vec::new(); |
| 755 | if let Some(value) = node.child_by_field_name("value") { |
| 756 | match declared { |
| 757 | Some((row, name)) => { |
| 758 | self.stack.push(Scope { row, kind: "variable", name }); |
| 759 | self.visit_function_body(value); |
| 760 | self.stack.pop(); |
| 761 | walked.push(value.id()); |
| 762 | } |
| 763 | None => self.visit_function_body(value), |
| 764 | } |
| 765 | } |
| 766 | walked |
| 767 | } |
| 768 | |
| 769 | /// extractImport via the rust hook: import node named by the ROOT module + |
| 770 | /// one generic root `imports` ref + per-binding FULL-path refs. |
no test coverage detected