1   // comment
2   package com.puppycrawl.tools.checkstyle.checks.indentation.commentsindentation;
3   
4   import java.util.*;
5   
6   // some
7   public class InputCommentsIndentationSurroundingCode
8   {
9       private void foo1() {
10          if (true) {
11              // here initialize some variables
12              int k = 0; // trailing comment
13                // violation
14              int b = 10;
15              // sss
16          }
17      }
18  
19      private void foo2() {
20          if (true) {
21              /* some */
22              int k = 0;
23                  /* violation */
24              int b = 10;
25                  /* violation
26                   * */
27              double d; /* trailing comment */
28                  /* violation
29               *
30                  */
31              boolean bb;
32              /***/
33              /* my comment*/
34              /*
35               *
36               *
37               *  some
38               */
39              /*
40               * comment
41               */
42              boolean x;
43          }
44      }
45  
46      private void foo3() {
47          int a = 5, b = 3, v = 6;
48          if (a == b
49              && v == b || ( a ==1
50                             /// violation
51                         /* violation
52                          * one fine day ... */
53                                      && b == 1)   ) {
54          }
55      }
56  
57      private static void com() {
58          /* here's my weird trailing comment */ boolean b = true;
59      }
60  
61      private static final String[][] mergeMatrix = {
62          // This example of trailing block comments was found in PMD sources.
63          /* TOP */{ "", },
64          /* ALWAYS */{ "", "", },
65         /* NEVER */{ "NEVER", "UNKNOWN", "NEVER", },
66         /* UNKNOWN */{ "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN" }, };
67  
68      private void foo4() {
69          if (!Arrays.equals(new String[]{""}, new String[]{""})
70                /* wierd trailing comment */) {
71          }
72      }
73      /**
74       * some javadoc
75       */
76      private static void l() {
77      }
78  
79      public void foid5() {
80          String s = "";
81          s.toString().toString().toString();
82          // comment
83      }
84  
85      public void foo6() {
86                // comment
87                // ...
88                // block
89                // ...
90                // violation
91          String someStr = new String();
92      }
93  
94      public void foo7() {
95               // comment
96               // ...
97               // block
98               // violation
99          // comment
100         String someStr = new String();
101     }
102 
103     public void foo8() {
104         String s = new String(); // comment
105                                  // ...
106                                  // block
107                                  // ...
108                                  // violation
109         String someStr = new String();
110     }
111 
112 
113     public String foo9(String s1, String s2, String s3) {
114         return "";
115     }
116 
117     public void foo10()
118         throws Exception {
119 
120         final String pattern = "^foo$";
121 
122         final String[] expected = {
123             "7:13: " + foo9("", "", ""),
124             // comment
125         };
126     }
127 
128     public void foo11() {
129 
130             /* empty */
131         hashCode();
132     }
133 
134     public void foo12() {
135     /* empty */
136         hashCode();
137     }
138 
139     public void foo13() {
140         hashCode();
141     /* empty */
142     }
143 
144     public void foo14() {
145         hashCode();
146         /*
147 
148         Test
149         */
150         // Test
151     }
152 
153     public InputCommentsIndentationSurroundingCode() {
154     }
155 
156     // Test
157 } // The Check should not throw NPE here!
158 // The Check should not throw NPE here!