forked from phoedos/pmd
Merge branch '7.0.x' into update-saxon-version
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
package net.sourceforge.pmd.lang.jsp;
|
||||
|
||||
import net.sourceforge.pmd.lang.BaseLanguageModule;
|
||||
import net.sourceforge.pmd.lang.jsp.rule.JspRuleChainVisitor;
|
||||
|
||||
/**
|
||||
* Created by christoferdutz on 20.09.14.
|
||||
@@ -16,7 +15,7 @@ public class JspLanguageModule extends BaseLanguageModule {
|
||||
public static final String TERSE_NAME = "jsp";
|
||||
|
||||
public JspLanguageModule() {
|
||||
super(NAME, "JSP", TERSE_NAME, JspRuleChainVisitor.class, "jsp", "jspx", "jspf", "tag");
|
||||
super(NAME, "JSP", TERSE_NAME, "jsp", "jspx", "jspf", "tag");
|
||||
addVersion("", new JspHandler(), true);
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.rule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
@@ -22,14 +20,7 @@ public abstract class AbstractJspRule extends AbstractRule implements JspParserV
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(List<? extends Node> nodes, RuleContext ctx) {
|
||||
visitAll(nodes, ctx);
|
||||
}
|
||||
|
||||
protected void visitAll(List<? extends Node> nodes, RuleContext ctx) {
|
||||
for (Object element : nodes) {
|
||||
JspNode node = (JspNode) element;
|
||||
visit(node, ctx);
|
||||
}
|
||||
public void apply(Node target, RuleContext ctx) {
|
||||
((JspNode) target).jjtAccept(this, ctx);
|
||||
}
|
||||
}
|
||||
|
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.rule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.jsp.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.jsp.ast.JspNode;
|
||||
import net.sourceforge.pmd.lang.jsp.ast.JspParserVisitor;
|
||||
import net.sourceforge.pmd.lang.jsp.ast.JspParserVisitorAdapter;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRuleChainVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
|
||||
public class JspRuleChainVisitor extends AbstractRuleChainVisitor {
|
||||
|
||||
@Override
|
||||
protected void indexNodes(List<Node> nodes, RuleContext ctx) {
|
||||
JspParserVisitor jspParserVisitor = new JspParserVisitorAdapter() {
|
||||
// Perform a visitation of the AST to index nodes which need
|
||||
// visiting by type
|
||||
@Override
|
||||
public Object visit(JspNode node, Object data) {
|
||||
indexNode(node);
|
||||
return super.visit(node, data);
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
jspParserVisitor.visit((ASTCompilationUnit) nodes.get(i), ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void visit(Rule rule, Node node, RuleContext ctx) {
|
||||
// Rule better either be a JspParserVisitor, or a XPathRule
|
||||
if (rule instanceof JspParserVisitor) {
|
||||
((JspNode) node).jjtAccept((JspParserVisitor) rule, ctx);
|
||||
} else {
|
||||
((XPathRule) rule).evaluate(node, ctx);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user