Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks
Class HiddenFieldCheck  view HiddenFieldCheck download HiddenFieldCheck.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.Check
              extended bycom.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

Field Summary
private  java.util.LinkedList mFieldsStack
          stack of sets of field names, one for each class of a set of nested classes
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
 
Constructor Summary
HiddenFieldCheck()
           
 
Method Summary
 void beginTree()
           
 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 leaveToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called after all the child nodes have been process.
private  void processVariable(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Process a variable token.
 void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called to process a token.
 
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 com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mFieldsStack

private java.util.LinkedList mFieldsStack
stack of sets of field names, one for each class of a set of nested classes

Constructor Detail

HiddenFieldCheck

public HiddenFieldCheck()
Method Detail

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.