GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use Collator when sorting Eclipse JDT members by aKandzior · Pull Request #2920 · diffplug/spotless

Conversation

@aKandzior

@aKandzior aKandzior commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This updates the Eclipse JDT member sorting comparator to use java.text.Collator when comparing member names and parameter type signatures.

The Eclipse JDT UI implementation uses a collator for these comparisons. Spotless used String.compareTo, which can produce a different member order than Eclipse save actions for names that differ by case or locale-sensitive collation.

Motivation

Our team primarily works with Eclipse, but some developers now use VS Code for smaller edits. We use Spotless to make the command line and non-Eclipse editing workflow follow the same formatting rules as Eclipse save actions.

Without this patch, member sorting can differ deterministically between Eclipse and Spotless in edge cases. That creates a "ping pong" scenario where method positions shift depending on which editor or formatter was used last.

Using the same collator-based comparison as Eclipse avoids that difference and makes Spotless member sorting match Eclipse more closely.

Changes

  • Use Collator in DefaultJavaElementComparator.
  • Apply it to method name comparison.
  • Apply it to parameter type signature comparison.
  • Add a regression fixture that exposes the ordering difference.

Test

./gradlew :lib-extra:test --tests com.diffplug.spotless.extra.java.EclipseJdtFormatterStepSpecialCaseTest --no-daemon --no-configuration-cache --console=plain

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

stechio reacted with hooray emoji
All reactions
  • 🎉 1 reaction
aKandzior added 2 commits May 8, 2026 14:24
@aKandzior
Use Collator when sorting Eclipse JDT members
8e20a90
The Eclipse JDT member sorter compares method names and parameter type signatures with a java.text.Collator. Spotless' DefaultJavaElementComparator used String.compareTo instead, which can produce a different member order than Eclipse save actions for names that differ by case or locale-sensitive collation.

Update DefaultJavaElementComparator to use Collator for member name comparison and parameter type signature comparison so Spotless matches Eclipse JDT behavior more closely.

Adds a regression fixture which exposes the case-sensitive ordering difference.

Test: ./gradlew :lib-extra:test --tests com.diffplug.spotless.extra.java.EclipseJdtFormatterStepSpecialCaseTest --no-daemon --no-configuration-cache --console=plain
@aKandzior
Update changelog for Eclipse JDT member sort fix
920e4b1
@aKandzior aKandzior mentioned this pull request May 8, 2026
[plugin-maven] eclipse formatter sorts Java class members and imports lexicographically rather than alphabetically #2493
Closed
aKandzior and others added 2 commits May 12, 2026 15:15
@aKandzior
Source code formatting with spotlessApply.
273293f
@nedtwigg
Merge remote-tracking branch 'origin/main' into fix-jdt-member-sort-c…
3de963b
…ollator
@nedtwigg
nedtwigg merged commit a2acb39 into diffplug:main May 14, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

stechio added a commit to pdfclown/pdfclown-common that referenced this pull request May 20, 2026
@stechio
style: apply new spotless sorting algorithm
57f5dca
Applies the new spotless sorting algorithm for Java members (Eclipse
JDT's collator-based comparison
diffplug/spotless#2920).
stechio added a commit to pdfclown/pdfclown-common that referenced this pull request May 20, 2026
@dependabot @stechio
fix(deps): bump com.diffplug.spotless:spotless-maven-plugin from 3.4.…
a5a87a2
…0 to 3.5.1 (#104)

* fix(deps): bump com.diffplug.spotless:spotless-maven-plugin

Bumps [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) from 3.4.0 to 3.5.1.
- [Release notes](https://github.com/diffplug/spotless/releases)
- [Changelog](https://github.com/diffplug/spotless/blob/main/CHANGES.md)
- [Commits](diffplug/spotless@maven/3.4.0...maven/3.5.1)

---
updated-dependencies:
- dependency-name: com.diffplug.spotless:spotless-maven-plugin
  dependency-version: 3.5.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* style: apply new spotless sorting algorithm

Applies the new spotless sorting algorithm for Java members (Eclipse
JDT's collator-based comparison diffplug/spotless#2920).

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: stechio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@aKandzior @nedtwigg
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.