View Javadoc
1   // comment
2   package com.google.checkstyle.test.chapter4formatting.rule4861blockcommentstyle;
3   
4   import java.util.Arrays;
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                // warn
14              int b = 10;
15              // sss
16          }
17      }
18  
19      private void foo2() {
20          if (true) {
21              /* some */
22              int k = 0;
23                  /* // warn */
24              int b = 10;
25                  /* // warn
26                   * */
27              double d; /* trailing comment */
28                  /* // warn
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                             /// // warn
51                         /* // warn
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                // warn
91          String someStr = new String();
92      }
93  
94      public void foo7() {
95               // comment
96               // ...
97               // block
98               // warn
99          // comment
100         String someStr = new String();
101     }
102 
103     public void foo8() {
104         String s = new String(); // comment
105                                  // ...
106                                  // block
107                                  // ...
108                                  // warn
109         String someStr = new String();
110     }
111 
112     public String foo9(String s1, String s2, String s3) {
113         return "";
114     }
115 
116     public void foo10()
117         throws Exception {
118 
119         final String pattern = "^foo$";
120 
121         final String[] expected = {
122             "7:13: " + foo9("", "", ""),
123             // comment
124         };
125     }
126 } // The Check should not throw NPE here!
127 // The Check should not throw NPE here!