public final class TreeWalker extends AbstractFileSetCheck implements ExternalResourceHolder
| Modifier and Type | Class and Description |
|---|---|
private static class |
TreeWalker.AstState
State of AST.
|
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
private Context |
childContext
Context of child components.
|
private java.util.Set<AbstractCheck> |
commentChecks
Registered comment checks.
|
private java.util.Set<TreeWalkerFilter> |
filters
The ast filters.
|
private ModuleFactory |
moduleFactory
A factory for creating submodules (i.e.
|
private java.util.Set<AbstractCheck> |
ordinaryChecks
Registered ordinary checks, that don't use comment nodes.
|
private java.util.Map<java.lang.Integer,java.util.Set<AbstractCheck>> |
tokenToCommentChecks
Maps from token name to comment checks.
|
private java.util.Map<java.lang.Integer,java.util.Set<AbstractCheck>> |
tokenToOrdinaryChecks
Maps from token name to ordinary checks.
|
private java.util.SortedSet<Violation> |
violations
The sorted set of violations.
|
| Constructor and Description |
|---|
TreeWalker()
Creates a new
TreeWalker instance. |
| Modifier and Type | Method and Description |
|---|---|
private static java.util.SortedSet<AbstractCheck> |
createNewCheckSortedSet()
Creates a new
SortedSet with a deterministic order based on the
Check's name before the default ordering. |
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.
|
private java.util.SortedSet<Violation> |
getFilteredViolations(java.lang.String fileName,
FileContents fileContents,
DetailAST rootAST)
Returns filtered set of
Violation. |
private java.util.Collection<AbstractCheck> |
getListOfChecks(DetailAST ast,
TreeWalker.AstState astState)
Method returns list of checks.
|
private void |
notifyBegin(DetailAST rootAST,
FileContents contents,
TreeWalker.AstState astState)
Notify checks that we are about to begin walking a tree.
|
private void |
notifyEnd(DetailAST rootAST,
TreeWalker.AstState astState)
Notify checks that we have finished walking a tree.
|
private void |
notifyLeave(DetailAST ast,
TreeWalker.AstState astState)
Notify checks that leaving a node.
|
private void |
notifyVisit(DetailAST ast,
TreeWalker.AstState astState)
Notify checks that visiting a node.
|
protected void |
processFiltered(java.io.File file,
FileText fileText)
Called to process a file that matches the specified file extensions.
|
private void |
processIter(DetailAST root,
TreeWalker.AstState astState)
Processes a node calling interested checks at each node.
|
private void |
registerCheck(AbstractCheck check)
Register a check for a given configuration.
|
private void |
registerCheck(int tokenId,
AbstractCheck check)
Register a check for a specified token id.
|
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.
|
private void |
walk(DetailAST ast,
FileContents contents,
TreeWalker.AstState astState)
Initiates the walk of an AST.
|
addViolations, beginProcessing, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getTabWidth, getViolations, init, log, log, process, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidthgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfigurationclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconfigurecontextualizeprivate final java.util.Map<java.lang.Integer,java.util.Set<AbstractCheck>> tokenToOrdinaryChecks
private final java.util.Map<java.lang.Integer,java.util.Set<AbstractCheck>> tokenToCommentChecks
private final java.util.Set<AbstractCheck> ordinaryChecks
private final java.util.Set<AbstractCheck> commentChecks
private final java.util.Set<TreeWalkerFilter> filters
private final java.util.SortedSet<Violation> violations
private Context childContext
private ModuleFactory moduleFactory
public TreeWalker()
TreeWalker instance.public void setModuleFactory(ModuleFactory moduleFactory)
moduleFactory - the factorypublic void finishLocalSetup()
AutomaticBeanThe default implementation does nothing.
finishLocalSetup in class AbstractViolationReporterpublic void setupChild(Configuration childConf) throws CheckstyleException
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.
setupChild in class AutomaticBeanchildConf - a child of this component's ConfigurationCheckstyleException - if there is a configuration error.Configuration.getChildren()protected void processFiltered(java.io.File file, FileText fileText) throws CheckstyleException
AbstractFileSetCheckprocessFiltered in class AbstractFileSetCheckfile - the file to be processedfileText - the contents of the file.CheckstyleException - if error condition within Checkstyle occurs.private java.util.SortedSet<Violation> getFilteredViolations(java.lang.String fileName, FileContents fileContents, DetailAST rootAST)
Violation.fileName - path to the filefileContents - the contents of the filerootAST - root AST element DetailAST of the fileprivate void registerCheck(AbstractCheck check) throws CheckstyleException
check - the check to registerCheckstyleException - if an error occursprivate void registerCheck(int tokenId, AbstractCheck check) throws CheckstyleException
tokenId - the id of the tokencheck - the check to registerCheckstyleException - if Check is misconfiguredprivate void walk(DetailAST ast, FileContents contents, TreeWalker.AstState astState)
ast - the root ASTcontents - the contents of the file the AST was generated from.astState - state of AST.private void notifyBegin(DetailAST rootAST, FileContents contents, TreeWalker.AstState astState)
rootAST - the root of the tree.contents - the contents of the file the AST was generated from.astState - state of AST.private void notifyEnd(DetailAST rootAST, TreeWalker.AstState astState)
rootAST - the root of the tree.astState - state of AST.private void notifyVisit(DetailAST ast, TreeWalker.AstState astState)
ast - the node to notify for.astState - state of AST.private void notifyLeave(DetailAST ast, TreeWalker.AstState astState)
ast - the node to notify forastState - state of AST.private java.util.Collection<AbstractCheck> getListOfChecks(DetailAST ast, TreeWalker.AstState astState)
ast - the node to notify forastState - state of AST.public void destroy()
FileSetCheckdestroy in interface FileSetCheckdestroy in class AbstractFileSetCheckpublic java.util.Set<java.lang.String> getExternalResourceLocations()
ExternalResourceHolderNullPointerException 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.getExternalResourceLocations in interface ExternalResourceHolderprivate void processIter(DetailAST root, TreeWalker.AstState astState)
root - the root of tree for processastState - state of AST.private static java.util.SortedSet<AbstractCheck> createNewCheckSortedSet()
SortedSet with a deterministic order based on the
Check's name before the default ordering.SortedSet.Copyright © 2001-2022. All Rights Reserved.