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

Method extract_class

codegraph-kernel/src/tsjs/extractors.rs:494–523  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

492 // --- extractClass ------------------------------------------------------------
493
494 pub(super) fn extract_class(&mut self, node: Node<'t>) {
495 let resolved_body = body_of(node); // skipBodilessClass unset for TS/JS
496 let name = self.extract_name(node);
497 // A class expression's name is bound inside the expression alone:
498 // never exported by it, and its head is its signature, which a
499 // declaration lacks (#2499). Mirrors TreeSitterExtractor.extractClass.
500 let expression = node.kind() == "class";
501 let extra = Extra {
502 docstring: crate::docstring::preceding_docstring(node, self.src),
503 visibility: self.visibility_of(node),
504 is_exported: Some(!expression && self.is_exported(node)),
505 signature: if expression { resolved_body.map(|body| class_expression_head(self.src, node, body)) } else { None },
506 ..Extra::default()
507 };
508 let Some(row) = self.create_node("class", &name, node, extra) else {
509 return;
510 };
511
512 self.extract_inheritance(node, row);
513 self.extract_decorators_for(node, row);
514
515 self.stack.push(Scope { row, kind: "class", name });
516 let body = resolved_body.unwrap_or(node);
517 for i in 0..body.named_child_count() {
518 if let Some(c) = body.named_child(i) {
519 self.visit_node(c);
520 }
521 }
522 self.stack.pop();
523 }
524
525 // --- extractMethod -------------------------------------------------------------
526

Callers 2

visit_nodeMethod · 0.45

Calls 12

body_ofFunction · 0.85
preceding_docstringFunction · 0.85
class_expression_headFunction · 0.85
mapMethod · 0.80
pushMethod · 0.80
extract_nameMethod · 0.45
visibility_ofMethod · 0.45
is_exportedMethod · 0.45
create_nodeMethod · 0.45
extract_inheritanceMethod · 0.45
visit_nodeMethod · 0.45

Tested by

no test coverage detected