GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Join adjacent string literals that share a line by abashev · Pull Request #176 · openjavaformat/open-java-format Conversation
Collaborator
Fixes #148. WhatWhen a concatenation of string literals ends up on one line, the // 21.X.X throw new SafeIllegalArgumentException( "Invalid recipient field - contains multiple " + "foreign key properties.", UnsafeArg.of("field", maybeField)); foo("one " + "two " + value + "three " + "four"); // this PR throw new SafeIllegalArgumentException( "Invalid recipient field - contains multiple foreign key properties.", UnsafeArg.of("field", maybeField)); foo("one two " + value + "three four"); What the pass does
Literals stay apart:
A run that a reflowed chain or a text block overlaps is left to that pass. Differences from palantir#1781The code is Zayan Khan's, from palantir#1781 (closed there unmerged), which addresses palantir#68; the commit keeps the author. Two rules are new here:
The goldens and unit tests became case files, and the changelog entry is left out. Tests
JDK 21 corpusOf the 15,747 files, 787 format differently, in 2,303 places, and each is a join: with the
Partial formattingJoins reach as far as the reflow does today, which is the whole file:
VersionThis changes the output, so under the version scheme it moves the second number.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsWhen 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.
Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Join"a " + "b" string concatenations that end up on one line
Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |