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

Method visitCallConditional

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

Source from the content-addressed store, hash-verified

218}
219
220func (un *unparser) visitCallConditional(expr ast.Expr) error {
221 c := expr.AsCall()
222 args := c.Args()
223 // add parens if operand is a conditional itself.
224 nested := isSamePrecedence(operators.Conditional, args[0]) ||
225 isComplexOperator(args[0])
226 err := un.visitMaybeNested(args[0], nested)
227 if err != nil {
228 return err
229 }
230 un.writeOperatorWithWrapping(operators.Conditional, "?")
231
232 // add parens if operand is a conditional itself.
233 nested = isSamePrecedence(operators.Conditional, args[1]) ||
234 isComplexOperator(args[1])
235 err = un.visitMaybeNested(args[1], nested)
236 if err != nil {
237 return err
238 }
239
240 un.str.WriteString(" : ")
241 // add parens if operand is a conditional itself.
242 nested = isSamePrecedence(operators.Conditional, args[2]) ||
243 isComplexOperator(args[2])
244
245 return un.visitMaybeNested(args[2], nested)
246}
247
248func (un *unparser) visitCallFunc(expr ast.Expr) error {
249 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