Extract the name for an impl block. For `impl User { ... }` → "User" For `impl Display for User { ... }` → "User"
(&self, node: &Node, source: &str)
| 260 | /// For `impl User { ... }` → "User" |
| 261 | /// For `impl Display for User { ... }` → "User" |
| 262 | fn extract_impl_name(&self, node: &Node, source: &str) -> Option<String> { |
| 263 | // Try `type` field first (the implementing type) |
| 264 | if let Some(type_node) = node.child_by_field_name("type") { |
| 265 | return Some(self.node_text(&type_node, source)); |
| 266 | } |
| 267 | |
| 268 | // Fallback: walk children looking for a type identifier |
| 269 | let mut cursor = node.walk(); |
| 270 | for child in node.children(&mut cursor) { |
| 271 | if child.kind() == "type_identifier" || child.kind() == "generic_type" { |
| 272 | return Some(self.node_text(&child, source)); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | None |
| 277 | } |
| 278 | |
| 279 | /// Extract a type alias. |
| 280 | fn extract_type_alias(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |