Fix indentation and closing-paren placement for multi-resource try-with-resources - #1454
Open
saloni-eng wants to merge 2 commits into
Open
saloni-eng wants to merge 2 commits into
saloni-eng wants to merge 2 commits into
Conversation
…cement for multi-resource try-with-resources
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Fixes #1392.
Try-with-resources statements with more than one resource were
formatting inconsistently: the first resource stayed glued to
try (,and the closing
)was glued to the last resource, e.g.:This changes multi-resource try statements to break after
(, puteach resource on its own line, and place the closing
)back at thesame indentation as
try, matching how other multi-line constructs(e.g. argument lists) are formatted:
Single-resource try-with-resources statements are unaffected.
Changes
JavaInputAstVisitor.visitTry: conditionally open aplusFourindent and force a break after
(only when there's more than oneresource; close the indent level before the trailing break so the
closing
)renders at the outer indent instead of the resourceindent.
FormatterTest: addedmultivariableTryWithResourcescovering thenew formatting.
testdata/B21465217.output,testdata/B26159561.output: regeneratedgolden files that encoded the old (pre-fix) multi-resource layout.
Testing
mvn clean testpasses, including the CR/LF/CRLF idempotency checksin
FormatterIntegrationTest.