writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured in the unparser options.
(fun string, unmangled string)
| 539 | // writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured |
| 540 | // in the unparser options. |
| 541 | func (un *unparser) writeOperatorWithWrapping(fun string, unmangled string) bool { |
| 542 | _, wrapOperatorExists := un.options.operatorsToWrapOn[fun] |
| 543 | lineLength := un.str.Len() - un.lastWrappedIndex + len(fun) |
| 544 | |
| 545 | if wrapOperatorExists && lineLength >= un.options.wrapOnColumn { |
| 546 | un.lastWrappedIndex = un.str.Len() |
| 547 | // wrapAfterColumnLimit flag dictates whether the newline is placed |
| 548 | // before or after the operator |
| 549 | if un.options.wrapAfterColumnLimit { |
| 550 | // Input: a && b |
| 551 | // Output: a &&\nb |
| 552 | un.str.WriteString(" ") |
| 553 | un.str.WriteString(unmangled) |
| 554 | un.str.WriteString("\n") |
| 555 | } else { |
| 556 | // Input: a && b |
| 557 | // Output: a\n&& b |
| 558 | un.str.WriteString("\n") |
| 559 | un.str.WriteString(unmangled) |
| 560 | un.str.WriteString(" ") |
| 561 | } |
| 562 | return true |
| 563 | } |
| 564 | un.str.WriteString(" ") |
| 565 | un.str.WriteString(unmangled) |
| 566 | un.str.WriteString(" ") |
| 567 | return false |
| 568 | } |
| 569 | |
| 570 | // Defined defaults for the unparser options |
| 571 | var ( |
no test coverage detected