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

Method build_arrow_function_signature

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

Build arrow function signature

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

Source from the content-addressed store, hash-verified

982
983 /// Build arrow function signature
984 fn build_arrow_function_signature(&self, name: &str, node: &Node, source: &str) -> String {
985 // Get parameters
986 let params = node
987 .child_by_field_name("parameters")
988 .or_else(|| node.child_by_field_name("parameter"))
989 .map(|p| self.node_text(&p, source).unwrap_or_default())
990 .unwrap_or_else(|| "()".to_string());
991
992 // Get return type if present
993 let return_type = node
994 .child_by_field_name("return_type")
995 .map(|r| self.node_text(&r, source).unwrap_or_default())
996 .unwrap_or_default();
997
998 if return_type.is_empty() {
999 format!("const {} = {} => ...", name, params)
1000 } else {
1001 format!("const {} = {}{} => ...", name, params, return_type)
1002 }
1003 }
1004
1005 /// Build const signature
1006 fn build_const_signature(&self, declarator: &Node, source: &str) -> String {

Callers 1

Calls 2

node_textMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected