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

Method visit

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

Source from the content-addressed store, hash-verified

529 // --- the main walk (visitNode, tree-sitter.ts:936-1303) ---------------
530
531 fn visit(&mut self, node: Node<'t>) {
532 // The visitNode hook (scala.ts:131-198) runs FIRST.
533 if self.hook(node) {
534 self.scan_fn_ref_subtree(node, 0);
535 return;
536 }
537
538 // maybeCaptureFnRefs (:990).
539 self.maybe_capture_fn_refs(node);
540
541 let kind = node.kind();
542 match kind {
543 // methodTypes (functionTypes is EMPTY — :994 never fires).
544 "function_definition" | "function_declaration" => {
545 self.extract_method_or_function(node);
546 return; // skipChildren
547 }
548 "class_definition" | "object_definition" => {
549 self.extract_class(node, "class");
550 return;
551 }
552 "trait_definition" => {
553 self.extract_class(node, "trait");
554 return;
555 }
556 "enum_definition" => {
557 self.extract_enum(node);
558 return;
559 }
560 "type_definition" => {
561 let skip = self.extract_type_alias(node);
562 if skip {
563 return;
564 }
565 // plain path → false → children re-visited (nothing matches).
566 }
567 "import_declaration" => {
568 self.extract_import(node);
569 return; // skipChildren
570 }
571 "call_expression" => {
572 self.extract_call(node);
573 // no skipChildren — chains/args re-visited
574 }
575 "instance_expression" => {
576 // INSTANTIATION_KINDS (:1255). findAnonymousClassBody looks
577 // for class_body/declaration_list — scala's template_body is
578 // neither → extractAnonymousClass never runs → children
579 // recursed: anon-body defs LEAK to the enclosing scope.
580 self.extract_instantiation(node);
581 }
582 _ => {}
583 }
584
585 let mut cursor = node.walk();
586 let children: Vec<Node<'t>> = node.named_children(&mut cursor).collect();
587 for child in children {
588 self.visit(child);

Callers 4

extractFunction · 0.45
hookMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45

Calls 11

hookMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45
maybe_capture_fn_refsMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45
extract_importMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected