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

Method walk_tree_for_references

atomic-semantic/src/parser.rs:99–168  ·  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

97
98 /// Walk the AST and extract references (function calls, identifier usages)
99 fn walk_tree_for_references(
100 &self,
101 node: &Node,
102 source: &str,
103 file_path: &str,
104 references: &mut Vec<Reference>,
105 seen: &mut HashSet<(String, u32)>,
106 ) {
107 match node.kind() {
108 // Function calls: foo(), obj.method(), etc.
109 "call_expression" => {
110 if let Some(reference) = self.extract_call_reference(node, source, file_path, seen)
111 {
112 references.push(reference);
113 }
114 }
115
116 // Member expressions: obj.property
117 "member_expression" => {
118 if let Some(reference) =
119 self.extract_member_reference(node, source, file_path, seen)
120 {
121 references.push(reference);
122 }
123 }
124
125 // Identifier usages (variables, type references)
126 "identifier" => {
127 // Skip if parent is a declaration (we want usages, not definitions)
128 if let Some(parent) = node.parent() {
129 let parent_kind = parent.kind();
130 // Skip identifiers that are part of declarations
131 if !matches!(
132 parent_kind,
133 "function_declaration"
134 | "class_declaration"
135 | "interface_declaration"
136 | "type_alias_declaration"
137 | "variable_declarator"
138 | "method_definition"
139 | "property_signature"
140 | "import_specifier"
141 | "import_clause"
142 ) {
143 if let Some(reference) =
144 self.extract_identifier_reference(node, source, file_path, seen)
145 {
146 references.push(reference);
147 }
148 }
149 }
150 }
151
152 // Type references: User, AuthToken, etc.
153 "type_identifier" => {
154 if let Some(reference) = self.extract_type_reference(node, source, file_path, seen)
155 {
156 references.push(reference);

Callers 1

Calls 9

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

Tested by

no test coverage detected