Conversation
StringWrapper.applyReplacements chooses '+' continuation indents from the string literal's start column. When the literal is prefixed (e.g. after `return`), that indent disagrees with the pretty-printer, so a second format pass rewrote the file (issue google#935). Format once more after applying wrap replacements so the output is stable under subsequent formatSource / CLI runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #935.
StringWrapperbuilds wrapped string concatenations with a continuation indent based on the string literal's start column (startColumn + 4). When the literal is prefixed (for example afterreturn), that disagrees with the pretty-printer, which breaks+relative to the statement. The wrap pass then returned that over-indented text without a final format, so a second CLI/formatSourcerun rewrote the file.After applying wrap replacements (and the existing AST sanity check), run
formatter.formatSourceonce more so the output matches what a subsequent format pass would produce.Test plan
mvn -pl core -Dtest=StringWrapperTest,StringWrapperIntegrationTest test— 80/80 (includes newwrapThenFormatIsIdempotentForPrefixedString)mvn -pl core -Dtest=FormatterIntegrationTest test— 1045/1045return "Very, very, … need to be split") twice with the all-deps jar; second pass is a no-opNotes
Google CLA already signed for this account (
cla/googlegreen on recentgoogle/autoPRs).