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