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

Method visit

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

Source from the content-addressed store, hash-verified

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

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