Search in sources :

Example 21 with RuleReference

use of net.sourceforge.pmd.lang.rule.RuleReference in project pmd-eclipse-plugin by pmd.

the class RuleSetUtil method addRuleSetByReference.

public static RuleSet addRuleSetByReference(RuleSet ruleSet, RuleSet sourceRuleSet, boolean allRules) {
    RuleSetReference reference = new RuleSetReference(sourceRuleSet.getFileName(), allRules);
    Collection<Rule> rules = new ArrayList<Rule>(ruleSet.getRules());
    for (Rule rule : sourceRuleSet.getRules()) {
        RuleReference ruleRef = new RuleReference(rule, reference);
        rules.add(ruleRef);
    }
    RuleSetFactory factory = new RuleSetFactory();
    return factory.createNewRuleSet(ruleSet.getName(), ruleSet.getDescription(), ruleSet.getFileName(), ruleSet.getExcludePatterns(), ruleSet.getIncludePatterns(), rules);
}
Also used : RuleSetFactory(net.sourceforge.pmd.RuleSetFactory) RuleReference(net.sourceforge.pmd.lang.rule.RuleReference) ArrayList(java.util.ArrayList) Rule(net.sourceforge.pmd.Rule) RuleSetReference(net.sourceforge.pmd.RuleSetReference)

Example 22 with RuleReference

use of net.sourceforge.pmd.lang.rule.RuleReference in project pmd-eclipse-plugin by pmd.

the class XPathPanelManager method updateOverridenFields.

protected void updateOverridenFields() {
    Rule rule = soleRule();
    if (rule instanceof RuleReference) {
        RuleReference ruleReference = (RuleReference) rule;
        xpathField.setBackground(ruleReference.hasOverriddenProperty(XPathRule.XPATH_DESCRIPTOR) ? overridenColour : null);
    }
}
Also used : RuleReference(net.sourceforge.pmd.lang.rule.RuleReference) XPathRule(net.sourceforge.pmd.lang.rule.XPathRule) Rule(net.sourceforge.pmd.Rule)

Example 23 with RuleReference

use of net.sourceforge.pmd.lang.rule.RuleReference in project pmd-eclipse-plugin by pmd.

the class DescriptionPanelManager method updateOverridenFields.

protected void updateOverridenFields() {
    Rule rule = soleRule();
    if (rule instanceof RuleReference) {
        RuleReference ruleReference = (RuleReference) rule;
        messageField.setBackground(ruleReference.getOverriddenMessage() != null ? overridenColour : null);
        descriptionBox.setBackground(ruleReference.getOverriddenDescription() != null ? overridenColour : null);
        externalURLField.setBackground(ruleReference.getOverriddenExternalInfoUrl() != null ? overridenColour : null);
    }
}
Also used : RuleReference(net.sourceforge.pmd.lang.rule.RuleReference) Rule(net.sourceforge.pmd.Rule)

Aggregations

RuleReference (net.sourceforge.pmd.lang.rule.RuleReference)23 Test (org.junit.Test)10 MockRule (net.sourceforge.pmd.lang.rule.MockRule)9 Rule (net.sourceforge.pmd.Rule)7 XPathRule (net.sourceforge.pmd.lang.rule.XPathRule)7 ArrayList (java.util.ArrayList)5 Language (net.sourceforge.pmd.lang.Language)4 List (java.util.List)3 PropertyDescriptor (net.sourceforge.pmd.properties.PropertyDescriptor)3 StringProperty (net.sourceforge.pmd.properties.StringProperty)3 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 TreeMap (java.util.TreeMap)2 RuleSet (net.sourceforge.pmd.RuleSet)2 JavaUtilLoggingRule (net.sourceforge.pmd.junit.JavaUtilLoggingRule)2 Element (org.w3c.dom.Element)2 HashSet (java.util.HashSet)1