extractVariable's generic fallback (top-level locals — rare in Java).
(&mut self, node: Node<'t>)
| 781 | |
| 782 | /// extractVariable's generic fallback (top-level locals — rare in Java). |
| 783 | fn extract_variable(&mut self, node: Node<'t>) { |
| 784 | let kind: &'static str = if self.is_const(node) { "constant" } else { "variable" }; |
| 785 | let docstring = preceding_docstring(node, self.src); |
| 786 | for i in 0..node.named_child_count() { |
| 787 | let Some(child) = node.named_child(i) else { continue }; |
| 788 | let name = match child.kind() { |
| 789 | "identifier" => self.text(child).to_string(), |
| 790 | "variable_declarator" => self.extract_name(child), |
| 791 | _ => continue, |
| 792 | }; |
| 793 | if name.is_empty() || name == "<anonymous>" { |
| 794 | continue; |
| 795 | } |
| 796 | self.create_node( |
| 797 | kind, |
| 798 | &name, |
| 799 | child, |
| 800 | Extra { docstring: docstring.clone(), ..Extra::default() }, |
| 801 | ); |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | fn extract_import(&mut self, node: Node<'t>) { |
| 806 | let import_text = self.text(node).trim().to_string(); |
no test coverage detected