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);
}
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);
}
}
}
}
Aggregations