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