(&mut self, node: Node<'t>)
| 531 | } |
| 532 | |
| 533 | fn extract_class(&mut self, node: Node<'t>) { |
| 534 | stack_guard!(); |
| 535 | let name = self.extract_name(node); |
| 536 | let extra = Extra { |
| 537 | docstring: docstring_for(node, self.src), |
| 538 | ..Extra::default() |
| 539 | }; |
| 540 | let Some(row) = self.create_node("class", &name, node, extra) else { return }; |
| 541 | |
| 542 | // Inheritance: `class Flask(Scaffold, Mixin):` — argument_list children. |
| 543 | // A parameterized base, `class Leaf(Base[str])`, is a `subscript` |
| 544 | // whose value names the class. |
| 545 | let extends_kind = edge_kind_index("extends").unwrap(); |
| 546 | for i in 0..node.named_child_count() { |
| 547 | let Some(child) = node.named_child(i) else { continue }; |
| 548 | if child.kind() == "argument_list" { |
| 549 | for j in 0..child.named_child_count() { |
| 550 | let Some(base) = child.named_child(j) else { continue }; |
| 551 | let arg = if base.kind() == "subscript" { |
| 552 | let Some(value) = base.child_by_field_name("value") else { continue }; |
| 553 | value |
| 554 | } else { |
| 555 | base |
| 556 | }; |
| 557 | if matches!(arg.kind(), "identifier" | "attribute") { |
| 558 | let name = self.text(arg).to_string(); |
| 559 | self.push_ref_at(row, &name, extends_kind, arg); |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | self.extract_decorators_for(node, row); |
| 565 | |
| 566 | self.stack.push(Scope { row, kind: "class", name }); |
| 567 | let body = node.child_by_field_name("body").unwrap_or(node); |
| 568 | for i in 0..body.named_child_count() { |
| 569 | if let Some(c) = body.named_child(i) { |
| 570 | self.visit_node(c); |
| 571 | } |
| 572 | } |
| 573 | self.stack.pop(); |
| 574 | } |
| 575 | |
| 576 | /// extractVariable's python branch: `left = right` at module scope. |
| 577 | /// Returns the right-hand side when it was walked under the assigned |
no test coverage detected