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

Method extract_struct

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

Extract a struct definition.

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

Source from the content-addressed store, hash-verified

196
197 /// Extract a struct definition.
198 fn extract_struct(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
199 let name_node = node.child_by_field_name("name")?;
200 let name = self.node_text(&name_node, source);
201
202 let line = node.start_position().row as u32 + 1;
203 let end_line = node.end_position().row as u32 + 1;
204 let exported = self.is_pub(node);
205
206 let signature = self.build_struct_signature(node, source);
207
208 let mut entity = Entity::new(name, EntityKind::Class, file_path, line, end_line);
209 if let Some(sig) = signature {
210 entity = entity.with_signature(sig);
211 }
212 if exported {
213 entity.exported = true;
214 }
215
216 Some(entity)
217 }
218
219 /// Extract an enum definition.
220 fn extract_enum(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {

Callers 1

walk_treeMethod · 0.45

Calls 4

is_pubMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected