net.sourceforge.pmd

Class AbstractRuleChainVisitor

public abstract class AbstractRuleChainVisitor extends Object implements RuleChainVisitor

This is a base class for RuleChainVisitor implementations which extracts interesting nodes from an AST, and lets each Rule visit the nodes it has expressed interest in.
Field Summary
protected Map<String,List<SimpleNode>>nodeNameToNodes
This is a mapping from node names to nodes instances for the current AST.
protected Map<RuleSet,List<Rule>>ruleSetRules
These are all the rules participating in the RuleChain, grouped by RuleSet.
Method Summary
voidadd(RuleSet ruleSet, Rule rule)
protected voidclear()
Clears the internal data structure used to manage the nodes visited between visiting different ASTs.
protected voidindexNode(SimpleNode node)
Index a single node for visitation by rules.
protected abstract voidindexNodes(List<CompilationUnit> astCompilationUnits, RuleContext ctx)
Index all nodes for visitation by rules.
protected voidinitialize()
Initialize the RuleChainVisitor to be ready to perform visitations.
protected abstract voidvisit(Rule rule, SimpleNode node, RuleContext ctx)
Visit the given rule to the given node.
voidvisitAll(List<CompilationUnit> astCompilationUnits, RuleContext ctx)

Field Detail

nodeNameToNodes

protected Map<String,List<SimpleNode>> nodeNameToNodes
This is a mapping from node names to nodes instances for the current AST.

ruleSetRules

protected Map<RuleSet,List<Rule>> ruleSetRules
These are all the rules participating in the RuleChain, grouped by RuleSet.

Method Detail

add

public void add(RuleSet ruleSet, Rule rule)

See Also: RuleChainVisitor

clear

protected void clear()
Clears the internal data structure used to manage the nodes visited between visiting different ASTs.

indexNode

protected void indexNode(SimpleNode node)
Index a single node for visitation by rules.

indexNodes

protected abstract void indexNodes(List<CompilationUnit> astCompilationUnits, RuleContext ctx)
Index all nodes for visitation by rules.

initialize

protected void initialize()
Initialize the RuleChainVisitor to be ready to perform visitations. This method should not be called until it is known that all Rules participating in the RuleChain are ready to be initialized themselves. Some rules may require full initialization to determine if they will participate in the RuleChain, so this has been delayed as long as possible to ensure that manipulation of the Rules is no longer occurring.

visit

protected abstract void visit(Rule rule, SimpleNode node, RuleContext ctx)
Visit the given rule to the given node.

visitAll

public void visitAll(List<CompilationUnit> astCompilationUnits, RuleContext ctx)

See Also: RuleChainVisitor