public class MultipleVariableDeclarationsExtendedCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Checks that each variable declaration is in its own statement and on its own line.
Rationale: the SUN Code conventions chapter 6.1 recommends that declarations should be one per line.
An example of how to configure the check is:
<module name="MultipleVariableDeclarations"/>
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_VAR_DECLARATIONS
Warning message key.
|
static String |
MSG_VAR_DECLARATIONS_COMMA
Warning message key.
|
| Constructor and Description |
|---|
MultipleVariableDeclarationsExtendedCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setIgnoreCycles(boolean value)
Enable|Disable declaration checking in cycles.
|
void |
setIgnoreMethods(boolean value)
Enable|Disable declaration checking in Methods.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) |
void |
work(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
Searches for wrong declarations and checks the their type.
|
beginTree, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic static final String MSG_VAR_DECLARATIONS_COMMA
public static final String MSG_VAR_DECLARATIONS
public MultipleVariableDeclarationsExtendedCheck()
public void setIgnoreCycles(boolean value)
value - check declaration in Methodspublic void setIgnoreMethods(boolean value)
value - check declaration in Methodspublic int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void work(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
ast - uses to get the parent or previous sibling token.public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.