MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / extract_impl_name

Method extract_impl_name

atomic-semantic/src/parsers/rust.rs:262–277  ·  view source on GitHub ↗

Extract the name for an impl block. For `impl User { ... }` → "User" For `impl Display for User { ... }` → "User"

(&self, node: &Node, source: &str)

Source from the content-addressed store, hash-verified

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> {

Callers 1

walk_treeMethod · 0.80

Calls 4

walkMethod · 0.80
childrenMethod · 0.80
node_textMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected