You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit da784aa
Browse filesBrowse the repository at this point in the historyBrowse files
When a concatenation of string literals ended up on one line, the +
between them stayed, as in "one " + "two". The string wrapping pass
only looked at lines past the column limit, so the output depended on
where the author had broken the string. StringWrapper now joins each
run of adjacent string literals that share a line into one literal,
whether the author wrote them so or the layout brought them together,
and the code is laid out again around it. A line with a quote on both
sides of a + now sets the pass off, and the pass returns at once when
it finds nothing to do.
Literals stay apart where joining would lose or change something: on
different lines, which is wrapping done on purpose; with a comment
between them; at a text block; on a line that ends in a line comment,
which may speak of them as they are written (a NON-NLS marker counts
the literals of its line, and a table of literals has a comment for
each row); where the left one ends in an octal escape of one or two
digits and the right one starts with an octal digit ("\1" + "2" is two
characters, "\12" one); and where either holds a Unicode escape. A run
that a reflowed chain or a text block overlaps is left to that pass.
From palantir#1781 by Zayan Khan, closed there
unmerged, which addresses palantir#68. Adapted
while bringing it over: the line comment rule and the Unicode escape
rule are new. Without the first, java/util/LocaleISOData.java of the
JDK, a table of rows such as "aa" + "aar" // Afar, became a column of
"aaaar" // Afar, and the NON-NLS markers of #23 lost their literals.
Without the second, "\u005c1" + "2" became "\u005c12", one character
instead of two, which the AST check rejected, so the file failed to
format. The goldens and unit tests became two cases, the expected
outputs of NON-NLS and palantir-10 join their literals, and the
changelog entry is left out.
Of the 15,747 files of the JDK 21 sources, 787 format differently, in
2,303 places, and each is a join: with the + between two literals
taken out and blanks ignored, both versions read the same. 737 files
join on lines that stay as they are; in 167 the code is then laid out
again, mostly a call whose argument now fits on the line of the call.
The files that change on a second run go down from 67 to 48, none of
them new: in 19, a second run moved the pieces of a chain about that
are now joined in the first.
Tests on JDK 21: FormatterCasesTest 887 -> 889; 1410 tests in the
module, 1471 in all modules.
Fixes#148.
0 commit comments