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

Method extract_class

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

Source from the content-addressed store, hash-verified

431 }
432
433 fn extract_class(&mut self, node: Node<'t>) {
434 let name = self.extract_name(node);
435 let extra = Extra {
436 docstring: preceding_docstring(node, self.src),
437 ..Extra::default()
438 };
439 let Some(row) = self.create_node("class", &name, node, extra) else { return };
440
441 // Inheritance: `class Flask(Scaffold, Mixin):` — argument_list children.
442 let extends_kind = edge_kind_index("extends").unwrap();
443 for i in 0..node.named_child_count() {
444 let Some(child) = node.named_child(i) else { continue };
445 if child.kind() == "argument_list" {
446 for j in 0..child.named_child_count() {
447 let Some(arg) = child.named_child(j) else { continue };
448 if matches!(arg.kind(), "identifier" | "attribute") {
449 let name = self.text(arg).to_string();
450 self.push_ref_at(row, &name, extends_kind, arg);
451 }
452 }
453 }
454 }
455 self.extract_decorators_for(node, row);
456
457 self.stack.push(Scope { row, kind: "class", name });
458 let body = node.child_by_field_name("body").unwrap_or(node);
459 for i in 0..body.named_child_count() {
460 if let Some(c) = body.named_child(i) {
461 self.visit_node(c);
462 }
463 }
464 self.stack.pop();
465 }
466
467 /// extractVariable's python branch: `left = right` at module scope.
468 fn extract_variable(&mut self, node: Node<'t>) {

Callers 2

visit_nodeMethod · 0.45

Calls 9

preceding_docstringFunction · 0.85
edge_kind_indexFunction · 0.85
unwrapMethod · 0.60
extract_nameMethod · 0.45
create_nodeMethod · 0.45
textMethod · 0.45
push_ref_atMethod · 0.45
visit_nodeMethod · 0.45

Tested by

no test coverage detected