Skip to content

Commit f7543b2

Browse files
cushongoogle-java-format Team
authored and
google-java-format Team
committed
Adjust line comment indentation inside statement switches
Follow-up to 3affd63 Fixes #876 PiperOrigin-RevId: 644190687
1 parent 3affd63 commit f7543b2

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

core/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import com.google.common.base.Verify;
2121
import com.google.common.collect.ImmutableList;
22-
import com.google.googlejavaformat.Indent;
2322
import com.google.googlejavaformat.OpsBuilder;
2423
import com.google.googlejavaformat.OpsBuilder.BlankLineWanted;
2524
import com.google.googlejavaformat.java.JavaInputAstVisitor;
@@ -233,11 +232,10 @@ public Void visitCase(CaseTree node, Void unused) {
233232
&& !node.getBody().getKind().equals(Tree.Kind.BLOCK)
234233
? plusFour
235234
: ZERO);
236-
Indent commentIndent = node.getCaseKind().equals(CaseTree.CaseKind.RULE) ? ZERO : plusTwo;
237235
if (isDefault) {
238-
token("default", commentIndent);
236+
token("default", ZERO);
239237
} else {
240-
token("case", commentIndent);
238+
token("case", ZERO);
241239
builder.open(labels.size() > 1 ? plusFour : ZERO);
242240
builder.space();
243241
boolean afterFirstToken = false;

core/src/test/resources/com/google/googlejavaformat/java/testdata/SwitchComment.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class T {
1616
void g(String v) {
1717
int x =
1818
switch (v) {
19-
// this is a line comment about "zero"
19+
// this is a line comment about "zero"
2020
case "zero":
2121
return 0;
2222
case "one":

0 commit comments

Comments
 (0)