MCPcopy Create free account
hub / github.com/apache/fory / formatMethodSignature

Function formatMethodSignature

go/fory/codegen/guard.go:158–196  ·  view source on GitHub ↗
(name string, sig *types.Signature)

Source from the content-addressed store, hash-verified

156}
157
158func formatMethodSignature(name string, sig *types.Signature) string {
159 var params, results []string
160
161 // Format parameters
162 if sig.Params() != nil {
163 for i := 0; i < sig.Params().Len(); i++ {
164 param := sig.Params().At(i)
165 paramStr := formatGoType(param.Type())
166 if param.Name() != "" {
167 paramStr = param.Name() + " " + paramStr
168 }
169 params = append(params, paramStr)
170 }
171 }
172
173 // Format results
174 if sig.Results() != nil {
175 for i := 0; i < sig.Results().Len(); i++ {
176 result := sig.Results().At(i)
177 resultStr := formatGoType(result.Type())
178 if result.Name() != "" {
179 resultStr = result.Name() + " " + resultStr
180 }
181 results = append(results, resultStr)
182 }
183 }
184
185 paramStr := strings.Join(params, ", ")
186 resultStr := strings.Join(results, ", ")
187
188 if len(results) > 1 {
189 resultStr = "(" + resultStr + ")"
190 }
191
192 if resultStr != "" {
193 return fmt.Sprintf("%s(%s) %s", name, paramStr, resultStr)
194 }
195 return fmt.Sprintf("%s(%s)", name, paramStr)
196}

Callers 1

formatGoTypeFunction · 0.85

Calls 3

formatGoTypeFunction · 0.85
LenMethod · 0.80
TypeMethod · 0.45

Tested by

no test coverage detected