Repository navigation
Format only the ranges on the command line, and leave the imports - #234
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/Range-text-output
branch
from
November 16, 2026 20:04
9582a08 to
863e920
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/Range-text-output
branch
from
November 16, 2026 20:05
863e920 to
275270f
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/Range-text-output
branch
from
November 16, 2026 20:25
275270f to
acb3e43
Compare
With --lines, --offset or --character-ranges and no --output-replacements, Main formatted the ranges, then fixed the imports of the whole file and reflowed every long string in it. It now prints what applying its --output-replacements for the same ranges gives: the code of the ranges formatted, its long strings reflowed, the imports and the rest of the file as they are (ADR-001). Without ranges nothing changes. Two tests pinned the old way: MainTest.importRemovalLines, now linesLeaveTheImports, and PartialFormattingTest.importJavadocNewlines, whose import line is still laid out but no longer gets the import orderer's blank line after it. Each case of FormatterCasesTest now also holds the text to the replacements for the lines it changes, and CommandLineRangesTest checks --lines on a file with imports and two long strings.
abashev
force-pushed
the
abashev/Range-reflow-inside
branch
from
November 17, 2026 18:45
3c36af2 to
c799977
Compare
abashev
force-pushed
the
abashev/Range-text-output
branch
from
November 17, 2026 18:45
acb3e43 to
bf770f1
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.
open-java-format --lines,--offsetand--character-ranges, printing text, now give what applying--output-replacementsfor the same ranges gives: the code of the ranges formatted and its long strings reflowed, the imports and the rest of the file as they are (ADR-001). Before, they formatted the ranges, then fixed the imports of the whole file and reflowed every long string in it. Without ranges nothing changes.What changes for users
--output-replacementslays it out. Long strings outside the code of the ranges stay as they are.Two tests pinned the old behaviour and change with it:
MainTest.importRemovalLines, nowlinesLeaveTheImports, andPartialFormattingTest.importJavadocNewlines, which no longer gets the import orderer's blank line after the import.Tests
FormatterCasesTestalso expects the same text from--character-rangesas from applying its--output-replacementsfor the lines formatting changes.CommandLineRangesTest:--linesleaves the imports and a long string on another line. On the code of Reflow only the long strings in the code that formatting the ranges rewrites #233, 25 cases andCommandLineRangesTestfail../gradlew checkpasses; 1,423 tests in:open-java-format. JDK 25 and JDK 28 (28+23-ea)::open-java-format:testpasses.