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