public class EmptyLineSeparatorCheck extends Check
By default the check will check the following statements:
PACKAGE_DEF,
IMPORT,
CLASS_DEF,
INTERFACE_DEF,
STATIC_INIT,
INSTANCE_INIT,
METHOD_DEF,
CTOR_DEF,
VARIABLE_DEF.
Example of declarations without empty line separator:
///////////////////////////////////////////////////
//HEADER
///////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.whitespace;
import java.io.Serializable;
class Foo
{
public static final int FOO_CONST = 1;
public void foo() {} //should be separated from previous statement.
}
An example of how to configure the check with default parameters is:
<module name="EmptyLineSeparator"/>
Example of declarations with empty line separator that is expected by the Check by default:
///////////////////////////////////////////////////
//HEADER
///////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.whitespace;
import java.io.Serializable;
class Foo
{
public static final int FOO_CONST = 1;
public void foo() {}
}
An example how to check empty line after
VARIABLE_DEF and
METHOD_DEF:
<module name="EmptyLineSeparator">
<property name="tokens" value="VARIABLE_DEF, METHOD_DEF"/>
</module>
An example how to allow no empty line between fields:
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
| Constructor and Description |
|---|
EmptyLineSeparatorCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
void |
setAllowNoEmptyLineBetweenFields(boolean aAllow)
Allow no empty line between fields.
|
void |
visitToken(DetailAST aAST)
Called to process a token.
|
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLine, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverityconfigure, contextualize, finishLocalSetup, getConfiguration, setupChildpublic final void setAllowNoEmptyLineBetweenFields(boolean aAllow)
aAllow - User's value.public int[] getDefaultTokens()
CheckgetDefaultTokens in class CheckTokenTypespublic void visitToken(DetailAST aAST)
CheckvisitToken in class CheckaAST - the token to processCopyright © 2001-2014. All Rights Reserved.