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

Method extract_include

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

Extract a `#include` directive.

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

Source from the content-addressed store, hash-verified

617
618 /// Extract a `#include` directive.
619 fn extract_include(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
620 let line = node.start_position().row as u32 + 1;
621 let end_line = node.end_position().row as u32 + 1;
622
623 let path_node = node.child_by_field_name("path")?;
624 let path_text = self.node_text(&path_node, source);
625
626 // Strip quotes/angle brackets for the name
627 let name = path_text
628 .trim_matches(|c| c == '"' || c == '<' || c == '>')
629 .to_string();
630
631 if name.is_empty() {
632 return None;
633 }
634
635 let sig_text = self.node_text(node, source);
636 let signature = sig_text.lines().next().unwrap_or("").trim().to_string();
637
638 let mut entity = Entity::new(name, EntityKind::Import, file_path, line, end_line);
639 entity = entity.with_signature(signature);
640
641 Some(entity)
642 }
643
644 /// Extract a `#define` directive.
645 fn extract_define(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {

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