public class WhitespaceAfterCheck extends AbstractCheck
Checks that a token is followed by whitespace, with the exception that it does not check for whitespace after the semicolon of an empty for iterator. Use Check EmptyForIteratorPad to validate empty for iterators.
tokens - tokens to check
Type is int[].
Default value is:
COMMA,
SEMI,
TYPECAST,
LITERAL_IF,
LITERAL_ELSE,
LITERAL_WHILE,
LITERAL_DO,
LITERAL_FOR,
DO_WHILE.
To configure the check:
<module name="WhitespaceAfter"/>
Example:
public void myTest() {
if (foo) { // OK
//...
} else if(bar) { // violation
//...
}
testMethod(foo, bar); // OK
testMethod(foo,bar); // violation
for (;;){} // OK
for(;;){} // violation, space after 'for' is required
}
To configure the check for whitespace only after COMMA and SEMI tokens:
<module name="WhitespaceAfter"> <property name="tokens" value="COMMA, SEMI"/> </module>
Example:
public void myTest() {
int a; int b; // OK
int a;int b; // violation
testMethod(foo, bar); // OK
testMethod(foo,bar); // violation
for(;;) {} // OK
}
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
ws.notFollowed
ws.typeCast
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_WS_NOT_FOLLOWED
A key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_WS_TYPECAST
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
WhitespaceAfterCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
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, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final String MSG_WS_NOT_FOLLOWED
public static final String MSG_WS_TYPECAST
public WhitespaceAfterCheck()
public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processCopyright © 2001–2020. All rights reserved.