writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured in the unparser options.
(fun string, unmangled string)
| 601 | // writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured |
| 602 | // in the unparser options. |
| 603 | func (un *unparser) writeOperatorWithWrapping(fun string, unmangled string) bool { |
| 604 | _, wrapOperatorExists := un.options.operatorsToWrapOn[fun] |
| 605 | lineLength := un.str.Len() - un.lastWrappedIndex + len(fun) |
| 606 | |
| 607 | if wrapOperatorExists && lineLength >= un.options.wrapOnColumn { |
| 608 | un.lastWrappedIndex = un.str.Len() |
| 609 | // wrapAfterColumnLimit flag dictates whether the newline is placed |
| 610 | // before or after the operator |
| 611 | if un.options.wrapAfterColumnLimit { |
| 612 | // Input: a && b |
| 613 | // Output: a &&\nb |
| 614 | un.str.WriteString(" ") |
| 615 | un.str.WriteString(unmangled) |
| 616 | un.str.WriteString("\n") |
| 617 | } else { |
| 618 | // Input: a && b |
| 619 | // Output: a\n&& b |
| 620 | un.str.WriteString("\n") |
| 621 | un.str.WriteString(unmangled) |
| 622 | un.str.WriteString(" ") |
| 623 | } |
| 624 | return true |
| 625 | } |
| 626 | un.str.WriteString(" ") |
| 627 | un.str.WriteString(unmangled) |
| 628 | un.str.WriteString(" ") |
| 629 | return false |
| 630 | } |
| 631 | |
| 632 | // Defined defaults for the unparser options |
| 633 | var ( |
no test coverage detected