MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / walk_tree

Method walk_tree

atomic-semantic/src/parser.rs:545–628  ·  view source on GitHub ↗

Walk the AST and extract entities

(
        &self,
        node: &Node,
        source: &str,
        file_path: &str,
        entities: &mut Vec<Entity>,
        in_export: bool,
    )

Source from the content-addressed store, hash-verified

543
544 /// Walk the AST and extract entities
545 fn walk_tree(
546 &self,
547 node: &Node,
548 source: &str,
549 file_path: &str,
550 entities: &mut Vec<Entity>,
551 in_export: bool,
552 ) {
553 // Check if this node is an export statement
554 let is_export = node.kind() == "export_statement";
555 let child_in_export = in_export || is_export;
556
557 match node.kind() {
558 // Function declarations
559 "function_declaration" => {
560 if let Some(entity) =
561 self.extract_function(node, source, file_path, child_in_export)
562 {
563 entities.push(entity);
564 }
565 }
566
567 // Arrow functions assigned to variables (const foo = () => {})
568 "lexical_declaration" | "variable_declaration" => {
569 entities.extend(self.extract_variable_declarations(
570 node,
571 source,
572 file_path,
573 child_in_export,
574 ));
575 }
576
577 // Class declarations
578 "class_declaration" => {
579 if let Some(entity) = self.extract_class(node, source, file_path, child_in_export) {
580 entities.push(entity);
581 }
582 // Also extract methods from the class
583 self.extract_class_members(node, source, file_path, entities);
584 }
585
586 // Interface declarations (TypeScript)
587 "interface_declaration" => {
588 if let Some(entity) =
589 self.extract_interface(node, source, file_path, child_in_export)
590 {
591 entities.push(entity);
592 }
593 }
594
595 // Type alias declarations (TypeScript)
596 "type_alias_declaration" => {
597 if let Some(entity) =
598 self.extract_type_alias(node, source, file_path, child_in_export)
599 {
600 entities.push(entity);
601 }
602 }

Callers 1

extractMethod · 0.45

Calls 12

extendMethod · 0.80
extract_class_membersMethod · 0.80
extract_moduleMethod · 0.80
child_countMethod · 0.80
kindMethod · 0.45
extract_functionMethod · 0.45
pushMethod · 0.45
extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_type_aliasMethod · 0.45
extract_enumMethod · 0.45

Tested by

no test coverage detected