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

Method extract_class

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

Source from the content-addressed store, hash-verified

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

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