google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.49k stars 848 forks source link

Adjust indentation of line comments inside expression switches #1111

Closed copybara-service[bot] closed 3 weeks ago

copybara-service[bot] commented 3 weeks ago

Adjust indentation of line comments inside expression switches

For statement switches there's some ambiguity about whether a comment documents the previous or next case:

  case 1:
    // case 1 falls through to 2
  case 2:
    doSomething()
  // this is information about case 1
  case 1:
  // this is information about case 2
  case 2:
    doSomething()

For expression switches there is no fall through, so assume that a line comments before a case label always apply to the case label after it.