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

Method extract_module

atomic-semantic/src/parser.rs:953–977  ·  view source on GitHub ↗

Extract a module/namespace declaration

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

Source from the content-addressed store, hash-verified

951
952 /// Extract a module/namespace declaration
953 fn extract_module(
954 &self,
955 node: &Node,
956 source: &str,
957 file_path: &str,
958 exported: bool,
959 ) -> Option<Entity> {
960 let name_node = node.child_by_field_name("name")?;
961 let name = self.node_text(&name_node, source)?;
962
963 let signature = format!("namespace {}", name);
964
965 Some(
966 Entity::new(
967 name,
968 EntityKind::Module,
969 file_path,
970 node.start_position().row as u32 + 1,
971 node.end_position().row as u32 + 1,
972 )
973 .with_column(node.start_position().column as u32)
974 .with_signature(signature)
975 .with_exported(exported),
976 )
977 }
978
979 // =========================================================================
980 // Helper methods for building signatures

Callers 1

walk_treeMethod · 0.80

Calls 4

with_exportedMethod · 0.80
with_columnMethod · 0.80
node_textMethod · 0.45
with_signatureMethod · 0.45

Tested by

no test coverage detected