View Javadoc
1   /*
2   CommentsIndentation
3   tokens = SINGLE_LINE_COMMENT
4   
5   
6   */
7   
8   // comment
9   package com.puppycrawl.tools.checkstyle.checks.indentation.commentsindentation;
10  
11  import java.util.Arrays;
12  
13  // some
14  public class InputCommentsIndentationSurroundingCode2One
15  {
16      private void foo1() {
17          if (true) {
18              // here initialize some variables
19              int k = 0; // trailing comment
20                // violation '.* incorrect .* level 14, expected is 12, .* same .* as line 21.'
21              int b = 10;
22              // sss
23          }
24      }
25  
26      private void foo2() {
27          if (true) {
28              /* some */
29              int k = 0;
30                  /* violation */
31              int b = 10;
32                  /* violation
33                   * */
34              double d; /* trailing comment */
35                  /* violation
36               *
37                  */
38              boolean bb;
39              /***/
40              /* my comment*/
41              /*
42               *
43               *
44               *  some
45               */
46              /*
47               * comment
48               */
49              boolean x;
50          }
51      }
52  
53      private void foo3() {
54          int a = 5, b = 3, v = 6;
55          if (a == b
56              && v == b || ( a ==1
57                             /// violation '.* incorrect .* level 27, expected is 36, .* as line 60.'
58                         /* violation
59                          * one fine day ... */
60                                      && b == 1)   ) {
61          }
62      }
63  
64      private static void com() {
65          /* here's my weird trailing comment */ boolean b = true;
66      }
67  
68      private static final String[][] mergeMatrix = {
69          // This example of trailing block comments was found in PMD sources.
70          /* TOP */{ "", },
71          /* ALWAYS */{ "", "", },
72         /* NEVER */{ "NEVER", "UNKNOWN", "NEVER", },
73         /* UNKNOWN */{ "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN" }, };
74  
75      private void foo4() {
76          if (!Arrays.equals(new String[]{""}, new String[]{""})
77                /* wierd trailing comment */) {
78          }
79      }
80      /**
81       * some javadoc
82       */
83      private static void l() {
84      }
85  
86      public void foid5() {
87          String s = "";
88          s.toString().toString().toString();
89          // comment
90      }
91  
92      public void foo6() {
93                // comment
94                // ...
95                // block
96                // ...
97                // violation '.* incorrect .* level 14, expected is 8, .* same .* as line 98.'
98          String someStr = new String();
99      }
100 
101     public void foo7() {
102              // comment
103              // ...
104              // block
105              // violation '.* incorrect .* level 13, expected is 8, .* same .* as line 107.'
106         // comment
107         String someStr = new String();
108     }
109 
110     public void foo8() {
111         String s = new String(); // comment
112                                  // ...
113                                  // block
114                                  // ...
115                                  // violation '.*incorrect.*level 33, expected is 8,.*as line 116.'
116         String someStr = new String();
117     }
118     // Test
119 }