MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extract_class

Method extract_class

codegraph-kernel/src/ruby.rs:668–703  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

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

Callers 2

visit_nodeMethod · 0.45

Calls 10

preceding_docstringFunction · 0.85
edge_kind_indexFunction · 0.85
pushMethod · 0.80
textMethod · 0.65
unwrapMethod · 0.60
extract_nameMethod · 0.45
visibility_ofMethod · 0.45
create_nodeMethod · 0.45
push_ref_atMethod · 0.45
visit_nodeMethod · 0.45

Tested by

no test coverage detected