extractVariable's generic fallback (top-level locals — rare in Java).
(&mut self, node: Node<'t>)
| 811 | |
| 812 | /// extractVariable's generic fallback (top-level locals — rare in Java). |
| 813 | fn extract_variable(&mut self, node: Node<'t>) { |
| 814 | let kind: &'static str = if self.is_const(node) { "constant" } else { "variable" }; |
| 815 | let docstring = preceding_docstring(node, self.src); |
| 816 | for child in node.named_children(&mut node.walk()) { |
| 817 | let name = match child.kind() { |
| 818 | "identifier" => self.text(child).to_string(), |
| 819 | "variable_declarator" => self.extract_name(child), |
| 820 | _ => continue, |
| 821 | }; |
| 822 | if name.is_empty() || name == "<anonymous>" { |
| 823 | continue; |
| 824 | } |
| 825 | self.create_node( |
| 826 | kind, |
| 827 | &name, |
| 828 | child, |
| 829 | Extra { docstring: docstring.clone(), ..Extra::default() }, |
| 830 | ); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | fn extract_import(&mut self, node: Node<'t>) { |
| 835 | let import_text = self.text(node).trim().to_string(); |
no test coverage detected