View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.vm.rule;
5   
6   import net.sourceforge.pmd.Rule;
7   import net.sourceforge.pmd.RuleContext;
8   import net.sourceforge.pmd.RuleViolation;
9   import net.sourceforge.pmd.lang.ast.Node;
10  import net.sourceforge.pmd.lang.rule.AbstractRuleViolationFactory;
11  import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
12  import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
13  import net.sourceforge.pmd.lang.vm.ast.AbstractVmNode;
14  
15  public final class VmRuleViolationFactory extends AbstractRuleViolationFactory {
16  
17      public static final RuleViolationFactory INSTANCE = new VmRuleViolationFactory();
18  
19      private VmRuleViolationFactory() {
20      }
21  
22      @Override
23      protected RuleViolation createRuleViolation(final Rule rule, final RuleContext ruleContext, final Node node,
24              final String message) {
25          return new ParametricRuleViolation<AbstractVmNode>(rule, ruleContext, (AbstractVmNode) node, message);
26      }
27  
28      @Override
29      protected RuleViolation createRuleViolation(final Rule rule, final RuleContext ruleContext, final Node node,
30              final String message, final int beginLine, final int endLine) {
31          final ParametricRuleViolation<AbstractVmNode> violation = new ParametricRuleViolation<AbstractVmNode>(rule,
32                  ruleContext, (AbstractVmNode) node, message);
33          violation.setLines(beginLine, endLine);
34          return violation;
35      }
36  }