1
2
3
4
5 package com . puppycrawl
6 .tools.
7 checkstyle.checks.whitespace.typecastparenpad;
8
9
10
11
12
13 class InputTypecastParenPadWhitespace
14 {
15
16 private int mVar1=1;
17
18 private int mVar2 =1;
19
20 private int mVar3 = 1;
21
22
23 void method1()
24 {
25 final int a = 1;
26 int b= 1;
27 b=1;
28 b+=1;
29 b -=- 1 + (+ b);
30 b = b ++ + b --;
31 b = ++ b - -- b;
32 }
33
34
35 void method2()
36 {
37 synchronized(this) {
38 }
39 try{
40 }
41 catch(RuntimeException e){
42 }
43 }
44
45
46
47
48
49
50
51 private int mVar4 = 1;
52
53
54
55 private void fastExit()
56 {
57 boolean complicatedStuffNeeded = true;
58 if( !complicatedStuffNeeded )
59 {
60 return;
61 }
62 else
63 {
64
65 }
66 }
67
68
69
70
71
72 private int nonVoid()
73 {
74 if ( true )
75 {
76 return(2);
77 }
78 else
79 {
80 return 2;
81 }
82 }
83
84
85 private void testCasts()
86 {
87 Object o = (Object) new Object();
88 o = (Object)o;
89 o = ( Object ) o;
90 o = (Object)
91 o;
92 }
93
94
95 private void testQuestions()
96 {
97 boolean b = (1 == 2)?true:false;
98 b = (1==2) ? false : true;
99 }
100
101
102 private void starTest()
103 {
104 int x = 2 *3* 4;
105 }
106
107
108 private void boolTest()
109 {
110 boolean a = true;
111 boolean x = ! a;
112 int z = ~1 + ~ 2;
113 }
114
115
116 private void divTest()
117 {
118 int a = 4 % 2;
119 int b = 4% 2;
120 int c = 4 %2;
121 int d = 4%2;
122 int e = 4 / 2;
123 int f = 4/ 2;
124 int g = 4 /2;
125 int h = 4/2;
126 }
127
128
129 private java .lang. String dotTest()
130 {
131 Object o = new java.lang.Object();
132 o.
133 toString();
134 o
135 .toString();
136 o . toString();
137 return o.toString();
138 }
139
140
141 public void assertTest()
142 {
143
144 assert true;
145
146
147 assert true : "Whups";
148
149
150 assert "OK".equals(null) ? false : true : "Whups";
151
152
153 assert(true);
154
155
156 assert true:"Whups";
157 }
158
159
160 void donBradman(Runnable aRun)
161 {
162 donBradman(new Runnable() {
163 public void run() {
164 }
165 });
166
167 final Runnable r = new Runnable() {
168 public void run() {
169 }
170 };
171 }
172
173
174 void rfe521323()
175 {
176 doStuff() ;
177
178 for (int i = 0 ; i < 5; i++) {
179
180 }
181 }
182
183
184
185 private int i ;
186
187 private int i1, i2, i3 ;
188
189 private int i4, i5, i6;
190
191
192 void bug806243()
193 {
194 Object o = new InputTypecastParenPadWhitespace() {
195 private int j ;
196
197 };
198 }
199
200 void doStuff() {
201 }
202 }
203
204
205
206
207
208
209 interface IFoo_TypecastParenPad
210 {
211 void foo() ;
212
213 }
214
215
216
217
218
219
220 class SpecialCasesInForLoop_TypecastParenPad
221 {
222 void forIterator()
223 {
224
225 for (int i = 0; i++ < 5;) {
226
227 }
228
229
230
231 int i = 0;
232 for ( ; i < 5; i++ ) {
233
234 }
235 for (int anInt : getSomeInts()) {
236
237 }
238 }
239
240 int[] getSomeInts() {
241 int i = (int) ( 2 / 3 );
242 return null;
243 }
244
245 public void myMethod() {
246 new Thread() {
247 public void run() {
248 }
249 }.start();
250 }
251
252 public void foo(java.util.List<? extends String[]> bar, Comparable<? super Object[]> baz) { }
253
254 public void mySuperMethod() {
255 Runnable[] runs = new Runnable[] {new Runnable() {
256 public void run() {
257 }
258 },
259 new Runnable() {
260 public void run() {
261 }
262 }};
263 runs[0]
264 .
265 run()
266 ;
267 }
268
269 public void testNullSemi() {
270 return ;
271 }
272
273 public void register(Object obj) { }
274
275 public void doSomething(String args[]) {
276 register(boolean[].class);
277 register( args );
278 }
279
280 public void parentheses() {
281 testNullSemi
282 (
283 )
284 ;
285 }
286
287 public static void testNoWhitespaceBeforeEllipses(String ... args) {
288 }
289 }