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