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

Function formatOperator

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

Source from the content-addressed store, hash-verified

1185}
1186
1187func formatOperator(opName string, o *OverloadDecl) string {
1188 args := o.ArgTypes()
1189 argTypes := make([]string, len(o.ArgTypes()))
1190 for j, a := range args {
1191 argTypes[j] = describeCELType(a)
1192 }
1193 ret := describeCELType(o.ResultType())
1194 switch len(args) {
1195 case 1:
1196 return fmt.Sprintf("%s%s -> %s", opName, argTypes[0], ret)
1197 case 2:
1198 if opName == operators.Index {
1199 return fmt.Sprintf("%s[%s] -> %s", argTypes[0], argTypes[1], ret)
1200 }
1201 return fmt.Sprintf("%s %s %s -> %s", argTypes[0], opName, argTypes[1], ret)
1202 default:
1203 if opName == operators.Conditional {
1204 return fmt.Sprint("bool ? <T> : <T> -> <T>")
1205 }
1206 return formatCall(opName, o)
1207 }
1208}
1209
1210func formatCall(funcName string, o *OverloadDecl) string {
1211 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