Extract an import declaration.
(&self, node: &Node, source: &str, file_path: &str)
| 401 | |
| 402 | /// Extract an import declaration. |
| 403 | fn extract_import(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
| 404 | let line = node.start_position().row as u32 + 1; |
| 405 | let end_line = node.end_position().row as u32 + 1; |
| 406 | |
| 407 | let text = self.node_text(node, source); |
| 408 | |
| 409 | // Extract the imported path: `import java.util.List;` → `java.util.List` |
| 410 | let name = text |
| 411 | .strip_prefix("import ") |
| 412 | .unwrap_or(&text) |
| 413 | .strip_prefix("static ") |
| 414 | .unwrap_or(&text) |
| 415 | .trim() |
| 416 | .trim_end_matches(';') |
| 417 | .trim() |
| 418 | .to_string(); |
| 419 | |
| 420 | let mut entity = Entity::new(name, EntityKind::Import, file_path, line, end_line); |
| 421 | entity = entity.with_signature(text.trim_end_matches(';').trim().to_string()); |
| 422 | |
| 423 | Some(entity) |
| 424 | } |
| 425 | |
| 426 | // ── Signature builders ────────────────────────────────────────── |
| 427 |
no test coverage detected