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 InputCommentsIndentationInSwitchBlockTwo {
11  
12      private static void foo1() {
13          if (true) {
14              switch(1) {
15                  case 0:
16  
17                  case 1:
18                          // violation '.* incorrect .* level 24, expected is 20,.*same.* as line 19.'
19                      int b = 10;
20                  default:
21                   // comment
22              }
23  
24          }
25      }
26  
27      public void fooDotInCaseBlock() {
28          int i = 0;
29          String s = "";
30  
31          switch (i) {
32              case -2:
33                  // what
34                  i++;
35                  // no break here
36              case 0:
37                  // what
38                  s.indexOf("ignore");
39                  // no break here
40              case -1:
41                   // what
42                   s.indexOf("no way");
43                 // violation '.* incorrect.*level 15, expected is 17, 12,.*same.* as line 42, 44.'
44              case 1:
45              case 2:
46                  i--;
47                  // no break here
48              case 3: { }
49              // fall through
50  
51  
52          }
53  
54          String breaks = ""
55          // violation '.* incorrect .* level 8, expected is 12, .* same .* as line 56.'
56              + "</table>"
57              // middle
58              + ""
59          // end
60          ;
61      }
62  
63      public void foo2() {
64          int a = 1;
65          switch (a) {
66              case 1:
67              default:
68      // violation '.* incorrect .* level 4, expected is 8, .* same .* as line 69.'
69          }
70      }
71  
72      public void foo3() {
73          int a = 1;
74          switch (a) {
75              case 1:
76              default:
77  
78                  // comment
79          }
80      }
81  
82      public void foo4() {
83          int a = 1;
84          switch (a) {
85              case 1:
86                  int b;
87                    // violation '.* incorrect .* level 18, expected is 16, 12, .* as line 86, 88.'
88              default:
89          }
90      }
91  
92      public void foo5() {
93          int a = 1;
94          switch (a) {
95              case 1:
96                  int b;
97              // comment
98              default:
99          }
100     }
101 
102     public void foo6() {
103         int a = 1;
104         switch (a) {
105             case 1:
106                 int b;
107                 // comment
108             default:
109         }
110     }
111 }