forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputOperatorWrapEol.java
73 lines (60 loc) · 1.9 KB
/
InputOperatorWrapEol.java
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
/*
OperatorWrap
option = eol
tokens = ASSIGN,COLON,LAND,LOR,STAR,QUESTION
*/
package com.puppycrawl.tools.checkstyle.checks.whitespace.operatorwrap;
import java.io.*; // Star import here as the check handles all TokenTypes.STAR
class InputOperatorWrapEol
{
{
int x1 = // ok
1 * // ok
2;
int x2
= 1 // violation ''=' should be on the previous line.'
* 2; // violation ''*' should be on the previous line.'
int x3 = ((2 * 1)
) * 0 * (1 * 2) * 0; // ok, parens
}
public InputOperatorWrapEol() throws IOException {
label: try (Reader r = // ok
null) {
}
try (Reader r
= null) { // violation ''=' should be on the previous line.'
}
int x = (1 < 2) ? // ok
false ? "".substring(0,
0).length()
: false // violation '':' should be on the previous line.'
? 2 : 3 : 4; // violation ''?' should be on the previous line.'
for (int value : // ok
new int[0]) {}
for (int value
: new int[0]) {} // violation '':' should be on the previous line.'
int[] a1 = // ok
{};
int[] a2
= {}; // violation ''=' should be on the previous line.'
int[] a3 = { // ok
};
}
void comment(int magic) {
if (magic != 0x31 && // '1' // ok
magic != 0x41 && // ')' // ok
magic != 0x59 // 'Y'
) {
}
if (magic == 0x32 // '2'
|| magic == 0x41 // violation ''\|\|' should be on the previous line.'
|| magic == 0x58 // violation ''\|\|' should be on the previous line.'
) {
}
}
int a;
void shortName(int oa) {
a=oa; // ok
a+=2; // ok
}
}