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, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final String MSG_FALL_THROUGH
public static final String MSG_FALL_THROUGH_LAST
public FallThroughCheck()
public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic 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)
AbstractCheckvisitToken in class AbstractCheckast - the token to processCopyright © 2001–2018. All rights reserved.