Open
Description
Contrary to the formatter within the Eclipse IDE (which sorts Java class members and imports alphabetically), the eclipse
formatter within Spotless sorts Java class members and imports lexicographically (!?!) — here it is my configuration:
<eclipse>
<file>${project.basedir}/config/eclipse/java-style.xml</file>
<sortMembersEnabled>true</sortMembersEnabled>
<!-- Optional: Specify the sort order of the member categories. (default: T,SF,SI,SM,F,I,C,M)
SF,SI,SM,F,I,C,M,T = Static Fields, Static Initializers, Static Methods, Fields, Initializers, Constructors, Methods, (Nested) Types -->
<sortMembersOrder>T,SF,SI,SM,F,I,C,M</sortMembersOrder>
<sortMembersVisibilityOrderEnabled>true</sortMembersVisibilityOrderEnabled>
<!-- Optional: Specify the ordering of members of the same category by the visibility within the category (default: B,V,R,D).
B,R,D,V = Public, Protected, Package, Private -->
<sortMembersVisibilityOrder>B,R,D,V</sortMembersVisibilityOrder>
</eclipse>
Feeding Eclipse IDE-formatted source code to spotless-maven-plugin, the resulting source code differs just in its sorting — for example:
- Eclipse IDE:
public static Optional<StackFrame> callerFrame() {
. . .
}
public static Object callOrThrow(. . .) {
. . .
}
- Spotless:
public static Object callOrThrow(. . .) {
. . .
}
public static Optional<StackFrame> callerFrame() {
. . .
}
In case of homonymous methods, lexicographic sorting is applied to the parameter type names:
- Eclipse IDE:
public static String transform(char[] value) {
. . .
}
public static String transform(String value) {
. . .
}
- Spotless:
public static String transform(String value) {
. . .
}
public static String transform(char[] value) {
. . .
}
The imports are also affected by the same problem:
- Eclipse IDE:
import static org.myexample.util.MyClass.anotherFunction;
import static org.myexample.util.MyClass.NestedType.myFunction;
- Spotless:
import static org.myexample.util.MyClass.NestedType.myFunction;
import static org.myexample.util.MyClass.anotherFunction;
Why such an inconsistency, considering that both the formatters are based on JDT?
(Have I overlooked any configuration option?)
Metadata
Metadata
Assignees
Labels
No labels