Package 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
,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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Constructor Summary
Constructors Constructor Description TreeWalker()
Creates a newTreeWalker
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.util.Set<java.lang.String>
getExternalResourceLocations()
Returns a set of external configuration resource locations which are used by the module.protected void
processFiltered(java.io.File file, FileText fileText)
Called to process a file that matches the specified file extensions.void
setModuleFactory(ModuleFactory moduleFactory)
Sets the module factory for creating child modules (Checks).void
setupChild(Configuration childConf)
Called by configure() for every child of this component's Configuration.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
addMessages, beginProcessing, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getMessages, getTabWidth, init, log, log, process, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidth
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, 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
-
-
-
-
Method Detail
-
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 classAbstractViolationReporter
-
setupChild
public void setupChild(Configuration childConf) throws CheckstyleException
Called by configure() for every child of this component's Configuration.The default implementation throws
Creates child module.CheckstyleException
ifchildConf
isnull
because it doesn't support children. It must be overridden to validate and support children that are wanted.- Overrides:
setupChild
in classAutomaticBean
- Parameters:
childConf
- a child of this component's Configuration- Throws:
CheckstyleException
- if there is a configuration error.- See Also:
Configuration.getChildren()
-
processFiltered
protected void processFiltered(java.io.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 classAbstractFileSetCheck
- Parameters:
file
- the file to be processedfileText
- 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 interfaceFileSetCheck
- Overrides:
destroy
in classAbstractFileSetCheck
-
getExternalResourceLocations
public java.util.Set<java.lang.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 beNullPointerException
inChecker
. 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 likeTreeWalker
.- Specified by:
getExternalResourceLocations
in interfaceExternalResourceHolder
- Returns:
- a set of external configuration resource locations which are used by the module.
-
-