Lines 741-747
public:
Link Here
|
741 |
LineFormatter(ContinuationIndenter *Indenter, WhitespaceManager *Whitespaces, |
741 |
LineFormatter(ContinuationIndenter *Indenter, WhitespaceManager *Whitespaces, |
742 |
const FormatStyle &Style, |
742 |
const FormatStyle &Style, |
743 |
UnwrappedLineFormatter *BlockFormatter) |
743 |
UnwrappedLineFormatter *BlockFormatter) |
744 |
: Indenter(Indenter), Whitespaces(Whitespaces), Style(Style), |
744 |
: Indenter(Indenter), Style(Style), Whitespaces(Whitespaces), |
745 |
BlockFormatter(BlockFormatter) {} |
745 |
BlockFormatter(BlockFormatter) {} |
746 |
virtual ~LineFormatter() {} |
746 |
virtual ~LineFormatter() {} |
747 |
|
747 |
|
Lines 782-788
protected:
Link Here
|
782 |
// assert so that we can simply call this function for all tokens. |
782 |
// assert so that we can simply call this function for all tokens. |
783 |
return true; |
783 |
return true; |
784 |
|
784 |
|
785 |
if (NewLine) { |
785 |
if (NewLine || (Previous.Children[0]->First->MustBreakBefore && |
|
|
786 |
Style.KeepLineBreaksForNonEmptyLines)) { |
786 |
int AdditionalIndent = State.Stack.back().Indent - |
787 |
int AdditionalIndent = State.Stack.back().Indent - |
787 |
Previous.Children[0]->Level * Style.IndentWidth; |
788 |
Previous.Children[0]->Level * Style.IndentWidth; |
788 |
|
789 |
|
Lines 827-836
protected:
Link Here
|
827 |
} |
828 |
} |
828 |
|
829 |
|
829 |
ContinuationIndenter *Indenter; |
830 |
ContinuationIndenter *Indenter; |
|
|
831 |
const FormatStyle &Style; |
830 |
|
832 |
|
831 |
private: |
833 |
private: |
832 |
WhitespaceManager *Whitespaces; |
834 |
WhitespaceManager *Whitespaces; |
833 |
const FormatStyle &Style; |
|
|
834 |
UnwrappedLineFormatter *BlockFormatter; |
835 |
UnwrappedLineFormatter *BlockFormatter; |
835 |
}; |
836 |
}; |
836 |
|
837 |
|
Lines 853-859
public:
Link Here
|
853 |
while (State.NextToken) { |
854 |
while (State.NextToken) { |
854 |
bool Newline = |
855 |
bool Newline = |
855 |
Indenter->mustBreak(State) || |
856 |
Indenter->mustBreak(State) || |
856 |
(Indenter->canBreak(State) && State.NextToken->NewlinesBefore > 0); |
857 |
(State.NextToken->NewlinesBefore > 0 && Indenter->canBreak(State)); |
857 |
unsigned Penalty = 0; |
858 |
unsigned Penalty = 0; |
858 |
formatChildren(State, Newline, /*DryRun=*/false, Penalty); |
859 |
formatChildren(State, Newline, /*DryRun=*/false, Penalty); |
859 |
Indenter->addTokenToState(State, Newline, /*DryRun=*/false); |
860 |
Indenter->addTokenToState(State, Newline, /*DryRun=*/false); |