(expr ast.Expr)
| 218 | } |
| 219 | |
| 220 | func (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 | |
| 248 | func (un *unparser) visitCallFunc(expr ast.Expr) error { |
| 249 | c := expr.AsCall() |
no test coverage detected