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

Method visitCallConditional

parser/unparser.go:184–210  ·  view source on GitHub ↗
(expr ast.Expr)

Source from the content-addressed store, hash-verified

182}
183
184func (un *unparser) visitCallConditional(expr ast.Expr) error {
185 c := expr.AsCall()
186 args := c.Args()
187 // add parens if operand is a conditional itself.
188 nested := isSamePrecedence(operators.Conditional, args[0]) ||
189 isComplexOperator(args[0])
190 err := un.visitMaybeNested(args[0], nested)
191 if err != nil {
192 return err
193 }
194 un.writeOperatorWithWrapping(operators.Conditional, "?")
195
196 // add parens if operand is a conditional itself.
197 nested = isSamePrecedence(operators.Conditional, args[1]) ||
198 isComplexOperator(args[1])
199 err = un.visitMaybeNested(args[1], nested)
200 if err != nil {
201 return err
202 }
203
204 un.str.WriteString(" : ")
205 // add parens if operand is a conditional itself.
206 nested = isSamePrecedence(operators.Conditional, args[2]) ||
207 isComplexOperator(args[2])
208
209 return un.visitMaybeNested(args[2], nested)
210}
211
212func (un *unparser) visitCallFunc(expr ast.Expr) error {
213 c := expr.AsCall()

Callers 1

visitCallMethod · 0.95

Calls 6

visitMaybeNestedMethod · 0.95
isSamePrecedenceFunction · 0.85
isComplexOperatorFunction · 0.85
AsCallMethod · 0.65
ArgsMethod · 0.65

Tested by

no test coverage detected