java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
com.puppycrawl.tools.checkstyle.checks.HiddenFieldCheck
- All Implemented Interfaces:
- com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable
- public class HiddenFieldCheck
- extends com.puppycrawl.tools.checkstyle.api.Check
Checks that a local variable or a parameter does not shadow
a field that is defined in the same class.
An example of how to configure the check is:
<module name="HiddenField"/>
An example of how to configure the check so that it checks variables but not
parameters is:
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/>
</module>
- Version:
- 1.0
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check |
|
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
|
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check |
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mFieldsStack
private java.util.LinkedList mFieldsStack
- stack of sets of field names,
one for each class of a set of nested classes
HiddenFieldCheck
public HiddenFieldCheck()
getDefaultTokens
public int[] getDefaultTokens()
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- Returns the default token a check is interested in. Only used if the
configuration for a check does not define the tokens.
getAcceptableTokens
public int[] getAcceptableTokens()
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- The configurable token set.
Used to protect Checks against malicious users who specify an
unacceptable token set in the configuration file.
The default implementation returns the check's default tokens.
getRequiredTokens
public int[] getRequiredTokens()
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- The tokens that this check must be registered for.
beginTree
public void beginTree()
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- Called to process a token.
leaveToken
public void leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- Called after all the child nodes have been process.
processVariable
private void processVariable(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Process a variable token.
Check whether a local variable or parameter shadows a field.
Store a field for later comparison with local variables and parameters.