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