1 /*
2 OperatorWrap
3 option = eol
4 tokens = ASSIGN,COLON,LAND,LOR,STAR,QUESTION
5
6
7 */
8
9 package com.puppycrawl.tools.checkstyle.checks.whitespace.operatorwrap;
10
11 import java.io.*; // Star import here as the check handles all TokenTypes.STAR
12
13 class InputOperatorWrapEol
14 {
15 {
16 int x1 =
17 1 *
18 2;
19
20 int x2
21 = 1 // violation ''=' should be on the previous line.'
22 * 2; // violation ''*' should be on the previous line.'
23
24 int x3 = ((2 * 1)
25 ) * 0 * (1 * 2) * 0; // ok, parens
26 }
27
28 public InputOperatorWrapEol() throws IOException {
29 label: try (Reader r =
30 null) {
31 }
32 try (Reader r
33 = null) { // violation ''=' should be on the previous line.'
34 }
35 int x = (1 < 2) ?
36 false ? "".substring(0,
37 0).length()
38 : false // violation '':' should be on the previous line.'
39 ? 2 : 3 : 4; // violation ''?' should be on the previous line.'
40
41 for (int value :
42 new int[0]) {}
43 for (int value
44 : new int[0]) {} // violation '':' should be on the previous line.'
45
46 int[] a1 =
47 {};
48 int[] a2
49 = {}; // violation ''=' should be on the previous line.'
50 int[] a3 = {
51 };
52 }
53
54 void comment(int magic) {
55 if (magic != 0x31 && // '1'
56 magic != 0x41 && // ')'
57 magic != 0x59 // 'Y'
58 ) {
59 }
60 if (magic == 0x32 // '2'
61 || magic == 0x41 // violation ''\|\|' should be on the previous line.'
62 || magic == 0x58 // violation ''\|\|' should be on the previous line.'
63 ) {
64 }
65 }
66
67 int a;
68 void shortName(int oa) {
69 a=oa;
70 a+=2;
71 }
72
73 }