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

Method extract_define

atomic-semantic/src/parsers/cpp.rs:645–664  ·  view source on GitHub ↗

Extract a `#define` directive.

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

Source from the content-addressed store, hash-verified

643
644 /// Extract a `#define` directive.
645 fn extract_define(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
646 let name_node = node.child_by_field_name("name")?;
647 let name = self.node_text(&name_node, source);
648
649 if name.is_empty() {
650 return None;
651 }
652
653 let line = node.start_position().row as u32 + 1;
654 let end_line = node.end_position().row as u32 + 1;
655
656 let sig_text = self.node_text(node, source);
657 let signature = sig_text.lines().next().unwrap_or("").trim().to_string();
658
659 let mut entity = Entity::new(name, EntityKind::Const, file_path, line, end_line);
660 entity = entity.with_signature(signature);
661 entity.exported = true;
662
663 Some(entity)
664 }
665
666 // ── Signature builders ──────────────────────────────────────────
667

Callers 1

walk_treeMethod · 0.80

Calls 5

with_signatureMethod · 0.80
node_textMethod · 0.45
is_emptyMethod · 0.45
nextMethod · 0.45
linesMethod · 0.45

Tested by

no test coverage detected