Rather than treating the optional binary expression following a pattern as part of the pattern itself, treat the entire expression as a binary expression, of which the pattern is a part, so that the usual binary expression formatting applies.
Example
Input
class Example {
public boolean test(final Object obj) {
return obj instanceof final Integer x && (x == 5 || x == 6 || x == 7 || x == 8 || x == 9 || x == 10 || x == 11);
}
}
Output
class Example {
public boolean test(final Object obj) {
return (
obj instanceof final Integer x &&
(x == 5 || x == 6 || x == 7 || x == 8 || x == 9 || x == 10 || x == 11)
);
}
}
611 solves the issue described in #605 also, while simultaneously supporting the now-official "when" style of guards. Assuming that PR is merged, we can close this one.
What changed with this PR:
Rather than treating the optional binary expression following a pattern as part of the pattern itself, treat the entire expression as a binary expression, of which the pattern is a part, so that the usual binary expression formatting applies.
Example
Input
Output
Relative issues or prs:
Closes #605