Search in sources :

Example 1 with RuleInterpreterPlugin

use of com.buschmais.jqassistant.core.analysis.api.RuleInterpreterPlugin in project jqa-core-framework by buschmais.

the class AnalyzerRuleVisitor method execute.

private <T extends ExecutableRule> Result<T> execute(T executableRule, Severity severity) throws RuleException {
    Map<String, Object> ruleParameters = getRuleParameters(executableRule);
    Executable<?> executable = executableRule.getExecutable();
    Collection<RuleInterpreterPlugin> languagePlugins = ruleInterpreterPlugins.get(executable.getLanguage());
    if (languagePlugins == null) {
        throw new RuleException("Could not determine plugin to execute " + executableRule);
    }
    for (RuleInterpreterPlugin languagePlugin : languagePlugins) {
        if (languagePlugin.accepts(executableRule)) {
            Result<T> result = execute(executableRule, severity, ruleParameters, languagePlugin);
            if (result != null) {
                return result;
            }
        }
    }
    throw new RuleException("No plugin for language '" + executable.getLanguage() + "' returned a result for " + executableRule);
}
Also used : RuleInterpreterPlugin(com.buschmais.jqassistant.core.analysis.api.RuleInterpreterPlugin) RuleException(com.buschmais.jqassistant.core.rule.api.model.RuleException)

Example 2 with RuleInterpreterPlugin

use of com.buschmais.jqassistant.core.analysis.api.RuleInterpreterPlugin in project jqa-core-framework by buschmais.

the class AnalyzerPluginRepositoryImpl method initializeRuleInterpreterPlugins.

private void initializeRuleInterpreterPlugins(JqassistantPlugin plugin) {
    IdClassListType ruleInterpreters = plugin.getRuleInterpreter();
    if (ruleInterpreters != null) {
        for (IdClassType pluginType : ruleInterpreters.getClazz()) {
            RuleInterpreterPlugin ruleInterpreterPlugin = createInstance(pluginType.getValue());
            ruleInterpreterPlugin.initialize();
            for (String language : ruleInterpreterPlugin.getLanguages()) {
                Collection<RuleInterpreterPlugin> plugins = ruleInterpreterPlugins.get(language.toLowerCase());
                if (plugins == null) {
                    plugins = new ArrayList<>();
                    ruleInterpreterPlugins.put(language.toLowerCase(), plugins);
                }
                plugins.add(ruleInterpreterPlugin);
            }
        }
    }
}
Also used : IdClassType(org.jqassistant.schema.plugin.v1.IdClassType) IdClassListType(org.jqassistant.schema.plugin.v1.IdClassListType) RuleInterpreterPlugin(com.buschmais.jqassistant.core.analysis.api.RuleInterpreterPlugin)

Aggregations

RuleInterpreterPlugin (com.buschmais.jqassistant.core.analysis.api.RuleInterpreterPlugin)2 RuleException (com.buschmais.jqassistant.core.rule.api.model.RuleException)1 IdClassListType (org.jqassistant.schema.plugin.v1.IdClassListType)1 IdClassType (org.jqassistant.schema.plugin.v1.IdClassType)1