Search in sources :

Example 1 with ImmutableLanguage

use of net.sourceforge.pmd.lang.rule.ImmutableLanguage in project pmd by pmd.

the class RuleSetWriter method createRuleElement.

private Element createRuleElement(Rule rule) {
    if (rule instanceof RuleReference) {
        RuleReference ruleReference = (RuleReference) rule;
        RuleSetReference ruleSetReference = ruleReference.getRuleSetReference();
        if (ruleSetReference.isAllRules()) {
            if (!ruleSetFileNames.contains(ruleSetReference.getRuleSetFileName())) {
                ruleSetFileNames.add(ruleSetReference.getRuleSetFileName());
                return createRuleSetReferenceElement(ruleSetReference);
            } else {
                return null;
            }
        } else {
            Language language = ruleReference.getOverriddenLanguage();
            LanguageVersion minimumLanguageVersion = ruleReference.getOverriddenMinimumLanguageVersion();
            LanguageVersion maximumLanguageVersion = ruleReference.getOverriddenMaximumLanguageVersion();
            Boolean deprecated = ruleReference.isOverriddenDeprecated();
            String name = ruleReference.getOverriddenName();
            String ref = ruleReference.getRuleSetReference().getRuleSetFileName() + '/' + ruleReference.getRule().getName();
            String message = ruleReference.getOverriddenMessage();
            String externalInfoUrl = ruleReference.getOverriddenExternalInfoUrl();
            String description = ruleReference.getOverriddenDescription();
            RulePriority priority = ruleReference.getOverriddenPriority();
            List<PropertyDescriptor<?>> propertyDescriptors = ruleReference.getOverriddenPropertyDescriptors();
            Map<PropertyDescriptor<?>, Object> propertiesByPropertyDescriptor = ruleReference.getOverriddenPropertiesByPropertyDescriptor();
            List<String> examples = ruleReference.getOverriddenExamples();
            return createSingleRuleElement(language, minimumLanguageVersion, maximumLanguageVersion, deprecated, name, null, ref, message, externalInfoUrl, null, null, null, null, description, priority, propertyDescriptors, propertiesByPropertyDescriptor, examples);
        }
    } else {
        return createSingleRuleElement(rule instanceof ImmutableLanguage ? null : rule.getLanguage(), rule.getMinimumLanguageVersion(), rule.getMaximumLanguageVersion(), rule.isDeprecated(), rule.getName(), rule.getSince(), null, rule.getMessage(), rule.getExternalInfoUrl(), rule.getRuleClass(), rule.isDfa(), rule.isTypeResolution(), rule.isMultifile(), rule.getDescription(), rule.getPriority(), rule.getPropertyDescriptors(), rule.getPropertiesByPropertyDescriptor(), rule.getExamples());
    }
}
Also used : ImmutableLanguage(net.sourceforge.pmd.lang.rule.ImmutableLanguage) RuleReference(net.sourceforge.pmd.lang.rule.RuleReference) PropertyDescriptor(net.sourceforge.pmd.properties.PropertyDescriptor) ImmutableLanguage(net.sourceforge.pmd.lang.rule.ImmutableLanguage) Language(net.sourceforge.pmd.lang.Language) LanguageVersion(net.sourceforge.pmd.lang.LanguageVersion)

Aggregations

Language (net.sourceforge.pmd.lang.Language)1 LanguageVersion (net.sourceforge.pmd.lang.LanguageVersion)1 ImmutableLanguage (net.sourceforge.pmd.lang.rule.ImmutableLanguage)1 RuleReference (net.sourceforge.pmd.lang.rule.RuleReference)1 PropertyDescriptor (net.sourceforge.pmd.properties.PropertyDescriptor)1