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

Method extract_trait

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

Extract a trait definition.

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

Source from the content-addressed store, hash-verified

235
236 /// Extract a trait definition.
237 fn extract_trait(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
238 let name_node = node.child_by_field_name("name")?;
239 let name = self.node_text(&name_node, source);
240
241 let line = node.start_position().row as u32 + 1;
242 let end_line = node.end_position().row as u32 + 1;
243 let exported = self.is_pub(node);
244
245 let signature = self.build_trait_signature(node, source);
246
247 let mut entity = Entity::new(name, EntityKind::Interface, file_path, line, end_line);
248 if let Some(sig) = signature {
249 entity = entity.with_signature(sig);
250 }
251 if exported {
252 entity.exported = true;
253 }
254
255 Some(entity)
256 }
257
258 /// Extract the name for an impl block.
259 ///

Callers 1

walk_treeMethod · 0.80

Calls 4

is_pubMethod · 0.80
build_trait_signatureMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected