In testing an upgrade to 1.6.1, we're sometimes seeing line breaks introduced into generics. Seems like this is probably a result of #512. I can see this being useful in pathological cases with extremely long generic type lists, but the issue is that we run prettier with a pretty aggressive line length limit, so we end up seeing split generics even in relatively straight-forward code samples. And it's pretty jarring when you first see it, because as far as I know, splitting generics like this isn't an idiomatic way to format Java (at least I haven't seen it in the wild before).
I tested the prettier-java upgrade on ~1,500 of our internal GitHub repos, and it definitely seemed like, in most cases, this generic splitting was hurting the code readability more than it helped. But curious to get your thoughts on how attached you are to this feature.
Prettier-Java 1.6.1
Input:
public abstract class GenericWblGeneratorWithLongName<OBJECT_TYPE, RECORD_TYPE> {
public static <RECORD, OFFSET> PagedResult<RECORD, OFFSET> appendCustomOffsets(
Arg arg1,
Arg arg2
) {
// implementation
}
}
Output:
public abstract class GenericWblGeneratorWithLongName<
OBJECT_TYPE, RECORD_TYPE
> {
public static <
RECORD, OFFSET
> PagedResult<RECORD, OFFSET> appendCustomOffsets(Arg arg1, Arg arg2) {
// implementation
}
}
Expected behavior:
public abstract class GenericWblGeneratorWithLongName<OBJECT_TYPE, RECORD_TYPE> {
public static <RECORD, OFFSET> PagedResult<RECORD, OFFSET> appendCustomOffsets(
Arg arg1,
Arg arg2
) {
// implementation
}
}
In testing an upgrade to 1.6.1, we're sometimes seeing line breaks introduced into generics. Seems like this is probably a result of #512. I can see this being useful in pathological cases with extremely long generic type lists, but the issue is that we run prettier with a pretty aggressive line length limit, so we end up seeing split generics even in relatively straight-forward code samples. And it's pretty jarring when you first see it, because as far as I know, splitting generics like this isn't an idiomatic way to format Java (at least I haven't seen it in the wild before).
I tested the prettier-java upgrade on ~1,500 of our internal GitHub repos, and it definitely seemed like, in most cases, this generic splitting was hurting the code readability more than it helped. But curious to get your thoughts on how attached you are to this feature.
Prettier-Java 1.6.1
# Options (if any):Input:
Output:
Expected behavior: