Keep a tabular array initializer with mixed signs in rows - #69
Merged
Merged
Conversation
An array initializer written in rows, such as a table of coordinates, keeps its rows when every column holds expressions of the same kind. A column that mixed 95.0 with -95.0 or +95.0 did not count as one kind, because a signed number is a unary expression in javac's tree, so the whole table collapsed into one line, or into a filled block. This ports google/google-java-format#406 by Andrew Reid, which fixes google/google-java-format#400: a unary expression counts as the kind of its operand for that comparison. The golden TabularMixedSignInitializer comes from upstream, with the expected output in this project's style. The 15,747 files of the JDK 21 sources format exactly as before.
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.
Brings over google/google-java-format#406 by Andrew Reid, which fixes google/google-java-format#400 (google-java-format 1.8).
The bug
An array initializer written in rows, such as a table of coordinates, keeps its rows when every column holds expressions of the same kind. A column that mixed
95.0with-95.0or+95.0did not count as one kind, because a signed number is a unary expression in javac's tree, so the whole table collapsed into one line:while the same table without signs kept its two rows.
From upstream, with the author kept
expressionsAreParallela unary expression counts as the kind of its operand. The upstream goldenTabularMixedSignInitializercomes with it (signs,++/--/~and!columns), with the expected output in this project's style.Checked
./gradlew :open-java-format:teston JDK 21: 1501 tests, all green.