MCPcopy Create free account
hub / github.com/cel-expr/cel-go / formatOperator

Function formatOperator

common/decls/decls.go:1275–1296  ·  view source on GitHub ↗
(opName string, o *OverloadDecl)

Source from the content-addressed store, hash-verified

1273}
1274
1275func formatOperator(opName string, o *OverloadDecl) string {
1276 args := o.ArgTypes()
1277 argTypes := make([]string, len(o.ArgTypes()))
1278 for j, a := range args {
1279 argTypes[j] = describeCELType(a)
1280 }
1281 ret := describeCELType(o.ResultType())
1282 switch len(args) {
1283 case 1:
1284 return fmt.Sprintf("%s%s -> %s", opName, argTypes[0], ret)
1285 case 2:
1286 if opName == operators.Index {
1287 return fmt.Sprintf("%s[%s] -> %s", argTypes[0], argTypes[1], ret)
1288 }
1289 return fmt.Sprintf("%s %s %s -> %s", argTypes[0], opName, argTypes[1], ret)
1290 default:
1291 if opName == operators.Conditional {
1292 return fmt.Sprint("bool ? <T> : <T> -> <T>")
1293 }
1294 return formatCall(opName, o)
1295 }
1296}
1297
1298func formatCall(funcName string, o *OverloadDecl) string {
1299 args := make([]string, len(o.ArgTypes()))

Callers 1

formatSignatureFunction · 0.85

Calls 4

describeCELTypeFunction · 0.85
formatCallFunction · 0.85
ArgTypesMethod · 0.80
ResultTypeMethod · 0.45

Tested by

no test coverage detected