private static @NotNull Collection<? extends IdeaPluginDescriptor> getDependenciesToEnable(@NotNull Collection<? extends IdeaPluginDescriptor> descriptors,
                                                                                             @NotNull Map<PluginId, IdeaPluginDescriptorImpl> pluginIdMap) {
    Set<IdeaPluginDescriptor> result = new LinkedHashSet<>();

    for (IdeaPluginDescriptor descriptor : descriptors) {
      result.add(descriptor);

      if (!(descriptor instanceof IdeaPluginDescriptorImpl)) {
        continue;
      }

      PluginManagerCore.INSTANCE.processAllNonOptionalDependencies((IdeaPluginDescriptorImpl)descriptor, pluginIdMap, dependency ->
        PluginManagerCore.CORE_ID.equals(dependency.getPluginId()) ||
        dependency.isEnabled() ||
        !result.add(dependency) ?
        FileVisitResult.SKIP_SUBTREE /* if descriptor has already been added/enabled, no need to process its dependencies */ :
        FileVisitResult.CONTINUE);
    }

    return Collections.unmodifiableSet(result);
  }
private static @NotNull Collection<? extends IdeaPluginDescriptor> getDependenciesToEnable(@NotNull Collection<? extends IdeaPluginDescriptor> descriptors,
                                                                                             @NotNull Map<PluginId, IdeaPluginDescriptorImpl> pluginIdMap)