Repository navigation
Reflow long strings in formatDiff on the JVM, as with the native binary - #232
Merged
Merged
Conversation
This was referenced Nov 14, 2026
abashev
force-pushed
the
abashev/Range-reflow-in-process
branch
2 times, most recently
from
November 16, 2026 20:05
ed3bcf8 to
33fe8c1
Compare
formatDiff on the JVM loads FormatterServiceImpl into the build's JVM, and its getFormatReplacements called Formatter.getFormatReplacements, which never reflows strings. With the native binary, and in IntelliJ IDEA, the bootstrapping and native services run Main --output-replacements, which does. A long string on a changed line stayed on one line on the JVM only, and the GitHub Action failed on the result (#219). What FormatFileCallable did for --output-replacements moves, as it is, to Formatter.getFormatAndReflowReplacements, and FormatterServiceImpl.getFormatReplacements returns what it gives. Each case of FormatterCasesTest now also holds the two to each other: the lines formatting changes, taken as a range, get the same replacements from the service and from Main. On the code before, 78 of the 915 cases fail.
Both tested the bootstrapping and native services only, never the one formatDiff loads on the JVM. FormatDiffTest runs it next to them, and both reflow a long string on a changed line with each of the three.
abashev
force-pushed
the
abashev/Range-reflow-in-process
branch
from
November 16, 2026 20:18
33fe8c1 to
94e5117
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 #231; merge that first. Part of #219.
formatDiffon the JVM now reflows long strings as it does with the native binary, and as IntelliJ IDEA does: the in-processFormatterServiceImpl.getFormatReplacementsreturns whatMain --output-replacementsprints.FormatFileCallabledid for--output-replacementsmoves, unchanged, to the package-privateFormatter.getFormatAndReflowReplacements;FormatFileCallableandFormatterServiceImplcall it. The command line's output does not change.FormatterCasesTest, which Run tests that need a newer JDK in classes and folders of their own #231'sFormatterCasesJava21Test,Java25TestandJava28Testrun, also gives the lines that formatting changes, taken as a range, to the service and toMain, and expects the same replacements. On the code of Run tests that need a newer JDK in classes and folders of their own #231, 78 of the 915 cases fail on it, thestringwrapperones among them.FormatDiffTestruns the in-process formatter next to the bootstrapping and native ones, andFormatterServicesTestandFormatDiffTestreflow a long string on a changed line with each of the three.Not here: a long string outside the ranges is still reflowed once one in them needs it, on every surface alike now; that is the next pull request.
Tests
./gradlew checkpasses; 1,419 tests in:open-java-format. JDK 25 and JDK 28 (28+23-ea)::open-java-format:testpasses.:open-java-format:testpasses, with the JDK 25 cases; JDK 28 (28+23-ea) too, with the JDK 28 ones.-PnativeImage=true(macOS aarch64, GraalVM 25):FormatterServicesTest11 of 11,FormatDiffTest7 of 7.