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

Method extract_const

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

Extract a const item.

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

Source from the content-addressed store, hash-verified

300
301 /// Extract a const item.
302 fn extract_const(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
303 let name_node = node.child_by_field_name("name")?;
304 let name = self.node_text(&name_node, source);
305
306 let line = node.start_position().row as u32 + 1;
307 let end_line = node.end_position().row as u32 + 1;
308 let exported = self.is_pub(node);
309
310 let sig = self.first_line(node, source);
311
312 let mut entity = Entity::new(name, EntityKind::Const, file_path, line, end_line);
313 if let Some(s) = sig {
314 entity = entity.with_signature(s);
315 }
316 if exported {
317 entity.exported = true;
318 }
319
320 Some(entity)
321 }
322
323 /// Extract a static item.
324 fn extract_static(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {

Callers 1

walk_treeMethod · 0.80

Calls 4

is_pubMethod · 0.80
first_lineMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected