Skip to content

Commit

Permalink
Fix indentation of case statements on JDK 17
Browse files Browse the repository at this point in the history
Fixes #643

PiperOrigin-RevId: 392966720
  • Loading branch information
cushon authored and google-java-format Team committed Aug 25, 2021
1 parent 865cff0 commit 79257ed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Expand Up @@ -251,7 +251,7 @@ public Void visitCase(CaseTree node, Void unused) {
token("default", plusTwo);
} else {
token("case", plusTwo);
builder.open(plusFour);
builder.open(node.getExpressions().size() > 1 ? plusFour : ZERO);
builder.space();
boolean first = true;
for (ExpressionTree expression : node.getExpressions()) {
Expand Down
@@ -0,0 +1,14 @@
public class Foo {
static final int VERBOSE_WORDY_AND_LENGTHY_ONE = 1;
static final int VERBOSE_WORDY_AND_LENGTHY_TWO = 2;
static final int VERBOSE_WORDY_AND_LENGTHY_FOUR = 4;

public static int fn(int x) {
switch (x) {
case VERBOSE_WORDY_AND_LENGTHY_ONE | VERBOSE_WORDY_AND_LENGTHY_TWO | VERBOSE_WORDY_AND_LENGTHY_FOUR:
return 0;
default:
return 1;
}
}
}
@@ -0,0 +1,16 @@
public class Foo {
static final int VERBOSE_WORDY_AND_LENGTHY_ONE = 1;
static final int VERBOSE_WORDY_AND_LENGTHY_TWO = 2;
static final int VERBOSE_WORDY_AND_LENGTHY_FOUR = 4;

public static int fn(int x) {
switch (x) {
case VERBOSE_WORDY_AND_LENGTHY_ONE
| VERBOSE_WORDY_AND_LENGTHY_TWO
| VERBOSE_WORDY_AND_LENGTHY_FOUR:
return 0;
default:
return 1;
}
}
}

0 comments on commit 79257ed

Please sign in to comment.