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

Method extract_class

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected