Extract a reference from a call expression
(
&self,
node: &Node,
source: &str,
file_path: &str,
seen: &mut HashSet<(String, u32)>,
)
| 145 | |
| 146 | /// Extract a reference from a call expression |
| 147 | fn extract_call_reference( |
| 148 | &self, |
| 149 | node: &Node, |
| 150 | source: &str, |
| 151 | file_path: &str, |
| 152 | seen: &mut HashSet<(String, u32)>, |
| 153 | ) -> Option<Reference> { |
| 154 | // Get the function being called |
| 155 | let function_node = node.child_by_field_name("function")?; |
| 156 | let line = node.start_position().row as u32 + 1; |
| 157 | |
| 158 | let symbol = match function_node.kind() { |
| 159 | "identifier" => { |
| 160 | // Direct call: foo() |
| 161 | function_node.utf8_text(source.as_bytes()).ok()?.to_string() |
| 162 | } |
| 163 | "member_expression" => { |
| 164 | // Method call: obj.method() |
| 165 | let property = function_node.child_by_field_name("property")?; |
| 166 | property.utf8_text(source.as_bytes()).ok()?.to_string() |
| 167 | } |
| 168 | _ => return None, |
| 169 | }; |
| 170 | |
| 171 | // Skip common built-ins |
| 172 | if matches!( |
| 173 | symbol.as_str(), |
| 174 | "console" |
| 175 | | "log" |
| 176 | | "error" |
| 177 | | "warn" |
| 178 | | "info" |
| 179 | | "debug" |
| 180 | | "toString" |
| 181 | | "valueOf" |
| 182 | | "push" |
| 183 | | "pop" |
| 184 | | "map" |
| 185 | | "filter" |
| 186 | | "reduce" |
| 187 | | "forEach" |
| 188 | | "find" |
| 189 | | "some" |
| 190 | | "every" |
| 191 | | "slice" |
| 192 | | "splice" |
| 193 | | "join" |
| 194 | | "split" |
| 195 | | "trim" |
| 196 | | "toLowerCase" |
| 197 | | "toUpperCase" |
| 198 | | "includes" |
| 199 | | "indexOf" |
| 200 | | "charAt" |
| 201 | | "substring" |
| 202 | | "replace" |
| 203 | | "match" |
| 204 | | "test" |