René's URL Explorer Experiment


Title: Format the same on every route: formatDiff on the JVM, ranges, and the order of fixing imports by abashev · Pull Request #220 · openjavaformat/open-java-format · GitHub

Open Graph Title: Format the same on every route: formatDiff on the JVM, ranges, and the order of fixing imports by abashev · Pull Request #220 · openjavaformat/open-java-format

X Title: Format the same on every route: formatDiff on the JVM, ranges, and the order of fixing imports by abashev · Pull Request #220 · openjavaformat/open-java-format

Description: Closes #219. formatDiff on the JVM and with the native binary, IntelliJ IDEA, the Maven plugin and the Spotless step now format a file the way the command line does. Imports. Formatter.formatSourceAndFixImports, behind the Maven plugin and the Spotless step, fixes the imports after formatting, as Main does. The order decided where the comment of a removed import ended up, and whether a blank line stayed under it. Ranges. --output-replacements and FormatterServiceImpl.getFormatReplacements go through one method, Formatter.getFormatAndReflowReplacements, so the in-process service reflows long strings as the bootstrapping and native services do. formatDiff without the native binary left them on one line, and the GitHub Action failed on the result. Strings outside the ranges. StringWrapper.wrap takes the ranges and reflows only the literals and text blocks that overlap them, moving the ranges along with each of its passes. The ranges are those of the code that formatting them rewrote, which is the statement around a changed line where the formatter re-lays it out. Before, one long string in the ranges reflowed every long string in the file. What changes for users Whole files: nothing. Without ranges StringWrapper runs as before. The patched Main gives byte for byte what the 21.0.2 native binary gives on 1,500 files, so the command line, the GitHub Action and the pre-commit hook are unchanged. The Maven plugin and the Spotless step now write what the command line writes. In the 3,865 files of #219 that changes one, CharsetEncoder of JDK 21. A file with an extraneous semicolon between imports, which they used to drop, now fails as on the command line: extraneous semicolon. And import module java./* comment */ base; stays on one line, as the command line leaves it, where they broke it after the dot. Ranges reflow the strings in the code the formatter rewrites for them, and nothing else. They do that more often than the native binary did: its check of whether to reflow looked at the ranges of the input in the formatted text, and missed a long string the formatter had moved into a rewritten statement. Over every line with a string literal and more than 90 characters in 600 of those files, one line at a time: 28 results reflowed, all inside the rewritten code; 21.0.2's --output-replacements reflowed 11, 2 of them outside it. Tests FormatterServiceImplTest holds the in-process service to what Main prints: whole files, and each line of each file as a range. On the code before this change 7 of the 11 new cases in it and in FormatterTest fail. StringWrapperTest covers wrapping in ranges and how the ranges move with the replacements. FormatterServicesTest and FormatDiffTest run the in-process formatter too, next to the bootstrapping and native ones, on a file with a long string on a changed line and another on a line that is not. ModuleImportTest expects for a comment inside a module name what the command line prints: it held formatSourceAndFixImports to the line the old order left broken after the dot. It runs on JDK 25 and later only, which is why the first push failed the JDK 25 to 28 builds and passed on 21. On JDK 21: ./gradlew check passes, 1,435 tests in :open-java-format, 141 in :gradle-open-java-format and 65 in the IntelliJ plugin. ./gradlew test passes as the CI legs run it on JDK 25 (TestKit Gradle 9.3.1) and on JDK 27 (9.8.0). With -PnativeImage=true (macOS aarch64, GraalVM 25) the 11 of FormatterServicesTest and the 7 of FormatDiffTest pass. Not here open-java-format --lines without --output-replacements still reflows the whole file: it fixes the imports between formatting and reflowing, and the ranges cannot be followed through that. The Eclipse plugin formats with Formatter.getFormatReplacements and does not reflow strings. Spotless' own palantirJavaFormat() step never reflows strings; that is Spotless' code.

Open Graph Description: Closes #219. formatDiff on the JVM and with the native binary, IntelliJ IDEA, the Maven plugin and the Spotless step now format a file the way the command line does. Imports. Formatter.formatSourc...

X Description: Closes #219. formatDiff on the JVM and with the native binary, IntelliJ IDEA, the Maven plugin and the Spotless step now format a file the way the command line does. Imports. Formatter.formatSourc...

