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

Method visit

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

Source from the content-addressed store, hash-verified

596 // --- the main walk (visitNode, tree-sitter.ts:936-1303) ---------------
597
598 fn visit(&mut self, node: Node<'t>) {
599 // The visitNode hook (dart.ts:144-157) — the constants branch.
600 if node.kind() == "static_final_declaration" {
601 let mut cursor = node.walk();
602 let name_node = node.named_children(&mut cursor).find(|c| c.kind() == "identifier");
603 if let Some(name_node) = name_node {
604 // signature = first value sibling's text, sliced to 100
605 // UTF-16 units (a flattened chain captures just its head).
606 let signature = name_node.next_named_sibling().map(|v| {
607 let (sliced, _) = util::slice_utf16(self.text(v), 100);
608 if util::utf16_len(&sliced) >= 100 {
609 format!("= {sliced}...")
610 } else {
611 format!("= {sliced}")
612 }
613 });
614 let name = self.text(name_node).to_string();
615 self.create_node("constant", &name, node, Extra { signature, ..Default::default() });
616 }
617 self.scan_fn_ref_subtree(node, 0);
618 return;
619 }
620
621 // maybeCaptureFnRefs (:990) — the double-walk fn-ref twin source.
622 self.maybe_capture_fn_refs(node);
623
624 match node.kind() {
625 "function_signature" => {
626 // functionTypes row — method_signature does NOT include it →
627 // always extractFunction, even inside a class (abstract
628 // members become kind `function` contained by the class).
629 self.extract_function(node);
630 return;
631 }
632 "class_definition" | "mixin_declaration" | "extension_declaration" => {
633 self.extract_class(node);
634 return;
635 }
636 "method_signature" | "constructor_signature" => {
637 self.extract_method(node);
638 return;
639 }
640 "enum_declaration" => {
641 self.extract_enum(node);
642 return;
643 }
644 "type_alias" => {
645 let skip = self.extract_type_alias(node);
646 if skip {
647 return;
648 }
649 }
650 "import_or_export" => {
651 self.extract_import(node);
652 return;
653 }
654 "new_expression" => {
655 // INSTANTIATION_KINDS row — from the FILE/CLASS on the

Callers 3

extractFunction · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45

Calls 14

slice_utf16Function · 0.85
utf16_lenFunction · 0.85
textMethod · 0.45
create_nodeMethod · 0.45
scan_fn_ref_subtreeMethod · 0.45
maybe_capture_fn_refsMethod · 0.45
extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_methodMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45
extract_importMethod · 0.45

Tested by

no test coverage detected