1
2
3
4 package net.sourceforge.pmd.lang.plsql.rule;
5
6 import java.util.List;
7 import java.util.logging.Logger;
8
9 import net.sourceforge.pmd.Rule;
10 import net.sourceforge.pmd.RuleContext;
11 import net.sourceforge.pmd.lang.ast.Node;
12 import net.sourceforge.pmd.lang.plsql.ast.ASTInput;
13 import net.sourceforge.pmd.lang.plsql.ast.PLSQLNode;
14 import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor;
15 import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitorAdapter;
16 import net.sourceforge.pmd.lang.rule.AbstractRuleChainVisitor;
17 import net.sourceforge.pmd.lang.rule.XPathRule;
18
19 public class PLSQLRuleChainVisitor extends AbstractRuleChainVisitor {
20 private final static Logger LOGGER = Logger.getLogger(PLSQLRuleChainVisitor.class.getName());
21 private final static String CLASS_NAME = PLSQLRuleChainVisitor.class.getName();
22
23 protected void indexNodes(List<Node> nodes, RuleContext ctx) {
24 LOGGER.entering(CLASS_NAME,"indexNodes");
25 PLSQLParserVisitor plsqlParserVistor = new PLSQLParserVisitorAdapter() {
26
27
28 public Object visit(PLSQLNode node, Object data) {
29 indexNode(node);
30 return super.visit(node, data);
31 }
32 };
33
34 for (int i = 0; i < nodes.size(); i++) {
35 plsqlParserVistor.visit((ASTInput)nodes.get(i), ctx);
36 }
37 LOGGER.exiting(CLASS_NAME,"indexNodes");
38 }
39
40 protected void visit(Rule rule, Node node, RuleContext ctx) {
41 LOGGER.entering(CLASS_NAME,"visit");
42
43 LOGGER.fine("Rule="+rule);
44 LOGGER.fine("Node="+node);
45 LOGGER.fine("RuleContext="+ctx);
46 LOGGER.fine("Rule Classname="+rule.getClass().getCanonicalName());
47 LOGGER.fine("Rule Name="+rule.getName());
48 if (rule instanceof XPathRule) {
49 ((XPathRule)rule).evaluate(node, ctx);
50 } else {
51 ((PLSQLNode)node).jjtAccept((PLSQLParserVisitor)rule, ctx);
52 }
53 LOGGER.exiting(CLASS_NAME,"visit");
54 }
55 }