public class NoWhitespaceBeforeCheck extends AbstractCheck
Checks that there is no whitespace before a token.
More specifically, it checks that it is not preceded with whitespace,
or (if linebreaks are allowed) all characters on the line before are
whitespace. To allow linebreaks before a token, set property
allowLineBreaks to true. No check occurs before semi-colons in empty
for loop initializers or conditions.
allowLineBreaks - Control whether whitespace is allowed
if the token is at a linebreak.
Default value is false.
tokens - tokens to check
Default value is:
COMMA,
SEMI,
POST_INC,
POST_DEC,
ELLIPSIS.
To configure the check:
<module name="NoWhitespaceBefore"/>
To configure the check to allow linebreaks before a DOT token:
<module name="NoWhitespaceBefore"> <property name="tokens" value="DOT"/> <property name="allowLineBreaks" value="true"/> </module>
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
NoWhitespaceBeforeCheck() |
| 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 |
setAllowLineBreaks(boolean allowLineBreaks)
Setter to control whether whitespace is allowed if the token is at a linebreak.
|
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 java.lang.String MSG_KEY
public NoWhitespaceBeforeCheck()
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 processpublic void setAllowLineBreaks(boolean allowLineBreaks)
allowLineBreaks - whether whitespace should be
flagged at line breaks.Copyright © 2001-2020. All Rights Reserved.