use of org.intellij.plugins.intelliLang.inject.LanguageInjectionConfigBean in project intellij-community by JetBrains.
the class Configuration method loadDefaultInjections.
private static List<BaseInjection> loadDefaultInjections() {
final List<Configuration> cfgList = new ArrayList<>();
final Set<Object> visited = new THashSet<>();
for (LanguageInjectionConfigBean configBean : Extensions.getExtensions(LanguageInjectionSupport.CONFIG_EP_NAME)) {
PluginDescriptor descriptor = configBean.getPluginDescriptor();
final ClassLoader loader = descriptor.getPluginClassLoader();
try {
final Enumeration<URL> enumeration = loader.getResources(configBean.getConfigUrl());
if (enumeration == null || !enumeration.hasMoreElements()) {
LOG.warn(descriptor.getPluginId() + ": " + configBean.getConfigUrl() + " was not found");
} else {
while (enumeration.hasMoreElements()) {
URL url = enumeration.nextElement();
// for DEBUG mode
if (!visited.add(url.getFile()))
continue;
InputStream stream = null;
try {
stream = url.openStream();
cfgList.add(load(stream));
} catch (Exception e) {
LOG.warn(e);
} finally {
if (stream != null) {
stream.close();
}
}
}
}
} catch (Exception e) {
LOG.warn(e);
}
}
final List<BaseInjection> defaultInjections = new ArrayList<>();
for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
for (Configuration cfg : cfgList) {
final List<BaseInjection> imported = cfg.getInjections(supportId);
defaultInjections.addAll(imported);
}
}
return defaultInjections;
}
Aggregations