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 InputCommentsIndentationInEmptyBlock {
11  
12      private void foo1() {
13          int a = 5, b = 3, v = 6;
14          if (a == b
15              && v == b || ( a ==1
16                     /// violation '.* incorrect .* level 19, expected is 31, .* same .* as line 19.'
17                         /* // violation '.* incorrect .* level 23, expected is 31, .* as line 19.'
18                          * one fine day ... */
19                                 && b == 1)   ) {
20              // Cannot clearly detect user intention of explanation target.
21          }
22      }
23  
24      private void foo2() {
25          int a = 5, b = 3, v = 6;
26          if (a == b
27              && v == b || ( a ==1
28              && b == 1)   ) {
29  
30  
31               // comment
32          }
33      }
34  
35      private void foo3() {
36          int a = 5, b = 3, v = 6;
37          if (a == b
38              && v == b || (a == 1
39              && b == 1)) {
40  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 41.'
41          }
42      }
43  
44      // Comments here should be ok by Check
45      @SuppressWarnings("unused") // trailing
46      private static void foo4() { // trailing
47          if (true) // trailing comment
48          {
49              // some comment
50          }
51          if (true) { // trailing comment
52  
53          }
54          /**
55           *
56           */
57      }
58  
59      // Comments here should be ok by Check
60      @SuppressWarnings("unused") // trailing
61      private static void foo5() { // trailing
62          if (true) // trailing comment
63          {
64  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 65.'
65          }
66          if (true) { // trailing comment
67  
68          }
69          /**
70           *
71           */
72      }
73  
74      public void foo6() {
75          try {
76  
77          } catch (Exception e) {
78  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 79.'
79          }
80      }
81  
82      public void foo7() {
83          try {
84  
85          } catch (Exception e) {
86              // OOOO: handle exception here
87          }
88      }
89  
90      private static class MyClass extends Object {
91             // no members
92      }
93  
94      private static class MyClass1 extends Object {
95  
96             // no members
97      }
98  
99      public void foo8() {
100         String[] array1 = {
101                 // comment
102         };
103         String[] array2 = {
104                     // comment
105         };
106         String[] array3 = {
107         // comment
108         };
109         String[] array4 = {
110 // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 111.'
111         };
112         String[] array5 = {
113 
114 // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 115.'
115         };
116     }
117 }