(&mut self, node: Node<'t>)
| 668 | } |
| 669 | |
| 670 | fn extract_class(&mut self, node: Node<'t>) { |
| 671 | stack_guard!(); |
| 672 | let name = self.extract_name(node); |
| 673 | let extra = Extra { |
| 674 | docstring: preceding_docstring(node, self.src), |
| 675 | signature: None, |
| 676 | visibility: Some(self.visibility_of(node)), |
| 677 | ..Extra::default() |
| 678 | }; |
| 679 | let Some(row) = self.create_node("class", &name, node, extra) else { return }; |
| 680 | |
| 681 | // extractInheritance: the `superclass` clause — ONE extends ref, FULL |
| 682 | // text (scope_resolution / even `Struct.new(:a)` expressions verbatim), |
| 683 | // positioned at the type child. |
| 684 | let extends_kind = edge_kind_index("extends").unwrap(); |
| 685 | for i in 0..node.named_child_count() { |
| 686 | let Some(child) = node.named_child(i) else { continue }; |
| 687 | if child.kind() == "superclass" { |
| 688 | if let Some(target) = child.named_child(0) { |
| 689 | let tname = self.text(target).to_string(); |
| 690 | self.push_ref_at(row, &tname, extends_kind, target); |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | self.stack.push(Scope { row, kind: "class", name }); |
| 696 | // Bodiless `class X; end` has no body field → the class node itself |
| 697 | // is walked (name/superclass children revisit harmlessly). |
| 698 | let body = node.child_by_field_name("body").unwrap_or(node); |
| 699 | for i in 0..body.named_child_count() { |
| 700 | if let Some(c) = body.named_child(i) { |
| 701 | self.visit_node(c); |
| 702 | } |
| 703 | } |
| 704 | self.stack.pop(); |
| 705 | } |
| 706 | |
| 707 | /// extractVariable — the python/ruby assignment branch (2709-2727): |
| 708 | /// identifier or constant LHS mints a `variable` node (no isConst hook — |
no test coverage detected