Class TreeWalker

All Implemented Interfaces:
Configurable, Contextualizable, ExternalResourceHolder, FileSetCheck

public final class TreeWalker extends AbstractFileSetCheck implements ExternalResourceHolder
Responsible for walking an abstract syntax tree and notifying interested checks at each each node.
  • Constructor Details

    • TreeWalker

      public TreeWalker()
      Creates a new TreeWalker instance.
  • Method Details

    • setModuleFactory

      public void setModuleFactory(ModuleFactory moduleFactory)
      Sets the module factory for creating child modules (Checks).
      Parameters:
      moduleFactory - 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 AbstractViolationReporter
    • setupChild

      public void setupChild(Configuration childConf) throws CheckstyleException
      Called by configure() for every child of this component's Configuration.

      The default implementation throws CheckstyleException if childConf is null because it doesn't support children. It must be overridden to validate and support children that are wanted.

      Creates child module.
      Overrides:
      setupChild in class AutomaticBean
      Parameters:
      childConf - a child of this component's Configuration
      Throws:
      CheckstyleException - if there is a configuration error.
      See Also:
    • processFiltered

      protected void processFiltered(File file, FileText fileText) throws CheckstyleException
      Description copied from class: AbstractFileSetCheck
      Called to process a file that matches the specified file extensions.
      Specified by:
      processFiltered in class AbstractFileSetCheck
      Parameters:
      file - the file to be processed
      fileText - the contents of the file.
      Throws:
      CheckstyleException - if error condition within Checkstyle occurs.
    • destroy

      public void destroy()
      Description copied from interface: FileSetCheck
      Cleans up the object.
      Specified by:
      destroy in interface FileSetCheck
      Overrides:
      destroy in class AbstractFileSetCheck
    • getExternalResourceLocations

      public Set<String> getExternalResourceLocations()
      Description copied from interface: ExternalResourceHolder
      Returns a set of external configuration resource locations which are used by the module. ATTENTION! If 'getExternalResourceLocations()' return null, there will be NullPointerException in Checker. Such behaviour will signal that your module (check or filter) is designed incorrectly. It make sense to return an empty set from 'getExternalResourceLocations()' only for composite modules like TreeWalker.
      Specified by:
      getExternalResourceLocations in interface ExternalResourceHolder
      Returns:
      a set of external configuration resource locations which are used by the module.