Opengraph URL: https://github.com/openjavaformat/open-java-format/pull/220

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5f7f3b1e-5bb9-ecb6-7c8f-ae67d7d9afc2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD0C4:197A56:6ACDE:91FEC:6AFBC76A
html-safe-nonce7d6c93268db951b5520e1ed145bbc51ee5c73318e3393512daae35c33ab1e8f1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEM0OjE5N0E1Njo2QUNERTo5MUZFQzo2QUZCQzc2QSIsInZpc2l0b3JfaWQiOiI2OTI2MjY0OTkyOTE2MDMxMzM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaca2fbd4e7e40fab147e1029824871b3908769b3bc60cea90c73007ce727c9bf7f
hovercard-subject-tagpull_request:5284967440
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/openjavaformat/open-java-format/pull/220/files
twitter:imagehttps://avatars.githubusercontent.com/u/214171?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/214171?s=400&v=4
og:image:altCloses #219. formatDiff on the JVM and with the native binary, IntelliJ IDEA, the Maven plugin and the Spotless step now format a file the way the command line does. Imports. Formatter.formatSourc...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git
octolytics-dimension-user_id325177626
octolytics-dimension-user_loginopenjavaformat
octolytics-dimension-repository_id1288055459
octolytics-dimension-repository_nwoopenjavaformat/open-java-format
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forktrue
octolytics-dimension-repository_parent_id214273098
octolytics-dimension-repository_parent_nwopalantir/palantir-java-format
octolytics-dimension-repository_network_root_id214273098
octolytics-dimension-repository_network_root_nwopalantir/palantir-java-format
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2c43021aed8695990c86c0eaaedc600bfeffec36
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/openjavaformat/open-java-format/pull/220/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fpull%2F220%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fpull%2F220%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=openjavaformat%2Fopen-java-format
Reloadhttps://github.com/openjavaformat/open-java-format/pull/220/files
Reloadhttps://github.com/openjavaformat/open-java-format/pull/220/files
Reloadhttps://github.com/openjavaformat/open-java-format/pull/220/files
openjavaformathttps://github.com/openjavaformat
open-java-formathttps://github.com/openjavaformat/open-java-format
Codehttps://github.com/openjavaformat/open-java-format
Issues30 (30)https://github.com/openjavaformat/open-java-format/issues
Pull requests5 (5)https://github.com/openjavaformat/open-java-format/pulls
Discussionshttps://github.com/openjavaformat/open-java-format/discussions
Actionshttps://github.com/openjavaformat/open-java-format/actions
Security and qualityhttps://github.com/openjavaformat/open-java-format/security
Insightshttps://github.com/openjavaformat/open-java-format/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fopenjavaformat%2Fopen-java-format%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fopenjavaformat%2Fopen-java-format%2Fissues%2Fnew%2Fchoose
abashevhttps://github.com/abashev
21.X.Xhttps://github.com/openjavaformat/open-java-format/tree/21.X.X
abashev/Same-output-on-every-routehttps://github.com/openjavaformat/open-java-format/tree/abashev/Same-output-on-every-route
Conversation 0 https://github.com/openjavaformat/open-java-format/pull/220
Commits 7 https://github.com/openjavaformat/open-java-format/pull/220/commits
Checks 17 https://github.com/openjavaformat/open-java-format/pull/220/checks
Files changed https://github.com/openjavaformat/open-java-format/pull/220/files
Please reload this pagehttps://github.com/openjavaformat/open-java-format/pull/220/files
Format the same on every route: formatDiff on the JVM, ranges, and the order of fixing imports https://github.com/openjavaformat/open-java-format/pull/220/files#top
Show all changes 7 commits https://github.com/openjavaformat/open-java-format/pull/220/files
edce6f5 Fix the imports after formatting, as the command line does abashev Nov 12, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/edce6f5f120c868a33dfeaa09b788383bb32d97b
68e5bdf Reflow only the strings in the code that formatting the ranges rewrites abashev Nov 12, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/68e5bdf1b4ee2191ddf712b7a7142a4d8f60d1df
b445927 Reflow long strings in formatDiff on the JVM, as with the native binary abashev Nov 12, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/b445927d718798484a4eb404a127322ef8e3ba83
b06ccee Expect what the command line prints for a comment in a module name abashev Nov 12, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/b06ccee5a4656924b6298f06a2f64e283c8661a6
80049d7 Revert the changes of this branch abashev Nov 14, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/80049d7fd6e274f0d3c6db8e686c54e832482996
8adfb3d Merge remote-tracking branch 'origin/21.X.X' into abashev/Same-output… abashev Nov 14, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/8adfb3d1fb32d267a4f83ef10e5f461fc049703d
af5f1c7 Format the repository with open-java-format 21.0.2 abashev Nov 14, 2026 https://github.com/openjavaformat/open-java-format/pull/220/commits/af5f1c7a47795747b2f2a2b2a5a4f093d1dec3b3
Clear filters https://github.com/openjavaformat/open-java-format/pull/220/files
Please reload this pagehttps://github.com/openjavaformat/open-java-format/pull/220/files
Please reload this pagehttps://github.com/openjavaformat/open-java-format/pull/220/files
build.gradlehttps://github.com/openjavaformat/open-java-format/pull/220/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7
View file https://github.com/openjavaformat/open-java-format/blob/af5f1c7a47795747b2f2a2b2a5a4f093d1dec3b3/build.gradle
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/openjavaformat/open-java-format/pull/220/{{ revealButtonHref }}
https://github.com/openjavaformat/open-java-format/pull/220/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7
https://github.com/openjavaformat/open-java-format/pull/220/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7
https://github.com/openjavaformat/open-java-format/pull/220/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7
https://github.com/openjavaformat/open-java-format/pull/220/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7
Please reload this pagehttps://github.com/openjavaformat/open-java-format/pull/220/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.