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

Method visit_node

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

Source from the content-addressed store, hash-verified

452 // --- the dispatcher (visitNode, Ruby-relevant branches) ----------------------
453
454 fn visit_node(&mut self, node: Node<'t>) {
455 stack_guard!();
456 // Language hook FIRST (tree-sitter.ts:943) — a handled subtree is
457 // scanned for fn-ref candidates and never reaches the ladder (or the
458 // maybeCaptureFnRefs call below).
459 if self.try_visit_hook(node) {
460 self.scan_fn_ref_subtree(node, 0);
461 return;
462 }
463
464 let kind = node.kind();
465 let mut skip_children = false;
466
467 self.maybe_capture_fn_refs(node);
468
469 if kind == "method" {
470 // functionTypes ∩ methodTypes: inside class-like (module counts!)
471 // ⇒ method, else function.
472 if self.inside_class_like() {
473 self.extract_method(node);
474 } else {
475 self.extract_function(node);
476 }
477 skip_children = true;
478 } else if kind == "class" {
479 self.extract_class(node);
480 skip_children = true;
481 } else if kind == "singleton_method" {
482 // methodTypes-only: extractMethod's 1747 gate bounces a top-level
483 // `def self.x` to extractFunction — a plain function named x (the
484 // receiver object is ignored everywhere).
485 if self.inside_class_like() {
486 self.extract_method(node);
487 } else {
488 self.extract_function(node);
489 }
490 skip_children = true;
491 } else if kind == "assignment"
492 && (!self.inside_class_like() || self.is_class_scope_constant_assignment(node))
493 {
494 // File scope: identifier AND constant LHS extract; class/module
495 // scope: ONLY constant LHS (isClassScopeConstantAssignment). The
496 // RHS is never walked (no instantiates/calls from initializers).
497 self.extract_variable(node);
498 self.scan_fn_ref_subtree(node, 0);
499 skip_children = true;
500 } else if kind == "call" {
501 // importTypes:['call'] — EVERY non-body call funnels here. Only
502 // require/require_relative-with-string emit; everything else is
503 // invisible (children still visited: no skipChildren).
504 self.extract_import(node);
505 }
506 // `singleton_class` (`class << self`), `alias`, top-level `if`/`begin`,
507 // `uninterpreted`, operator_assignment: no branch — recursed.
508
509 if !skip_children {
510 for i in 0..node.named_child_count() {
511 if let Some(c) = node.named_child(i) {

Callers 3

extractFunction · 0.45
try_visit_hookMethod · 0.45
extract_classMethod · 0.45

Calls 10

try_visit_hookMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45
maybe_capture_fn_refsMethod · 0.45
inside_class_likeMethod · 0.45
extract_methodMethod · 0.45
extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_variableMethod · 0.45
extract_importMethod · 0.45

Tested by

no test coverage detected