Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ void writeFooterJavadocTagStart(FooterJavadocTagStart token) {
*/
postWriteModifiedContinuingListStack.reset();

if (!wroteAnythingSignificant) {
// Javadoc consists solely of tags. This is frowned upon in general but OK for @Overrides.
} else if (!continuingFooterTag) {
if (!continuingFooterTag) {
// First footer tag after a body tag.
requestBlankLine();
} else {
Expand Down Expand Up @@ -234,9 +232,7 @@ void writeListItemOpen(ListItemOpenTag token) {
}

void writeHeaderOpen(HeaderOpenTag token) {
if (wroteAnythingSignificant) {
requestBlankLine();
}
requestBlankLine();

writeToken(token);
}
Expand All @@ -262,29 +258,23 @@ void writeParagraphOpen(Token token) {
}

void writeBlockquoteOpen(BlockquoteOpenTag token) {
if (wroteAnythingSignificant) {
requestBlankLine();
}
requestBlankLine();

writeToken(token);

requestNewline();
}

void writeBlockquoteClose(BlockquoteCloseTag token) {
if (wroteAnythingSignificant) {
requestNewline();
}
requestNewline();

writeToken(token);

requestBlankLine();
}

void writePreOpen(PreOpenTag token) {
if (wroteAnythingSignificant) {
requestBlankLine();
}
requestBlankLine();

writeToken(token);
}
Expand All @@ -304,9 +294,7 @@ void writeCodeClose(CodeCloseTag token) {
}

void writeTableOpen(TableOpenTag token) {
if (wroteAnythingSignificant) {
requestBlankLine();
}
requestBlankLine();

writeToken(token);
}
Expand Down Expand Up @@ -355,7 +343,7 @@ void writeLiteral(Literal token) {
}

void writeMarkdownFencedCodeBlock(MarkdownFencedCodeBlock token) {
if (wroteAnythingSignificant && !atStartOfLine) {
if (!atStartOfLine) {
// A reminder that atStartOfLine is still true after `-␣` because it is a StartOfLineToken.
requestBlankLine();
}
Expand All @@ -371,11 +359,12 @@ void writeMarkdownFencedCodeBlock(MarkdownFencedCodeBlock token) {
});
writeNewline();
output.append(token.end());
wroteAnythingSignificant = true;
requestBlankLine();
}

void writeMarkdownTable(MarkdownTable token) {
if (wroteAnythingSignificant && !atStartOfLine) {
if (!atStartOfLine) {
requestBlankLine();
}
flushWhitespace();
Expand All @@ -385,6 +374,7 @@ void writeMarkdownTable(MarkdownTable token) {
writeNewline(AutoIndent.NO_AUTO_INDENT);
output.append(line);
}
wroteAnythingSignificant = true;
requestBlankLine();
}

Expand Down Expand Up @@ -419,6 +409,10 @@ private void flushWhitespace() {
requestNewline();
}

if (!wroteAnythingSignificant) {
requestedWhitespace = NONE;
}

if (classicJavadoc
&& requestedWhitespace == BLANK_LINE
&& (!postWriteModifiedContinuingListStack.isEmpty() || continuingFooterTag)) {
Expand Down Expand Up @@ -466,6 +460,7 @@ private void writeToken(Token token) {
output.append(requestedMoeBeginStripComment.value());
requestedMoeBeginStripComment = null;
indentForMoeEndStripComment = innerIndent();
wroteAnythingSignificant = true;
requestNewline();
writeToken(token);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ class Test {}\
String expected =
"""
/**
*
* <!-- moe:begin_intracomment_strip -->
* Foo.
* <!-- moe:end_intracomment_strip -->
Expand Down Expand Up @@ -1995,11 +1994,9 @@ public void markdownLooseLists() {
/// - item 2
class Test {}
""";
// TODO: the line break between items should be preserved, and there should not be a blank line
// before the list.
// TODO: the line break between items should be preserved.
String expected =
"""
///
/// - item 1
/// - item 2
class Test {}
Expand Down Expand Up @@ -2259,7 +2256,8 @@ public void tableInHtmlListItem() {
class Test {}
""";
// requestBlankLine() in writeTableOpen() inserts a blank line after <li> before <table> when
// inside a list item.
// inside a list item. Also, we might prefer to eliminate the blank lines around the table
// element and to indent the table contents and close tag at least as far as the open tag.
String expected =
"""
/// <ul>
Expand All @@ -2286,11 +2284,8 @@ public void tableInsideMarkdownListItemAfterText() {
/// </table>
class Test {}
""";
// requestBlankLine() in writeTableOpen() inserts a blank line after item text before <table>
// inside the list item.
String expected =
"""
///
/// - item text
///
/// <table>
Expand Down
Loading