google-java-format
google-java-format copied to clipboard
Wrong indentation on if-then with comments
Comments at the end of this if
makes the then
block to not get indented.
if (prd.source()
.isPresent()) // exclude generated productions like casts
prd = null;
Line 331. IntelliJ reports this as well.
I think the problem comes from the if condition that got split into two lines. If I move the comment to a separate line, then indentation works as expected.
The style guide requires braces for if
statements: https://google.github.io/styleguide/javaguide.html#s4.1.1-braces-always-used (#938 is slightly related)
So I agree this isn't a good formatting and we'd probably prefer something like the following, but this is also low priority because it's already not following the style guide:
if (prd.source()
.isPresent()) // exclude generated productions like casts
prd = null;
I see this also with a condition on a single line:
I.e. the line break in the condition is likely not the cause.