View Javadoc
1   /*
2   CommentsIndentation
3   tokens = (default)SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN
4   
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.checks.indentation.commentsindentation;
9   
10  public class InputCommentsIndentationInSwitchBlockOne {
11  
12      private static void fooSwitch() {
13          switch("") {
14              case "0": //some comment
15              case "1":
16                  // my comment
17                  foo1();
18                  break;
19              case "2":
20                  // my comment
21                  //comment
22                  foo1();
23                  // comment
24                  break;
25              case "3":
26                  // violation below '.* incorrect .* level 12, expected is 16,.* same.* as line 28.'
27              /* violation */
28                  foo1();
29                  /* com */
30                  break;
31              case "5":
32                  foo1();
33                     // violation '.* incorrect .* level 19, expected is 16, 12, .* as line 32, 34.'
34              case "6":
35                  int k = 7;
36                  // fall through
37              case "7":
38                  if (true) {}
39                     // violation '.* incorrect .* level 19, expected is 16, 12, .* as line 38, 40.'
40              case "8":
41                  break;
42              case "9":
43                  foo1();
44                  // fall through
45              case "10": {
46                  if (true) {}
47                  // fall through
48              }
49              case "11": {
50              // fall through
51              }
52              case "28": {
53                  // fall through
54              }
55              case "12": {
56        // violation '.* incorrect .* level 6, expected is 16, .* same .* as line 57.'
57                  int i;
58              }
59              case "13": {
60                         // some comment in empty case block
61              }
62              case "14": {
63          // violation '.* incorrect .* level 8, expected is 12, .* same .* as line 64.'
64              }
65              case "15": {
66                  foo1();
67                        // violation '.* incorrect .* level 22, expected is 16,.* same.* as line 66.'
68              }
69              case "16": {
70                  int a;
71              }
72              // fall through
73              case "17": {
74                  int a;
75              }
76                // violation '.* incorrect .* level 14, expected is 12, 16,.* same.* as line 73, 77.'
77                  case "18": { System.lineSeparator();
78                  }   // trailing comment
79              case "19":
80                  // comment
81              case "20":
82              // comment
83              case "21":
84              default:
85                  // comment
86                  break;
87          }
88      }
89  
90      private static void foo1() {
91          if (true) {
92              switch(1) {
93                  case 0:
94  
95                  case 1:
96                          // violation '.* incorrect .* level 24, expected is 20,.*same.* as line 97.'
97                      int b = 10;
98                  default:
99                   // comment
100             }
101 
102         }
103     }
104 }