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, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public EmptyLineSeparatorCheck()
public final void setAllowNoEmptyLineBetweenFields(boolean aAllow)
aAllow
- User's value.public int[] getDefaultTokens()
Check
getDefaultTokens
in class Check
TokenTypes
public void visitToken(DetailAST aAST)
Check
visitToken
in class Check
aAST
- the token to processCopyright © 2001–2019. All rights reserved.