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

Method build_method_signature

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

Build method signature

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

Source from the content-addressed store, hash-verified

1096
1097 /// Build method signature
1098 fn build_method_signature(&self, node: &Node, source: &str) -> String {
1099 let name = node
1100 .child_by_field_name("name")
1101 .and_then(|n| self.node_text(&n, source))
1102 .unwrap_or_default();
1103
1104 // Get parameters
1105 let params = node
1106 .child_by_field_name("parameters")
1107 .map(|p| self.node_text(&p, source).unwrap_or_default())
1108 .unwrap_or_else(|| "()".to_string());
1109
1110 // Get return type
1111 let return_type = node
1112 .child_by_field_name("return_type")
1113 .map(|r| self.node_text(&r, source).unwrap_or_default())
1114 .unwrap_or_default();
1115
1116 // Check for async/static modifiers
1117 let mut modifiers = Vec::new();
1118 for i in 0..node.child_count() {
1119 if let Some(child) = node.child(i) {
1120 match child.kind() {
1121 "async" => modifiers.push("async"),
1122 "static" => modifiers.push("static"),
1123 "readonly" => modifiers.push("readonly"),
1124 "accessibility_modifier" => {
1125 if let Some(text) = self.node_text(&child, source) {
1126 modifiers.push(if text == "public" {
1127 "public"
1128 } else if text == "private" {
1129 "private"
1130 } else {
1131 "protected"
1132 });
1133 }
1134 }
1135 _ => {}
1136 }
1137 }
1138 }
1139
1140 let modifier_str = if modifiers.is_empty() {
1141 String::new()
1142 } else {
1143 format!("{} ", modifiers.join(" "))
1144 };
1145
1146 format!("{}{}{}{}", modifier_str, name, params, return_type)
1147 }
1148
1149 /// Build type alias signature
1150 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