(expr ast.Expr)
| 182 | } |
| 183 | |
| 184 | func (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 | |
| 212 | func (un *unparser) visitCallFunc(expr ast.Expr) error { |
| 213 | c := expr.AsCall() |
no test coverage detected