Rulechain visits are for now entirely handled as strings:
|
private List<String> ruleChainVisits = new ArrayList<>(); |
The implementation also throws an exception (!) if the node class doesn't have a hardcoded "AST" prefix:
|
public void addRuleChainVisit(Class<? extends Node> nodeClass) { |
|
if (!nodeClass.getSimpleName().startsWith("AST")) { |
|
throw new IllegalArgumentException("Node class does not start with 'AST' prefix: " + nodeClass); |
|
} |
|
addRuleChainVisit(nodeClass.getSimpleName().substring("AST".length())); |
|
} |
Introducing some abstractions into the AST (like done in #1759, argumented on the wiki) has a number of advantages, but the current rulechain implementation doesn't scale. Adding a rulechain visit to an abstract node type currently does nothing, instead of visiting all nodes having the specified supertype.
Refs #1772
There's the exact same problem with XPath queries, which I'll explain in another issue
Rulechain visits are for now entirely handled as strings:
pmd/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java
Line 44 in 4bb55e4
The implementation also throws an exception (!) if the node class doesn't have a hardcoded "AST" prefix:
pmd/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java
Lines 319 to 324 in 4bb55e4
Introducing some abstractions into the AST (like done in #1759, argumented on the wiki) has a number of advantages, but the current rulechain implementation doesn't scale. Adding a rulechain visit to an abstract node type currently does nothing, instead of visiting all nodes having the specified supertype.
Refs #1772
There's the exact same problem with XPath queries, which I'll explain in another issue