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

Method extract_module

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

923
924 /// Extract a module/namespace declaration
925 fn extract_module(
926 &self,
927 node: &Node,
928 source: &str,
929 file_path: &str,
930 exported: bool,
931 ) -> Option<Entity> {
932 let name_node = node.child_by_field_name("name")?;
933 let name = self.node_text(&name_node, source)?;
934
935 let signature = format!("namespace {}", name);
936
937 Some(
938 Entity::new(
939 name,
940 EntityKind::Module,
941 file_path,
942 node.start_position().row as u32 + 1,
943 node.end_position().row as u32 + 1,
944 )
945 .with_column(node.start_position().column as u32)
946 .with_signature(signature)
947 .with_exported(exported),
948 )
949 }
950
951 // =========================================================================
952 // 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