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

Method extract_module

atomic-semantic/src/parser.rs:908–932  ·  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

906
907 /// Extract a module/namespace declaration
908 fn extract_module(
909 &self,
910 node: &Node,
911 source: &str,
912 file_path: &str,
913 exported: bool,
914 ) -> Option<Entity> {
915 let name_node = node.child_by_field_name("name")?;
916 let name = self.node_text(&name_node, source)?;
917
918 let signature = format!("namespace {}", name);
919
920 Some(
921 Entity::new(
922 name,
923 EntityKind::Module,
924 file_path,
925 node.start_position().row as u32 + 1,
926 node.end_position().row as u32 + 1,
927 )
928 .with_column(node.start_position().column as u32)
929 .with_signature(signature)
930 .with_exported(exported),
931 )
932 }
933
934 // =========================================================================
935 // Helper methods for building signatures

Callers 1

walk_treeMethod · 0.80

Calls 4

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

Tested by

no test coverage detected