Open Zhenye-Na opened 5 months ago
Based on my investigation, it looks like in this line https://github.com/palantir/palantir-java-format/blob/e7abbb0435ec1bbdbcc8fc9ead8ea826fefc3ecc/palantir-java-format/src/main/java/com/palantir/javaformat/java/ImportOrderer.java#L29C1-L29C52, we are utilizing existing tokens.
However, Record
is not included there, in such case
/**
* {@link TokenKind}s that indicate the start of a type definition. We use this to avoid scanning the whole file,
* since we know that imports must precede any type definition.
*/
private static final ImmutableSet<TokenKind> CLASS_START =
ImmutableSet.of(TokenKind.CLASS, TokenKind.INTERFACE, TokenKind.ENUM);
/**
* We use this set to find the first import, and again to check that there are no imports after the place we stopped
* gathering them. An annotation definition ({@code @interface}) is two tokens, the second which is
* {@code interface}, so we don't need a separate entry for that.
*/
private static final ImmutableSet<String> IMPORT_OR_CLASS_START =
ImmutableSet.of("import", "class", "interface", "enum");
The formatting for record
object has inconsistent indentation comparing to the others.
I am happy to contribute to this to include at least record
in to it
What happened?
Related issue: https://github.com/palantir/palantir-java-format/issues/1007
What did you want to happen?
The formatter should indent
Record
constructor to be4
spaces instead of8