View Javadoc
1   /*
2   OperatorWrap
3   option = (default)NL
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 InputOperatorWrapNl
14  {
15      {
16          int x1
17                  = (1
18                  * 2) * (1
19                      * 2);
20          int x2 = // violation ''=' should be on a new line.'
21                  1 * // violation ''*' should be on a new line.'
22                  2 * ""
23                      .length();
24          int x3 = (2 * 1) * 0 * ( // ok, parens
25                  1 * 2) * 0;
26      }
27  
28      public InputOperatorWrapNl() throws IOException {
29          label: try (Reader r
30                       = null) {
31          }
32          try (Reader r = // violation ''=' should be on a new line.'
33                       null) {
34          }
35          int x = (1 < 2) ? // violation ''?' should be on a new line.'
36              false ? "".substring(0,
37                      0).length() : false
38                  ? 1
39                  : 2 : 3;
40  
41          for (int value
42                  : new int[0]) {}
43          for (int value : // violation '':' should be on a new line.'
44                  new int[0]) {}
45  
46          int[] a1
47                  = {};
48          int[] a2 = // violation ''=' should be on a new line.'
49                  {};
50          int[] a3 = {
51          };
52      }
53  
54      void comment(int magic) {
55          if (magic == 0x32 // '2'
56                  || magic == 0x41 // ')'
57                  || magic == 0x58 // 'X'
58          ) {
59          }
60          if (magic != 0x31 && // violation ''&&' should be on a new line.'
61                  magic != 0x41 && // violation ''&&' should be on a new line.'
62                  magic != 0x59 // 'Y'
63          ) {
64          }
65      }
66  
67      int a;
68      void shortName(int oa) {
69          a=oa;
70          a+=2;
71      }
72  
73  }