extractVariable's python branch: `left = right` at module scope.
(&mut self, node: Node<'t>)
| 464 | |
| 465 | /// extractVariable's python branch: `left = right` at module scope. |
| 466 | fn extract_variable(&mut self, node: Node<'t>) { |
| 467 | let docstring = preceding_docstring(node, self.src); |
| 468 | let left = node.child_by_field_name("left").or_else(|| node.named_child(0)); |
| 469 | let right = node.child_by_field_name("right").or_else(|| node.named_child(1)); |
| 470 | let Some(left) = left else { return }; |
| 471 | if !matches!(left.kind(), "identifier" | "constant") { |
| 472 | return; |
| 473 | } |
| 474 | let name = self.text(left).to_string(); |
| 475 | let signature = right.map(|r| util::init_signature(self.text(r))); |
| 476 | // No isConst hook ⇒ always `variable` (UPPER_CASE constants included). |
| 477 | self.create_node("variable", &name, node, Extra { docstring, signature, ..Extra::default() }); |
| 478 | } |
| 479 | |
| 480 | fn extract_import(&mut self, node: Node<'t>) { |
| 481 | let import_text = self.text(node).trim().to_string(); |
no test coverage detected