public static IdeaPluginDescriptorImpl[] loadDescriptors(@Nullable StartupProgress progress) {
    if (ClassUtilCore.isLoadingOfExternalPluginsDisabled()) {
      return IdeaPluginDescriptorImpl.EMPTY_ARRAY;
    }

    final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();

    int pluginsCount =
        countPlugins(PathManager.getPluginsPath())
            + countPlugins(PathManager.getPreinstalledPluginsPath());
    loadDescriptors(PathManager.getPluginsPath(), result, progress, pluginsCount);
    Application application = ApplicationManager.getApplication();
    boolean fromSources = false;
    if (application == null || !application.isUnitTestMode()) {
      int size = result.size();
      loadDescriptors(PathManager.getPreinstalledPluginsPath(), result, progress, pluginsCount);
      fromSources = size == result.size();
    }

    loadDescriptorsFromProperty(result);

    loadDescriptorsFromClassPath(result, fromSources ? progress : null);

    IdeaPluginDescriptorImpl[] pluginDescriptors =
        result.toArray(new IdeaPluginDescriptorImpl[result.size()]);
    try {
      Arrays.sort(pluginDescriptors, new PluginDescriptorComparator(pluginDescriptors));
    } catch (Exception e) {
      prepareLoadingPluginsErrorMessage(
          IdeBundle.message("error.plugins.were.not.loaded", e.getMessage()));
      getLogger().info(e);
      return findCorePlugin(pluginDescriptors);
    }
    return pluginDescriptors;
  }
 private static boolean loadOldPlugins(File plugins, File dest) throws IOException {
   if (plugins.exists()) {
     List<IdeaPluginDescriptorImpl> descriptors = new SmartList<IdeaPluginDescriptorImpl>();
     PluginManagerCore.loadDescriptors(plugins, descriptors, null, 0);
     List<String> oldPlugins = new SmartList<String>();
     for (IdeaPluginDescriptorImpl descriptor : descriptors) {
       // check isBundled also - probably plugin is bundled in new IDE version
       if (descriptor.isEnabled() && !descriptor.isBundled()) {
         oldPlugins.add(descriptor.getPluginId().getIdString());
       }
     }
     if (!oldPlugins.isEmpty()) {
       PluginManagerCore.savePluginsList(
           oldPlugins, false, new File(dest, PluginManager.INSTALLED_TXT));
     }
     return true;
   }
   return false;
 }