Build method signature
(&self, node: &Node, source: &str)
| 1113 | |
| 1114 | /// Build method signature |
| 1115 | fn build_method_signature(&self, node: &Node, source: &str) -> String { |
| 1116 | let name = node |
| 1117 | .child_by_field_name("name") |
| 1118 | .and_then(|n| self.node_text(&n, source)) |
| 1119 | .unwrap_or_default(); |
| 1120 | |
| 1121 | // Get parameters |
| 1122 | let params = node |
| 1123 | .child_by_field_name("parameters") |
| 1124 | .map(|p| self.node_text(&p, source).unwrap_or_default()) |
| 1125 | .unwrap_or_else(|| "()".to_string()); |
| 1126 | |
| 1127 | // Get return type |
| 1128 | let return_type = node |
| 1129 | .child_by_field_name("return_type") |
| 1130 | .map(|r| self.node_text(&r, source).unwrap_or_default()) |
| 1131 | .unwrap_or_default(); |
| 1132 | |
| 1133 | // Check for async/static modifiers |
| 1134 | let mut modifiers = Vec::new(); |
| 1135 | for i in 0..node.child_count() { |
| 1136 | if let Some(child) = node.child(i) { |
| 1137 | match child.kind() { |
| 1138 | "async" => modifiers.push("async"), |
| 1139 | "static" => modifiers.push("static"), |
| 1140 | "readonly" => modifiers.push("readonly"), |
| 1141 | "accessibility_modifier" => { |
| 1142 | if let Some(text) = self.node_text(&child, source) { |
| 1143 | modifiers.push(if text == "public" { |
| 1144 | "public" |
| 1145 | } else if text == "private" { |
| 1146 | "private" |
| 1147 | } else { |
| 1148 | "protected" |
| 1149 | }); |
| 1150 | } |
| 1151 | } |
| 1152 | _ => {} |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | |
| 1157 | let modifier_str = if modifiers.is_empty() { |
| 1158 | String::new() |
| 1159 | } else { |
| 1160 | format!("{} ", modifiers.join(" ")) |
| 1161 | }; |
| 1162 | |
| 1163 | format!("{}{}{}{}", modifier_str, name, params, return_type) |
| 1164 | } |
| 1165 | |
| 1166 | /// Build type alias signature |
| 1167 | fn build_type_alias_signature(&self, node: &Node, source: &str) -> String { |
no test coverage detected