Extract a use declaration.
(&self, node: &Node, source: &str, file_path: &str)
| 361 | |
| 362 | /// Extract a use declaration. |
| 363 | fn extract_use(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
| 364 | let line = node.start_position().row as u32 + 1; |
| 365 | let end_line = node.end_position().row as u32 + 1; |
| 366 | |
| 367 | let text = self.node_text(node, source); |
| 368 | |
| 369 | // Extract the path from `use std::io::Read;` |
| 370 | let name = text |
| 371 | .strip_prefix("pub ") |
| 372 | .unwrap_or(&text) |
| 373 | .strip_prefix("use ") |
| 374 | .unwrap_or(&text) |
| 375 | .trim_end_matches(';') |
| 376 | .to_string(); |
| 377 | |
| 378 | let mut entity = Entity::new(name, EntityKind::Import, file_path, line, end_line); |
| 379 | entity = entity.with_signature(text); |
| 380 | |
| 381 | Some(entity) |
| 382 | } |
| 383 | |
| 384 | // ── Signature builders ────────────────────────────────────────── |
| 385 |
no test coverage detected