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

Method walk_tree_for_references

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

Walk the AST and extract references (function calls, identifier usages)

(
        &self,
        node: &Node,
        source: &str,
        file_path: &str,
        references: &mut Vec<Reference>,
        seen: &mut HashSet<(String, u32)>,
    )

Source from the content-addressed store, hash-verified

73
74 /// Walk the AST and extract references (function calls, identifier usages)
75 fn walk_tree_for_references(
76 &self,
77 node: &Node,
78 source: &str,
79 file_path: &str,
80 references: &mut Vec<Reference>,
81 seen: &mut HashSet<(String, u32)>,
82 ) {
83 match node.kind() {
84 // Function calls: foo(), obj.method(), etc.
85 "call_expression" => {
86 if let Some(reference) = self.extract_call_reference(node, source, file_path, seen)
87 {
88 references.push(reference);
89 }
90 }
91
92 // Member expressions: obj.property
93 "member_expression" => {
94 if let Some(reference) =
95 self.extract_member_reference(node, source, file_path, seen)
96 {
97 references.push(reference);
98 }
99 }
100
101 // Identifier usages (variables, type references)
102 "identifier" => {
103 // Skip if parent is a declaration (we want usages, not definitions)
104 if let Some(parent) = node.parent() {
105 let parent_kind = parent.kind();
106 // Skip identifiers that are part of declarations
107 if !matches!(
108 parent_kind,
109 "function_declaration"
110 | "class_declaration"
111 | "interface_declaration"
112 | "type_alias_declaration"
113 | "variable_declarator"
114 | "method_definition"
115 | "property_signature"
116 | "import_specifier"
117 | "import_clause"
118 ) {
119 if let Some(reference) =
120 self.extract_identifier_reference(node, source, file_path, seen)
121 {
122 references.push(reference);
123 }
124 }
125 }
126 }
127
128 // Type references: User, AuthToken, etc.
129 "type_identifier" => {
130 if let Some(reference) = self.extract_type_reference(node, source, file_path, seen)
131 {
132 references.push(reference);

Callers 1

extract_referencesMethod · 0.80

Calls 9

parentMethod · 0.80
walkMethod · 0.80
childrenMethod · 0.80
kindMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected