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

Method extract_class

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

Source from the content-addressed store, hash-verified

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

Callers 2

visit_nodeMethod · 0.45

Calls 13

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
walkMethod · 0.45

Tested by

no test coverage detected