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

Method visit_node

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

Source from the content-addressed store, hash-verified

440 // --- visitNode ------------------------------------------------------------
441
442 fn visit_node(&mut self, node: Node<'t>) {
443 stack_guard!();
444 let kind = node.kind();
445 let mut skip_children = false;
446
447 self.maybe_capture_fn_refs(node);
448
449 if matches!(kind, "function_item" | "function_signature_item") {
450 self.extract_fn_or_method(node);
451 skip_children = true;
452 } else if kind == "trait_item" {
453 self.extract_interface(node);
454 skip_children = true;
455 } else if kind == "struct_item" {
456 self.extract_aggregate(node, "struct");
457 skip_children = true;
458 } else if kind == "union_item" {
459 self.extract_aggregate(node, "union");
460 skip_children = true;
461 } else if kind == "enum_item" {
462 self.extract_enum(node);
463 skip_children = true;
464 } else if kind == "type_item" {
465 self.extract_type_alias(node);
466 // extractTypeAlias returns false for rust (plain alias) — children
467 // are visited (nothing in them has a branch).
468 } else if matches!(kind, "let_declaration" | "const_item" | "static_item")
469 && !self.inside_class_like()
470 {
471 // Inside a class-like scope the gate fails and the else-ladder
472 // falls through with children VISITED — a trait const's value
473 // expression emits calls refs from the trait node.
474 self.extract_variable(node);
475 self.scan_fn_ref_subtree(node, 0);
476 skip_children = true;
477 } else if kind == "use_declaration" {
478 self.extract_import(node);
479 // importTypes branch never sets skipChildren.
480 } else if kind == "call_expression" {
481 self.extract_call(node);
482 } else if kind == "struct_expression" {
483 self.extract_instantiation(node);
484 } else if kind == "impl_item" {
485 // Emits the implements back-reference; skipChildren stays false so
486 // the declaration_list is visited at FILE scope (impl pushes
487 // nothing on the stack).
488 self.extract_rust_impl_item(node);
489 }
490
491 if !skip_children {
492 for i in 0..node.named_child_count() {
493 if let Some(c) = node.named_child(i) {
494 self.visit_node(c);
495 }
496 }
497 }
498 }
499

Callers 4

extractFunction · 0.45
extract_interfaceMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45

Calls 13

extract_fn_or_methodMethod · 0.80
maybe_capture_fn_refsMethod · 0.45
extract_interfaceMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45
inside_class_likeMethod · 0.45
extract_variableMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45
extract_importMethod · 0.45
extract_callMethod · 0.45

Tested by

no test coverage detected