Extract a reference from a member expression (property access)
(
&self,
node: &Node,
source: &str,
file_path: &str,
seen: &mut HashSet<(String, u32)>,
)
| 299 | |
| 300 | /// Extract a reference from a member expression (property access) |
| 301 | fn extract_member_reference( |
| 302 | &self, |
| 303 | node: &Node, |
| 304 | source: &str, |
| 305 | file_path: &str, |
| 306 | seen: &mut HashSet<(String, u32)>, |
| 307 | ) -> Option<Reference> { |
| 308 | // Skip if parent is a call expression (we'll handle that separately) |
| 309 | if let Some(parent) = node.parent() { |
| 310 | if parent.kind() == "call_expression" { |
| 311 | return None; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | let property = node.child_by_field_name("property")?; |
| 316 | let symbol = property.utf8_text(source.as_bytes()).ok()?.to_string(); |
| 317 | let line = node.start_position().row as u32 + 1; |
| 318 | |
| 319 | // Skip common properties |
| 320 | if matches!( |
| 321 | symbol.as_str(), |
| 322 | "length" |
| 323 | | "size" |
| 324 | | "prototype" |
| 325 | | "constructor" |
| 326 | | "name" |
| 327 | | "message" |
| 328 | | "stack" |
| 329 | | "code" |
| 330 | | "data" |
| 331 | | "error" |
| 332 | | "success" |
| 333 | | "result" |
| 334 | | "value" |
| 335 | | "key" |
| 336 | | "id" |
| 337 | | "type" |
| 338 | | "status" |
| 339 | ) { |
| 340 | return None; |
| 341 | } |
| 342 | |
| 343 | let key = (symbol.clone(), line); |
| 344 | if seen.contains(&key) { |
| 345 | return None; |
| 346 | } |
| 347 | seen.insert(key); |
| 348 | |
| 349 | let context = source |
| 350 | .lines() |
| 351 | .nth(node.start_position().row) |
| 352 | .map(|s| s.trim().to_string()); |
| 353 | |
| 354 | Some(Reference { |
| 355 | symbol, |
| 356 | file: file_path.to_string(), |
| 357 | line, |
| 358 | column: Some(property.start_position().column as u32), |