Repository navigation
Reflow long strings in Eclipse's Format, as on the command line - #235
Merged
Merged
Conversation
abashev
force-pushed
the
abashev/Range-reflow-inside
branch
from
November 16, 2026 20:03
2897566 to
2e3876f
Compare
abashev
force-pushed
the
abashev/Eclipse-range-reflow
branch
from
November 16, 2026 20:04
aa291bb to
c36e9b1
Compare
abashev
force-pushed
the
abashev/Range-reflow-inside
branch
from
November 16, 2026 20:05
2e3876f to
6e28b71
Compare
abashev
force-pushed
the
abashev/Eclipse-range-reflow
branch
from
November 16, 2026 20:05
c36e9b1 to
5894a4f
Compare
abashev
force-pushed
the
abashev/Range-reflow-inside
branch
from
November 16, 2026 20:22
6e28b71 to
3c36af2
Compare
abashev
force-pushed
the
abashev/Eclipse-range-reflow
branch
from
November 16, 2026 20:26
5894a4f to
86741cf
Compare
abashev
force-pushed
the
abashev/Range-reflow-inside
branch
from
November 17, 2026 18:45
3c36af2 to
c799977
Compare
… line Eclipse's Format of a Java editor formats the whole compilation unit with its comments over the selected ranges. It went through Formatter.getFormatReplacements, which never reflows, so a long string in the selection stayed on one line where the command line, formatDiff and IntelliJ IDEA wrap it (#219). It now goes through getFormatAndReflowReplacements, which reflows only the strings in the code that formatting the ranges rewrites. Snippets, which Eclipse formats when it inserts code, stay as they are: they are wrapped in a dummy class, and toReplacements accepts only changes to whitespace, which reflowing a string is not. The plugin had no tests; it gets JUnit and AssertJ for SnippetFormatterTest.
abashev
force-pushed
the
abashev/Eclipse-range-reflow
branch
from
November 17, 2026 18:45
86741cf to
6dcf057
Compare
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.
Builds on #233; merge that first. Independent of #234.
Eclipse's Format of a Java editor now reflows the long strings in the selected code, as the command line,
formatDiffand IntelliJ IDEA do (ADR-001). It formats the compilation unit with its comments over the selected ranges, and went throughFormatter.getFormatReplacements, which never reflows (#219). It now callsgetFormatAndReflowReplacements, the method--output-replacementsand the in-process service share since #232, which after #233 reflows only the strings in the code that formatting the ranges rewrites.What changes for users
open-java-format --character-rangeswraps it. Strings outside the selection stay as they are. Imports are not touched, as before.toReplacementsaccepts only changes to whitespace, which reflowing a string is not.Tests
The plugin had no tests; it gets JUnit and AssertJ for
SnippetFormatterTest:reflowsTheLongStringOfTheRangeOnly: a compilation unit with two long strings and a range over one; that one is wrapped, the other stays. On the code of Reflow only the long strings in the code that formatting the ranges rewrites #233 it fails.leavesTheLongStringOfAStatementSnippet: a statement snippet keeps its long string.JDK 21:
./gradlew checkpasses. JDK 25::open-java-format-eclipse-plugin:testpasses.