com.puppycrawl.tools.checkstyle
Class TreeWalker

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
              extended by com.puppycrawl.tools.checkstyle.TreeWalker
All Implemented Interfaces:
Configurable, Contextualizable, FileSetCheck

public final class TreeWalker
extends AbstractFileSetCheck

Responsible for walking an abstract syntax tree and notifying interested checks at each each node.

Version:
1.0
Author:
Oliver Burn

Constructor Summary
TreeWalker()
          Creates a new TreeWalker instance.
 
Method Summary
 void destroy()
          Cleans up the object.
 void finishLocalSetup()
          Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.
static DetailAST parse(FileContents aContents)
          Static helper method to parses a Java source file.
protected  void processFiltered(File aFile, List<String> aLines)
          Called to process a file that matches the specified file extensions.
 void setCacheFile(String aFileName)
           
 void setClassLoader(ClassLoader aClassLoader)
           
 void setModuleFactory(ModuleFactory aModuleFactory)
          Sets the module factory for creating child modules (Checks).
 void setTabWidth(int aTabWidth)
           
 void setupChild(Configuration aChildConf)
          Called by configure() for every child of this component's Configuration.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
beginProcessing, finishProcessing, fireErrors, getMessageCollector, getMessageDispatcher, init, log, log, process, setFileExtensions, setMessageDispatcher
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Configurable
configure
 
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizable
contextualize
 

Constructor Detail

TreeWalker

public TreeWalker()
Creates a new TreeWalker instance.

Method Detail

setTabWidth

public void setTabWidth(int aTabWidth)
Parameters:
aTabWidth - the distance between tab stops

setCacheFile

public void setCacheFile(String aFileName)
Parameters:
aFileName - the cache file

setClassLoader

public void setClassLoader(ClassLoader aClassLoader)
Parameters:
aClassLoader - class loader to resolve classes with.

setModuleFactory

public void setModuleFactory(ModuleFactory aModuleFactory)
Sets the module factory for creating child modules (Checks).

Parameters:
aModuleFactory - the factory

finishLocalSetup

public void finishLocalSetup()
Description copied from class: AutomaticBean
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.

The default implementation does nothing.

Overrides:
finishLocalSetup in class AutomaticBean

setupChild

public void setupChild(Configuration aChildConf)
                throws CheckstyleException
Description copied from class: AutomaticBean
Called by configure() for every child of this component's Configuration.

The default implementation does nothing.

Overrides:
setupChild in class AutomaticBean
Parameters:
aChildConf - a child of this component's Configuration
Throws:
CheckstyleException - if there is a configuration error.
See Also:
Configuration.getChildren()

processFiltered

protected void processFiltered(File aFile,
                               List<String> aLines)
Description copied from class: AbstractFileSetCheck
Called to process a file that matches the specified file extensions.

Specified by:
processFiltered in class AbstractFileSetCheck
Parameters:
aFile - the file to be processed
aLines - an immutable list of the contents of the file.

parse

public static DetailAST parse(FileContents aContents)
                       throws RecognitionException,
                              TokenStreamException
Static helper method to parses a Java source file.

Parameters:
aContents - contains the contents of the file
Returns:
the root of the AST
Throws:
TokenStreamException - if lexing failed
RecognitionException - if parsing failed

destroy

public void destroy()
Description copied from class: AbstractFileSetCheck
Cleans up the object.

Specified by:
destroy in interface FileSetCheck
Overrides:
destroy in class AbstractFileSetCheck

Back to the Checkstyle Home Page