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

Method build_method_signature

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

Build method signature

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

Source from the content-addressed store, hash-verified

1141
1142 /// Build method signature
1143 fn build_method_signature(&self, node: &Node, source: &str) -> String {
1144 let name = node
1145 .child_by_field_name("name")
1146 .and_then(|n| self.node_text(&n, source))
1147 .unwrap_or_default();
1148
1149 // Get parameters
1150 let params = node
1151 .child_by_field_name("parameters")
1152 .map(|p| self.node_text(&p, source).unwrap_or_default())
1153 .unwrap_or_else(|| "()".to_string());
1154
1155 // Get return type
1156 let return_type = node
1157 .child_by_field_name("return_type")
1158 .map(|r| self.node_text(&r, source).unwrap_or_default())
1159 .unwrap_or_default();
1160
1161 // Check for async/static modifiers
1162 let mut modifiers = Vec::new();
1163 for i in 0..node.child_count() {
1164 if let Some(child) = node.child(i) {
1165 match child.kind() {
1166 "async" => modifiers.push("async"),
1167 "static" => modifiers.push("static"),
1168 "readonly" => modifiers.push("readonly"),
1169 "accessibility_modifier" => {
1170 if let Some(text) = self.node_text(&child, source) {
1171 modifiers.push(if text == "public" {
1172 "public"
1173 } else if text == "private" {
1174 "private"
1175 } else {
1176 "protected"
1177 });
1178 }
1179 }
1180 _ => {}
1181 }
1182 }
1183 }
1184
1185 let modifier_str = if modifiers.is_empty() {
1186 String::new()
1187 } else {
1188 format!("{} ", modifiers.join(" "))
1189 };
1190
1191 format!("{}{}{}{}", modifier_str, name, params, return_type)
1192 }
1193
1194 /// Build type alias signature
1195 fn build_type_alias_signature(&self, node: &Node, source: &str) -> String {

Callers 1

extract_methodMethod · 0.45

Calls 5

child_countMethod · 0.80
node_textMethod · 0.45
kindMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected