Skip to content

Commit

Permalink
Adjust line comment indentation inside statement switches
Browse files Browse the repository at this point in the history
Follow-up to 3affd63

Fixes #876

PiperOrigin-RevId: 644190687
  • Loading branch information
cushon authored and google-java-format Team committed Jun 18, 2024
1 parent 3affd63 commit f7543b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.googlejavaformat.Indent;
import com.google.googlejavaformat.OpsBuilder;
import com.google.googlejavaformat.OpsBuilder.BlankLineWanted;
import com.google.googlejavaformat.java.JavaInputAstVisitor;
Expand Down Expand Up @@ -233,11 +232,10 @@ public Void visitCase(CaseTree node, Void unused) {
&& !node.getBody().getKind().equals(Tree.Kind.BLOCK)
? plusFour
: ZERO);
Indent commentIndent = node.getCaseKind().equals(CaseTree.CaseKind.RULE) ? ZERO : plusTwo;
if (isDefault) {
token("default", commentIndent);
token("default", ZERO);
} else {
token("case", commentIndent);
token("case", ZERO);
builder.open(labels.size() > 1 ? plusFour : ZERO);
builder.space();
boolean afterFirstToken = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class T {
void g(String v) {
int x =
switch (v) {
// this is a line comment about "zero"
// this is a line comment about "zero"
case "zero":
return 0;
case "one":
Expand Down

0 comments on commit f7543b2

Please sign in to comment.