Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.puppycrawl.tools.checkstyle
Class TreeWalker

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
              com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
                  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 compoent's setup that was not handled by the bean introspection.
`static DetailAST` | `parse(FileContents aContents)` Static helper method to parses a Java source file.
`void` | `process(File[] aFiles)` Processes a set of files and fires errors to the MessageDispatcher.
`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)` Instantiates, configures and registers a Check that is specified in the provided configuration.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
`filter, fireErrors, getCharset, getMessageCollector, getMessageDispatcher, log, log, setCharset, setFileExtensions, setMessageDispatcher`

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
`getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, 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 compoent's setup that was not handled by the bean introspection.

  The default implementation does nothing.

  Overrides:
    `finishLocalSetup` in class `AutomaticBean`
  See Also:
    `Configurable`

### setupChild

    public void setupChild(Configuration aChildConf)
                    throws CheckstyleException

  Instantiates, configures and registers a Check that is specified in the provided configuration. 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()`

### 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

### process

    public void process(File[] aFiles)

  Processes a set of files and fires errors to the MessageDispatcher. The file set to process might contain files that are not interesting to the FileSetCheck. Such files should be ignored, no error message should be fired for them. For example a FileSetCheck that checks java files should ignore html or properties files. Once processiong is done, it is highly recommended to call for the destroy method to close and remove the listeners.

  Parameters:
    `aFiles` - the files to be audited.
  See Also:
    `FileSetCheck.destroy()`

### destroy

    public void destroy()

  Description copied from interface: `FileSetCheck`
  Cleans up the object.

  Specified by:
    `destroy` in interface `FileSetCheck`
  Overrides:
    `destroy` in class `AbstractFileSetCheck`
  See Also:
    `FileSetCheck`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Back to the Checkstyle Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD