1 package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
2
3
4
5
6
7
8
9
10
11 class InputWhitespaceAroundBasic {
12 private final int var1= 1;
13 private final int var2 =1;
14
15
16 private final int var3 = 1;
17
18
19 private final int var4 = 1;
20
21 int xyz;
22 int abc;
23 int pqr;
24
25
26 private int test;
27
28 private int i4, i5, i6;
29
30
31
32 void method1() {
33 final int a = 1;
34 int b= 1;
35 b= 1;
36 b +=1;
37 b -=- 1 + (+ b);
38 b = b++ + b--;
39 b = ++ b - -- b;
40 }
41
42
43 void method2() {
44 synchronized(this) {
45
46
47
48 }
49 try{
50
51
52
53
54 } catch (RuntimeException e) {
55 }
56 }
57
58
59 private void fastExit() {
60 boolean complicatedStuffNeeded = true;
61
62
63
64 if(!complicatedStuffNeeded) {
65
66 } else {
67
68 }
69 }
70
71
72
73
74
75
76 private int nonVoid() {
77 if (true) {
78 return(2);
79
80
81
82 } else {
83 return 2;
84 }
85 }
86
87
88 private void testCasts() {
89 Object o = (Object) new Object();
90 o = (Object) o;
91 o = ( Object ) o;
92 o = (Object)
93 o;
94 }
95
96
97 private void testQuestions() {
98
99 boolean b = (1 ==2) ? false : true;
100 }
101
102
103 private void starTest() {
104 int x = 2 * 3* 4;
105 }
106
107
108 private void boolTest() {
109 boolean a = true;
110 boolean x = !a;
111 int z = ~1 + ~2;
112 }
113
114
115 private void divTest() {
116 int a = 4 % 2;
117 int b = 4% 2;
118 int c = 4 %2;
119 int d = 4% 2;
120 int e = 4 / 2;
121 int f = 4/ 2;
122 int g = 4 /2;
123 }
124
125
126
127
128
129
130 private java.lang.String dotTest() {
131 Object o = new java.lang.Object();
132 o.toString();
133 o.toString();
134 o.toString();
135 return o.toString();
136 }
137
138
139 public void assertTest() {
140
141 assert true;
142
143
144 assert true : "Whups";
145
146
147 assert "OK".equals(null) ? false : true : "Whups";
148
149
150 assert(true);
151
152
153 assert true: "Whups";
154 }
155
156
157 void donBradman(Runnable run) {
158 donBradman(
159 new Runnable() {
160 public void run() {}
161 });
162
163 final Runnable r =
164 new Runnable() {
165 public void run() {}
166 };
167 }
168
169
170 void rfe521323() {
171 doStuff();
172 for (int i = 0; i < 5; i++) {}
173 }
174
175
176 void bug806243() {
177 Object o =
178 new InputWhitespaceAroundBasic() {
179 private int test;
180 };
181 }
182
183 void doStuff() {}
184
185 interface Foo {
186 void foo();
187 }
188
189
190
191
192
193
194
195 class SpecialCasesInForLoop {
196 void forIterator() {
197
198 for (int i = 0; i++ < 5; ) {
199
200 }
201
202
203
204 int i = 0;
205 for (; i < 5; i++) {
206
207 }
208 for (int anInt : getSomeInts()) {
209
210 }
211 }
212
213 int[] getSomeInts() {
214 int i = 2 / 3;
215 return null;
216 }
217
218 void forColon() {
219 int[] ll = new int[10];
220 for (int x:ll) {}
221
222
223
224 for (int x :ll) {}
225 for (int x: ll) {}
226 for (int x : ll) {}
227 }
228 }
229
230
231 class NewGoogleOperators {
232 NewGoogleOperators() {
233 Runnable l;
234
235 l = ()-> {};
236 l = () ->{};
237
238
239
240 l = () -> {};
241 l = () -> {};
242
243 java.util.Arrays.sort(null, String::compareToIgnoreCase);
244 java.util.Arrays.sort(null, String::compareToIgnoreCase);
245
246 new Object().toString();
247 new Object().toString();
248 }
249 }
250 }