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

Method extract_function

atomic-semantic/src/parsers/go.rs:87–108  ·  view source on GitHub ↗

Extract a package-level function declaration.

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

Source from the content-addressed store, hash-verified

85
86 /// Extract a package-level function declaration.
87 fn extract_function(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
88 let name_node = node.child_by_field_name("name")?;
89 let name = self.node_text(&name_node, source);
90
91 let line = node.start_position().row as u32 + 1;
92 let end_line = node.end_position().row as u32 + 1;
93
94 // In Go, exported = starts with uppercase letter
95 let exported = name.starts_with(|c: char| c.is_uppercase());
96
97 let signature = self.build_function_signature(node, source);
98
99 let mut entity = Entity::new(name, EntityKind::Function, file_path, line, end_line);
100 if let Some(sig) = signature {
101 entity = entity.with_signature(sig);
102 }
103 if exported {
104 entity.exported = true;
105 }
106
107 Some(entity)
108 }
109
110 /// Extract a method declaration (function with receiver).
111 fn extract_method(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {

Callers 1

walk_treeMethod · 0.45

Calls 3

with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected