Repository navigation
Conversation
When disabled, members of the same category (and visibility, if enabled) keep their original relative order instead of being sorted alphabetically. Can be overridden per file with // @SortMembers:sortByName=false|true. Default (true) keeps the current behaviour. Refs diffplug#3184 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTr23xDiCMWvQrEoZQSNHQ
Refs diffplug#3184 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTr23xDiCMWvQrEoZQSNHQ
Refs diffplug#3184 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTr23xDiCMWvQrEoZQSNHQ
Pankraz76
marked this pull request as ready for review
November 22, 2026 12:50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MTr23xDiCMWvQrEoZQSNHQ
This branch has not been deployed
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.
Closes #3184
Problem
With the Eclipse JDT step's Sort Members feature enabled, members of the same category (and the same visibility, if
sortMembersVisibilityOrderEnabledis on) are always sorted alphabetically by name. There is no way to keep their original relative order — e.g. a JUnit setup method ends up between test methods.Root cause
DefaultJavaElementComparator.compare(...)always falls back to a name comparison (methods: name, then parameter types; fields/types/enum constants/annotation members: name) once category and visibility are equal. Only initializers and members preserved bysortMembersDoNotSortFieldskeep their relative order.Change
sortMembersByName(defaulttrue= current behaviour, unchanged). Iffalse, members that are equal on category (and visibility) keep their original relative order — for all member kinds (methods incl. overloads, constructors, fields when sorted, nested types, enum constants, annotation type members).EclipseJdtFormatterStep.Builder#sortMembersByName(boolean)(Spotless-specific keyspotless.sort_members.by_name, no Eclipse equivalent)eclipse().sortMembersByName(false)<sortMembersByName>false</sortMembersByName>// @SortMembers:sortByName=false|true, same mechanism as the existing overrides.CHANGES.mdupdated.Tests
New cases in
EclipseJdtFormatterStepSpecialCaseTest(all viaStepHarness.testResource, which also asserts idempotence), expected outputs written by hand:foo(String)/foo(int)and constructors)sortMembersDoNotSortFields(false)→ fields and enum constants keep their ordersortByName=falsewith global default, andsortByName=truewith globalfalseAll existing sort tests and resources are unchanged and green.
CHANGES.md,plugin-gradle/CHANGES.md,plugin-maven/CHANGES.mdupdated (linking the issue)🤖 Generated with Claude Code
https://claude.ai/code/session_01MTr23xDiCMWvQrEoZQSNHQ