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

Method build_arrow_function_signature

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

Build arrow function signature

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

Source from the content-addressed store, hash-verified

965
966 /// Build arrow function signature
967 fn build_arrow_function_signature(&self, name: &str, node: &Node, source: &str) -> String {
968 // Get parameters
969 let params = node
970 .child_by_field_name("parameters")
971 .or_else(|| node.child_by_field_name("parameter"))
972 .map(|p| self.node_text(&p, source).unwrap_or_default())
973 .unwrap_or_else(|| "()".to_string());
974
975 // Get return type if present
976 let return_type = node
977 .child_by_field_name("return_type")
978 .map(|r| self.node_text(&r, source).unwrap_or_default())
979 .unwrap_or_default();
980
981 if return_type.is_empty() {
982 format!("const {} = {} => ...", name, params)
983 } else {
984 format!("const {} = {}{} => ...", name, params, return_type)
985 }
986 }
987
988 /// Build const signature
989 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