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

Function formatOperator

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

Source from the content-addressed store, hash-verified

1089}
1090
1091func formatOperator(opName string, o *OverloadDecl) string {
1092 args := o.ArgTypes()
1093 argTypes := make([]string, len(o.ArgTypes()))
1094 for j, a := range args {
1095 argTypes[j] = describeCELType(a)
1096 }
1097 ret := describeCELType(o.ResultType())
1098 switch len(args) {
1099 case 1:
1100 return fmt.Sprintf("%s%s -> %s", opName, argTypes[0], ret)
1101 case 2:
1102 if opName == operators.Index {
1103 return fmt.Sprintf("%s[%s] -> %s", argTypes[0], argTypes[1], ret)
1104 }
1105 return fmt.Sprintf("%s %s %s -> %s", argTypes[0], opName, argTypes[1], ret)
1106 default:
1107 if opName == operators.Conditional {
1108 return fmt.Sprint("bool ? <T> : <T> -> <T>")
1109 }
1110 return formatCall(opName, o)
1111 }
1112}
1113
1114func formatCall(funcName string, o *OverloadDecl) string {
1115 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