in format.go [312:337]
func (un *formatter) visitCallBinary(expr ast.Expr) error {
c := expr.AsCall()
fun := c.FunctionName()
args := c.Args()
lhs := args[0]
// add parens if the current operator is lower precedence than the lhs expr operator.
lhsParen := isComplexOperatorWithRespectTo(fun, lhs)
rhs := args[1]
// add parens if the current operator is lower precedence than the rhs expr operator,
// or the same precedence and the operator is left recursive.
rhsParen := isComplexOperatorWithRespectTo(fun, rhs)
if !rhsParen && isLeftRecursive(fun) {
rhsParen = isSamePrecedence(fun, rhs)
}
err := un.visitMaybeNested(lhs, lhsParen)
if err != nil {
return err
}
unmangled, found := operators.FindReverseBinaryOperator(fun)
if !found {
return fmt.Errorf("cannot unmangle operator: %s", fun)
}
un.writeOperatorWithWrapping(fun, unmangled)
return un.visitMaybeNested(rhs, rhsParen)
}