private static @NotNull Map<EngineInfo, ScriptEngineFactory> calcFactories() {
    // bundled factories from java modules (Groovy) and from plugins
    return JBIterable.of(PluginManagerCore.getPlugins())
      .flatten(o -> {
        try {
          return new ScriptEngineManager(o.getClassLoader()).getEngineFactories();
        }
        catch (Throwable e) {
          LOG.error(new PluginException(e, o.getPluginId()));
          return null;
        }
      })
      .unique(o -> o.getClass().getName())
      .filterMap(factory -> {
        try {
          Class<? extends ScriptEngineFactory> aClass = factory.getClass();
          ClassLoader classLoader = aClass.getClassLoader();
          PluginDescriptor plugin = classLoader instanceof PluginAwareClassLoader
                                    ? ((PluginAwareClassLoader)classLoader).getPluginDescriptor() : null;
          EngineInfo info = new EngineInfo(
            factory.getEngineName(),
            factory.getEngineVersion(),
            factory.getLanguageName(),
            factory.getLanguageVersion(),
            factory.getExtensions(),
            aClass.getName(),
            plugin);
          return Pair.create(info, factory);
        }
        catch (Throwable e) {
          LOG.error(PluginException.createByClass(e, factory.getClass()));
          return null;
        }
      })
      .toMap(o -> o.first, o -> o.second);
  }
private static @NotNull Map<EngineInfo, ScriptEngineFactory> calcFactories()