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

Method visit_node

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

Source from the content-addressed store, hash-verified

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

Callers 4

extractFunction · 0.45
extract_interfaceMethod · 0.45
extract_structMethod · 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_structMethod · 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