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

Method extract_class

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

Source from the content-addressed store, hash-verified

396 // --- extractClass ------------------------------------------------------------
397
398 pub(super) fn extract_class(&mut self, node: Node<'t>) {
399 let resolved_body = body_of(node); // skipBodilessClass unset for TS/JS
400 let name = self.extract_name(node);
401 // A class expression's name is bound inside the expression alone:
402 // never exported by it, and its head is its signature, which a
403 // declaration lacks (#2499). Mirrors TreeSitterExtractor.extractClass.
404 let expression = node.kind() == "class";
405 let extra = Extra {
406 docstring: crate::docstring::preceding_docstring(node, self.src),
407 visibility: self.visibility_of(node),
408 is_exported: Some(!expression && self.is_exported(node)),
409 signature: if expression { resolved_body.map(|body| class_expression_head(self.src, node, body)) } else { None },
410 ..Extra::default()
411 };
412 let Some(row) = self.create_node("class", &name, node, extra) else {
413 return;
414 };
415
416 self.extract_inheritance(node, row);
417 self.extract_decorators_for(node, row);
418
419 self.stack.push(Scope { row, kind: "class", name });
420 let body = resolved_body.unwrap_or(node);
421 for i in 0..body.named_child_count() {
422 if let Some(c) = body.named_child(i) {
423 self.visit_node(c);
424 }
425 }
426 self.stack.pop();
427 }
428
429 // --- extractMethod -------------------------------------------------------------
430

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