From 7919ae41e1da4ad8ea2a9ff2dcd417e4a35ce8a8 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Wed, 20 May 2026 09:30:12 -0400 Subject: [PATCH] Fix: sort members treats record declarations as types (#2941) ASTNode.RECORD_DECLARATION was missing from the switch statement in DefaultJavaElementComparator.category(), causing nested record declarations to fall through to the `return 0` fallback instead of returning TYPE_INDEX. This placed records in the wrong sort category (near methods) rather than with other type declarations (T). The same node type was also missing from the secondary sort switch in compare(), which handles name-based ordering within a category. I did not add any tests for this are there were not tests for the Eclipse formatter. --- .../spotless/extra/glue/jdt/DefaultJavaElementComparator.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/DefaultJavaElementComparator.java b/lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/DefaultJavaElementComparator.java index 9b9f1d3aaf..2d5b7c47ed 100644 --- a/lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/DefaultJavaElementComparator.java +++ b/lib-extra/src/jdt/java/com/diffplug/spotless/extra/glue/jdt/DefaultJavaElementComparator.java @@ -190,6 +190,7 @@ private int category(BodyDeclaration bodyDeclaration) { } case ASTNode.TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: + case ASTNode.RECORD_DECLARATION: case ASTNode.ANNOTATION_TYPE_DECLARATION: return TYPE_INDEX; case ASTNode.ENUM_CONSTANT_DECLARATION: @@ -315,6 +316,7 @@ public int compare(BodyDeclaration bodyDeclaration1, BodyDeclaration bodyDeclara } case ASTNode.TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION: + case ASTNode.RECORD_DECLARATION: case ASTNode.ANNOTATION_TYPE_DECLARATION: { AbstractTypeDeclaration type1 = (AbstractTypeDeclaration) bodyDeclaration1; AbstractTypeDeclaration type2 = (AbstractTypeDeclaration) bodyDeclaration2;