1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// comment
package com.puppycrawl.tools.checkstyle.checks.indentation;
import java.util.*;
// some
public class InputCommentsIndentationSurroundingCode
{
private void foo() {
if (true) {
// here initialize some variables
int k = 0; // trailing comment
// initialize b
int b = 10;
// sss
}
}
private void foo1() {
if (true) {
/* some */
int k = 0;
/* some */
int b = 10;
/*
* */
double d; /* trailing comment */
/*
*
*/
boolean bb;
/***/
/* my comment*/
/*
*
*
* some
*/
/*
* comment
*/
boolean x;
}
}
private void foo3() {
int a = 5, b = 3, v = 6;
if (a == b
&& v == b || ( a ==1
/// What about that case ? the same for block comments
/*
* one fine day ... */
&& b == 1) ) {
// code
}
}
// Comments here should be ok by Check
@SuppressWarnings("unused") // trailing
private static void check () { // trailing
if (true) // trailing comment
{
// some comment
}
if (true) { // trailing comment
}
/**
*
*/
}
private static void com() {
/* here's my weird trailing comment */ boolean b = true;
}
private static void cases() {
switch("") {
case "0": //some comment
case "1":
// my comment
com();
break;
case "2":
// my comment
//comment
check();
// comment
break;
case "3":
/* com */
check();
/* com */
break;
case "5":
check();
// fall through
case "6":
int k = 7;
// fall through
case "7":
if (true) {}
// fall through
case "8":
break;
default:
// comment
break;
}
}
private static final String[][] mergeMatrix = {
// TOP ALWAYS NEVER UNKNOWN
/* TOP */{ "", },
/* ALWAYS */{ "", "", },
/* NEVER */{ "NEVER", "UNKNOWN", "NEVER", },
/* UNKNOWN */{ "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN" }, };
private void foo4() {
if (!Arrays.equals(new String[]{""}, new String[]{""})
/* wierd trailing comment */) {
}
}
/**
* some javadoc
*/
private static void l() {}
private void foo32() {
if (true) {
switch(1) {
case 0:
case 1:
// initialize b
int b = 10;
}
}
}
} // The Check should not throw NPE here!
|