View Javadoc
1   package com.google.checkstyle.test.chapter4formatting.rule4861blockcommentstyle;
2   
3   /** some javadoc. */
4   public class InputFormattedCommentsIndentationInSwitchBlock {
5   
6     private static void fooSwitch() {
7       switch ("") {
8         case "0": // some comment
9         case "1":
10          // my comment
11          foo1();
12          break;
13        case "2":
14          // my comment
15          // comment
16          foo1();
17          // comment
18          break;
19        case "3":
20          /* // odd indentation comment
21           *  */
22  
23          foo1();
24          /* com */
25          break;
26        case "5":
27          foo1();
28          // odd indentation comment
29          break;
30        case "6":
31          int k = 7;
32        // fall through
33        case "7":
34          if (true) {
35            /* foo */
36          }
37          // odd indentation comment
38          break;
39        case "8":
40          break;
41        case "9":
42          foo1();
43        // fall through
44        case "10":
45          {
46            if (true) {
47              /* foo */
48            }
49          }
50        // fall through
51        case "11":
52          {
53          }
54        // fall through
55        case "28":
56          {
57          }
58        // fall through
59        case "12":
60          {
61            // odd indentation comment
62  
63            int i;
64          }
65          break;
66        case "13":
67          {
68            // some comment in empty case block
69          }
70          break;
71        case "14":
72          {
73            // odd indentation comment
74  
75          }
76          break;
77        case "15":
78          {
79            foo1();
80            // odd indentation comment
81          }
82          break;
83        case "16":
84          {
85            int a;
86          }
87        // fall through
88        case "17":
89          {
90            int a;
91          }
92  
93          // odd indentation comment
94          break;
95        case "18":
96          {
97            System.lineSeparator();
98          } // trailing comment
99          break;
100       case "19":
101       // comment
102       case "20":
103       // comment
104       case "21":
105       default:
106         // comment
107         break;
108     }
109   }
110 
111   private static void foo1() {
112     if (true) {
113       switch (1) {
114         case 0:
115 
116         case 1:
117 
118           // odd indentation comment
119           int b = 10;
120           break;
121         default:
122           // comment
123       }
124     }
125   }
126 
127   /** some javadoc. */
128   public void fooDotInCaseBlock() {
129     int i = 0;
130     String s = "";
131 
132     switch (i) {
133       case -2:
134         // what
135         i++;
136         break;
137       case 0:
138         // what
139         s.indexOf("ignore");
140         break;
141       case -1:
142         // what
143 
144         s.indexOf("no way");
145         // odd indentation comment
146         break;
147       case 1:
148       case 2:
149         i--;
150         break;
151       case 3:
152         {
153         }
154       // fall through
155       default:
156     }
157 
158     String breaks =
159         ""
160 
161             // odd indentation comment
162             + "</table>"
163             // middle
164             + ""
165         // end
166         ;
167   }
168 
169   /** some javadoc. */
170   public void foo2() {
171     int a = 1;
172     switch (a) {
173       case 1:
174       default:
175         // odd indentation comment
176     }
177   }
178 
179   /** some javadoc. */
180   public void foo3() {
181     int a = 1;
182     switch (a) {
183       case 1:
184       default:
185 
186         // comment
187     }
188   }
189 
190   /** some javadoc. */
191   public void foo4() {
192     int a = 1;
193     switch (a) {
194       case 1:
195         int b;
196         // odd indentation comment
197         break;
198       default:
199     }
200   }
201 
202   /** some javadoc. */
203   public void foo5() {
204     int a = 1;
205     switch (a) {
206       case 1:
207         int b;
208         // comment
209         break;
210       default:
211     }
212   }
213 
214   /** some javadoc. */
215   public void foo6() {
216     int a = 1;
217     switch (a) {
218       case 1:
219         int b;
220         // comment
221         break;
222       default:
223     }
224   }
225 
226   /** some javadoc. */
227   public void foo7() {
228     int a = 2;
229     String s = "";
230     switch (a) {
231       // comment
232       // comment
233       // comment
234       case 1:
235       case 2:
236         // comment
237         // comment
238         foo1();
239         // comment
240         break;
241       case 3:
242       // comment
243       // comment
244       // comment
245 
246       case 4:
247       // odd indentation comment
248       case 5:
249         s.toString().toString().toString();
250         // odd indentation comment
251         // odd indentation comment
252         // odd indentation comment
253         break;
254       default:
255     }
256   }
257 
258   /** some javadoc. */
259   public void foo8() {
260     int a = 2;
261     String s = "";
262     switch (a) {
263       // comment
264       // comment
265       // comment
266       case 1:
267       case 2:
268         // comment
269         // comment
270         foo1();
271         // comment
272         break;
273       case 3:
274         // comment
275         // comment
276         s.toString().toString().toString();
277         // comment
278 
279         break;
280       case 4:
281       // odd indentation comment
282       default:
283     }
284   }
285 
286   /** some javadoc. */
287   public void foo9() {
288     int a = 5;
289     switch (a) {
290       case 1:
291       case 2:
292       // comment
293       default:
294     }
295   }
296 
297   /** some javadoc. */
298   public void foo10() {
299     int a = 5;
300     switch (a) {
301       case 1:
302       default:
303         // comment
304     }
305   }
306 
307   /** some javadoc. */
308   public void foo11() {
309     int a = 5;
310     switch (a) {
311       case 1:
312       case 2:
313       // comment
314       default:
315     }
316   }
317 
318   /** some javadoc. */
319   public void foo12() {
320     int a = 5;
321     switch (a) {
322       // comment
323       case 1:
324       default:
325     }
326   }
327 }