public class FallThroughCheck extends AbstractCheck
The check honors special comments to suppress warnings about the fall through. By default the comments "fallthru", "fall through", "falls through" and "fallthrough" are recognized.
The following fragment of code will NOT trigger the check, because of the comment "fallthru" and absence of any Java code in case 5.
case 3: x = 2; // fallthru case 4: case 5: case 6: break;
The recognized relief comment can be configured with the property
reliefPattern
. Default value of this regular expression
is "fallthru|fall through|fallthrough|falls through".
An example of how to configure the check is:
<module name="FallThrough"> <property name="reliefPattern" value="Fall Through"/> </module>
AutomaticBean.OutputStreamOptions
Modifier and Type | Field and Description |
---|---|
static String |
MSG_FALL_THROUGH
A key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_FALL_THROUGH_LAST
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
FallThroughCheck() |
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 |
setCheckLastCaseGroup(boolean value)
Configures whether we need to check last case group or not.
|
void |
setReliefPattern(Pattern pattern)
Set the relief pattern.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
public static final String MSG_FALL_THROUGH
public static final String MSG_FALL_THROUGH_LAST
public FallThroughCheck()
public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public void setReliefPattern(Pattern pattern)
pattern
- The regular expression pattern.public void setCheckLastCaseGroup(boolean value)
value
- new value of the property.public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processCopyright © 2001–2018. All rights reserved.