Repository navigation
Leave out the empty ranges the out-of-process formatters get - #277
Merged
Merged
Conversation
IntelliJ IDEA can pass an empty range among those it reformats. The native and the separate-JVM services turned [n, n) into "n:n-1", which --character-ranges, whose ranges are closed, rejects with "Invalid range", and Reformat failed. FormatterServiceImpl, in process, already leaves empty ranges out: its TreeRangeSet drops them. The two services now leave them out too, and format nothing when no range is left, as FormatterServiceImpl does: without --character-ranges the command line would format the whole file. formatDiff, which drops the empty range of a blank line, so no longer reformats the whole file when a diff adds only blank lines. Closes #275
CI's native job leaves out macOS on Apple silicon, commented out in its matrix; release.yml still builds it. Every native leg moves to the newest image: macos-latest for Apple silicon, and, as arm Linux and Intel macOS have no free -latest label, ubuntu-26.04-arm and macos-26-intel.
The platform names in release.yml's matrix only named the jobs and their artifacts: the binaries are named, and their Maven classifiers read, from what Gradle builds, and the deploy jobs collect every native-image-* artifact. The runner label names both now.
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.
Based on
21.X.X.IntelliJ IDEA can pass an empty range among the ranges it reformats. The native and the separate-JVM services turned
[n, n)inton:n-1, which--character-rangesrejects withInvalid range: [1376..1375], because its ranges are closed. Reformat then failed with theUncheckedIOExceptionof #275. The in-process formatter never failed, sinceFormatterServiceImplputs the ranges in aTreeRangeSet, which drops empty ones. The released 21.0.2 binary shows both halves:--character-ranges 10:20,22:21exits 2, and no--character-rangesat all formats the whole file.Changes
RangeUtils.toStringRangesleaves out the ranges that are empty once canonical, before they become--character-ranges.NativeImageFormatterServiceandBootstrappingFormatterServicereturn no replacements, without starting the command, when no range is left. That is whatFormatterServiceImpldoes; without the flag, the command line would format the whole file.formatDiffdrops the empty range of a blank line, so with the native or the separate-JVM formatter a diff that adds only blank lines reformatted the whole file. It now formats nothing there, as it already did in process.The fix is in the bootstrap code, not the command line, so it also holds when the separate JVM runs an older formatter.
Checked
JvmFormatterServicesTest, which runs in every build, andFormatterServicesTest, which the native jobs run, each get two cases: an empty range in the middle of the file and one at its end, next to a range that is not empty, and empty ranges or no range alone. Before the fix both cases failed on the separate-JVM service with the issue's error../gradlew -PnativeImage=true :open-java-format-jdk-bootstrap:test :gradle-open-java-format:testpasses against a native binary built from this branch with GraalVM 25, and./gradlew checkpasses.CI runners
A second commit, unrelated to the fix:
nativejob leaves out macOS on Apple silicon, commented out in its matrix.release.ymlstill builds it.macos-latestfor Apple silicon. Arm Linux and Intel macOS have no free-latestlabel, so they getubuntu-26.04-armandmacos-26-intel;macos-latest-largeis Intel too, but it is a paid larger runner.mise run ci:nativeand the README follow.release.yml's matrix lists the runners alone, asci.yml's does: its platform names only named the jobs and their artifacts, which the runner label names now. The binaries are named, and their Maven classifiers read, from what Gradle builds.ubuntu-latestmoved to 26.04.Closes #275