(expr ast.Expr)
| 155 | } |
| 156 | |
| 157 | func (un *unparser) visitCallBinary(expr ast.Expr) error { |
| 158 | c := expr.AsCall() |
| 159 | fun := c.FunctionName() |
| 160 | args := c.Args() |
| 161 | lhs := args[0] |
| 162 | // add parens if the current operator is lower precedence than the lhs expr operator. |
| 163 | lhsParen := isComplexOperatorWithRespectTo(fun, lhs) |
| 164 | rhs := args[1] |
| 165 | // add parens if the current operator is lower precedence than the rhs expr operator, |
| 166 | // or the same precedence and the operator is left recursive. |
| 167 | rhsParen := isComplexOperatorWithRespectTo(fun, rhs) |
| 168 | if !rhsParen && isLeftRecursive(fun) { |
| 169 | rhsParen = isSamePrecedence(fun, rhs) |
| 170 | } |
| 171 | err := un.visitMaybeNested(lhs, lhsParen) |
| 172 | if err != nil { |
| 173 | return err |
| 174 | } |
| 175 | unmangled, found := operators.FindReverseBinaryOperator(fun) |
| 176 | if !found { |
| 177 | return fmt.Errorf("cannot unmangle operator: %s", fun) |
| 178 | } |
| 179 | |
| 180 | un.writeOperatorWithWrapping(fun, unmangled) |
| 181 | return un.visitMaybeNested(rhs, rhsParen) |
| 182 | } |
| 183 | |
| 184 | func (un *unparser) visitCallConditional(expr ast.Expr) error { |
| 185 | c := expr.AsCall() |
no test coverage detected