Skip to content

Commit

Permalink
Issue checkstyle#7619: Updated doc for EmptyLineSeperator
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatSneakyCoder authored and romani committed Oct 17, 2022
1 parent 21d1219 commit c6005cb
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,34 +119,28 @@
* ///////////////////////////////////////////////////
* //HEADER
* ///////////////////////////////////////////////////
* package com.whitespace; // violation, 'package' should be separated from previous line.
* import java.io.Serializable; // violation, 'import' should be separated from previous line.
* class Foo { // violation, 'CLASS_DEF' should be separated from previous line.
* public static final int FOO_CONST = 1;
* public void foo() {} // violation, 'METHOD_DEF' should be separated from previous line.
* }
* </pre>
* package com.whitespace; // violation , 'package' should be separated from previous line
* import java.io.Serializable; // violation , 'import' should be separated from previous line
*
* <p>
* Example of declarations with empty line separator
* that is expected by the Check by default:
* </p>
* class FirstClass {
*
* <pre>
* ///////////////////////////////////////////////////
* //HEADER
* ///////////////////////////////////////////////////
* int var1 = 1;
* int var2 = 2; // violation , 'VARIABLE_DEF' should be separated from previous line
*
* package com.puppycrawl.tools.checkstyle.whitespace;
*
* import java.io.Serializable;
* int var3 = 3;
*
*
* class Foo {
* public static final int FOO_CONST = 1;
* void method1() {}
* void method2() { // violation , 'METHOD_DEF' should be separated from previous line
* int var4 = 4;
*
* public void foo() {}
*
* int var5 = 5;
* }
* }
* </pre>
*
* <p>
* To check empty line before
* <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">
Expand All @@ -156,11 +150,38 @@
* </p>
*
* <pre>
* &lt;module name=&quot;EmptyLineSeparator&quot;&gt;
* &lt;module name=&quot;EmptyLineSeparator&quot;&gt;
* &lt;property name=&quot;tokens&quot; value=&quot;VARIABLE_DEF, METHOD_DEF&quot;/&gt;
* &lt;/module&gt;
* &lt;/module&gt;
* </pre>
*
* <pre>
* ///////////////////////////////////////////////////
* //HEADER
* ///////////////////////////////////////////////////
* package com.whitespace;
* import java.io.Serializable;
*
* class FirstClass {
*
* int var1 = 1;
* int var2 = 2; // violation , 'VARIABLE_DEF' should be separated from previous line
*
*
* int var3 = 3;
*
*
* void method1() {}
* void method2() { // violation , 'METHOD_DEF' should be separated from previous line
* int var4 = 4;
*
*
* int var5 = 5;
* }
* }
* </pre>
*
*
* <p>
* To allow no empty line between fields:
* </p>
Expand All @@ -175,37 +196,31 @@
* </p>
*
* <pre>
* class Foo {
* int field1; // ok
* double field2; // ok
* long field3, field4 = 10L, field5; // ok
* }
* </pre>
* <p>
* Example of declarations with multiple empty lines between class members (allowed by default):
* </p>
*
* <pre>
* ///////////////////////////////////////////////////
* //HEADER
* ///////////////////////////////////////////////////
* package com.whitespace; // violation , 'package' should be separated from previous line
* import java.io.Serializable; // violation , 'import' should be separated from previous line
*
* class FirstClass {
*
* package com.puppycrawl.tools.checkstyle.whitespace;
* int var1 = 1;
* int var2 = 2;
*
*
*
* import java.io.Serializable;
* int var3 = 3;
*
*
* class Foo {
* public static final int FOO_CONST = 1;
* void method1() {}
* void method2() { // violation , 'METHOD_DEF' should be separated from previous line
* int var4 = 4;
*
*
*
* public void foo() {} // OK
* int var5 = 5;
* }
* }
* </pre>
*
* <p>
* To disallow multiple empty lines between class members:
* </p>
Expand All @@ -218,20 +233,25 @@
* ///////////////////////////////////////////////////
* //HEADER
* ///////////////////////////////////////////////////
* package com.whitespace; // violation , 'package' should be separated from previous line
* import java.io.Serializable; // violation , 'import' should be separated from previous line
*
* class FirstClass {
*
* package com.checkstyle.whitespace; // violation, 'package' has more than 1 empty lines before.
*
* int var1 = 1;
* int var2 = 2; // violation , 'VARIABLE_DEF' should be separated from previous line
*
* import java.io.Serializable; // violation, 'import' has more than 1 empty lines before.
*
* int var3 = 3; // violation , 'VARIABLE_DEF' has more than 1 empty lines before
*
* class Foo { // violation, 'CLASS_DEF' has more than 1 empty lines before.
* public static final int FOO_CONST = 1;
*
* void method1() {} // violation , 'METHOD_DEF' has more than 1 empty lines before
* void method2() { // violation , 'METHOD_DEF' should be separated from previous line
* int var4 = 4;
*
*
* public void foo() {} // violation, 'METHOD_DEF' has more than 1 empty lines before.
* int var5 = 5;
* }
* }
* </pre>
*
Expand Down Expand Up @@ -269,40 +289,28 @@
* ///////////////////////////////////////////////////
* //HEADER
* ///////////////////////////////////////////////////
* package com.whitespace; // violation , 'package' should be separated from previous line
* import java.io.Serializable; // violation , 'import' should be separated from previous line
*
* package com.puppycrawl.tools.checkstyle.whitespace;
* class FirstClass {
*
* class Foo {
* int var1 = 1;
* int var2 = 2; // violation , 'VARIABLE_DEF' should be separated from previous line
*
* public void foo() {
*
* int var3 = 3;
*
* System.out.println(1); // violation, There is more than 1 empty line one after another
* // in previous line.
* }
* }
* </pre>
* <p>
* To disallow multiple empty lines between class members:
* </p>
*
* <pre>
* &lt;module name="EmptyLineSeparator"&gt;
* &lt;property name="allowMultipleEmptyLines" value="false"/&gt;
* &lt;/module&gt;
* </pre>
* <p>Example:</p>
* <pre>
* package com.puppycrawl.tools.checkstyle.whitespace;
*
* class Test {
* private int k;
* void method1() {}
* void method2() { // violation , 'METHOD_DEF' should be separated from previous line
* int var4 = 4; // violation , There is more than 1 empty line after this line
*
*
* private static void foo() {} // violation, 'METHOD_DEF' has more than 1 empty lines before.
*
* int var5 = 5;
* }
* }
* </pre>
*
* <p>
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
* </p>
Expand Down

0 comments on commit c6005cb

Please sign in to comment.