diff --git a/config_whitespace.html b/config_whitespace.html index 193da31148..28375582c3 100644 --- a/config_whitespace.html +++ b/config_whitespace.html @@ -2005,19 +2005,178 @@

Examples

<module name="NoWhitespaceAfter"/> -

- To configure the check to forbid linebreaks after a DOT token: -

- + To configure check to restrict use of whitespace after DOT token: +

+ +
+
+<module name="NoWhitespaceAfter">
+  <property name="tokens" value="DOT"/>
+</module>
+  
+ +

Example:

+ +
+
+class CheckDotToken {
+  int a, b;
+  CheckDotToken(int a, int b) {
+    this. a = a; // violation, whitespace after '.' is not allowed
+    this.b = b; // OK
+  }
+
+  public void function() {}
+  public static void main(String[] args) {
+    CheckDotToken ob = new CheckDotToken(5, 7);
+    ob. function(); // violation, whitespace after '.' is not allowed
+    ob.function(); // OK
+    ob. a = 10; // violaion, whitespace after '.' is not allowed
+    ob.b = 17; // OK
+  }
+}
+  
+ +

+ To configure check to allow line breaks after DOT token: +

+
 <module name="NoWhitespaceAfter">
   <property name="tokens" value="DOT"/>
   <property name="allowLineBreaks" value="false"/>
 </module>
-        
- + + +

Example:

+ +
+
+class CheckDotToken {
+  int a, b;
+  CheckDotToken(int a, int b) {
+    this.
+        a = a; // violation, linebreak after '.' is not allowed
+    this.b = b; // OK
+  }
+
+  public void function() {}
+  public static void main(String[] args) {
+    CheckDotToken ob = new CheckDotToken(5, 7);
+    ob.
+      function(); // violation, linebreak after '.' is not allowed
+    ob.function(); // OK
+    ob. 
+      a = 10; // violation, linebreak after '.' is not allowed
+    ob.b = 17; // OK
+  }
+}
+
+ +

+ To configure check to restrict use of whitespace after ARRAY_DECLARATOR token: +

+ +
+
+<module name="NoWhitespaceAfter">
+  <property name="tokens" value="ARRAY_DECLARATOR"/>
+</module>
+  
+ +

Example:

+ +
+
+int [] array1; // violation, whitespace after 'int' is not allowed
+int[] array2; // OK
+int[ ] array3; // OK
+int array4 []; // violation, whitespace after 'array4' is not allowed
+int array5[]; // OK
+int array6[ ]; // OK
+  
+ +

+ To configure check to allow line breaks after ARRAY_DECLARATOR token: +

+ +
+
+<module name="NoWhitespaceAfter">
+  <property name="tokens" value="ARRAY_DECLARATOR"/>
+  <property name="allowLineBreaks" value="false"/>
+</module>
+  
+ +

Example:

+ +
+
+int 
+  [] array1; // violation, linebreak after 'int' is not allowed
+int[ 
+    ] array2; // OK
+int array3
+    []; // violation, linebreak after 'a' is not allowed
+int array4[ 
+      ]; // OK
+
+ +

+ To configure check to restrict use of whitespace after ARRAY_INIT token: +

+ +
+
+<module name="NoWhitespaceAfter">
+  <property name="tokens" value="ARRAY_INIT"/>
+</module>
+  
+ +

Example:

+ +
+
+int[] array1 = { 1, 2, 3, 4}; // violation, whitespace after '{' is not allowed
+int[] array2 = {1, 2, 3, 4 }; // OK
+int[][] array3 = {{ 1,2}, {3,4}} // violation, whitespace after '{' is not allowed
+int[][] array4 = {{1,2}, {3,4} } // OK
+int[][] array5 = new int[]{ 1,2,3,4} // violation, whitespace after '{' is not allowed
+    
+ +

+ To configure check to allow line breaks after ARRAY_INIT token: +

+ +
+
+<module name="NoWhitespaceAfter">
+  <property name="tokens" value="ARRAY_INIT"/>
+  <property name="allowLineBreaks" value="false"/>
+</module>
+  
+ +

Example:

+ +
+
+int[] array1 = {
+                1,
+                2
+               }; // violation, linebreak after '{' is not allowed
+int[] array2 = {1,2
+               };// OK
+int[] array3 = {
+                {1,2},
+                {3,4}
+               }; // violation, linebreak after '{' is not allowed
+int[][] array4 = {{1,2},
+                  {3,4}
+                 }; // OK
+  
+

If the annotation is between the type and the array, the check will skip validation for spaces: