Build arrow function signature
(&self, name: &str, node: &Node, source: &str)
| 1010 | |
| 1011 | /// Build arrow function signature |
| 1012 | fn build_arrow_function_signature(&self, name: &str, node: &Node, source: &str) -> String { |
| 1013 | // Get parameters |
| 1014 | let params = node |
| 1015 | .child_by_field_name("parameters") |
| 1016 | .or_else(|| node.child_by_field_name("parameter")) |
| 1017 | .map(|p| self.node_text(&p, source).unwrap_or_default()) |
| 1018 | .unwrap_or_else(|| "()".to_string()); |
| 1019 | |
| 1020 | // Get return type if present |
| 1021 | let return_type = node |
| 1022 | .child_by_field_name("return_type") |
| 1023 | .map(|r| self.node_text(&r, source).unwrap_or_default()) |
| 1024 | .unwrap_or_default(); |
| 1025 | |
| 1026 | if return_type.is_empty() { |
| 1027 | format!("const {} = {} => ...", name, params) |
| 1028 | } else { |
| 1029 | format!("const {} = {}{} => ...", name, params, return_type) |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | /// Build const signature |
| 1034 | fn build_const_signature(&self, declarator: &Node, source: &str) -> String { |
no test coverage detected