public void unregisterExtension(String pluginName, Element extensionElement) {
   String epName = extractEPName(extensionElement);
   if (!myExtensionElement2extension.containsKey(extensionElement)) {
     XMLOutputter xmlOutputter = new XMLOutputter();
     Format format =
         Format.getCompactFormat().setIndent("  ").setTextMode(Format.TextMode.NORMALIZE);
     xmlOutputter.setFormat(format);
     StringWriter stringWriter = new StringWriter();
     try {
       xmlOutputter.output(extensionElement, stringWriter);
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
     myLogger.warn(stringWriter.toString());
     throw new IllegalArgumentException(
         "Trying to unregister extension element that was never registered");
   }
   ExtensionComponentAdapter adapter = myExtensionElement2extension.remove(extensionElement);
   if (adapter == null) return;
   if (getExtensionPoint(epName).unregisterComponentAdapter(adapter)) {
     MutablePicoContainer pluginContainer = internalGetPluginContainer();
     pluginContainer.unregisterComponent(adapter.getComponentKey());
     if (pluginContainer.getComponentAdapters().isEmpty()) {
       disposePluginContainer(pluginName);
     }
   }
 }
 static void mergeOptionalConfigs(Map<PluginId, IdeaPluginDescriptorImpl> descriptors) {
   final Map<PluginId, IdeaPluginDescriptorImpl> descriptorsWithModules =
       new HashMap<PluginId, IdeaPluginDescriptorImpl>(descriptors);
   addModulesAsDependents(descriptorsWithModules);
   for (IdeaPluginDescriptorImpl descriptor : descriptors.values()) {
     final Map<PluginId, IdeaPluginDescriptorImpl> optionalDescriptors =
         descriptor.getOptionalDescriptors();
     if (optionalDescriptors != null && !optionalDescriptors.isEmpty()) {
       for (Map.Entry<PluginId, IdeaPluginDescriptorImpl> entry : optionalDescriptors.entrySet()) {
         if (descriptorsWithModules.containsKey(entry.getKey())) {
           descriptor.mergeOptionalConfig(entry.getValue());
         }
       }
     }
   }
 }
 public boolean hasExtensionPoint(String extensionPointName) {
   return myExtensionPoints.containsKey(extensionPointName);
 }
  @Nullable
  static String filterBadPlugins(
      List<? extends IdeaPluginDescriptor> result, final Map<String, String> disabledPluginNames) {
    final Map<PluginId, IdeaPluginDescriptor> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptor>();
    final StringBuffer message = new StringBuffer();
    boolean pluginsWithoutIdFound = false;
    for (Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor descriptor = it.next();
      final PluginId id = descriptor.getPluginId();
      if (id == null) {
        pluginsWithoutIdFound = true;
      }
      if (idToDescriptorMap.containsKey(id)) {
        message.append("<br>");
        message.append(IdeBundle.message("message.duplicate.plugin.id"));
        message.append(id);
        it.remove();
      } else if (descriptor.isEnabled()) {
        idToDescriptorMap.put(id, descriptor);
      }
    }
    addModulesAsDependents(idToDescriptorMap);
    final List<String> disabledPluginIds = new ArrayList<String>();
    final LinkedHashSet<String> faultyDescriptors = new LinkedHashSet<String>();
    for (final Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor pluginDescriptor = it.next();
      checkDependants(
          pluginDescriptor,
          new Function<PluginId, IdeaPluginDescriptor>() {
            @Override
            public IdeaPluginDescriptor fun(final PluginId pluginId) {
              return idToDescriptorMap.get(pluginId);
            }
          },
          new Condition<PluginId>() {
            @Override
            public boolean value(final PluginId pluginId) {
              if (!idToDescriptorMap.containsKey(pluginId)) {
                pluginDescriptor.setEnabled(false);
                if (!pluginId.getIdString().startsWith(MODULE_DEPENDENCY_PREFIX)) {
                  faultyDescriptors.add(pluginId.getIdString());
                  disabledPluginIds.add(pluginDescriptor.getPluginId().getIdString());
                  message.append("<br>");
                  final String name = pluginDescriptor.getName();
                  final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
                  String pluginName;
                  if (descriptor == null) {
                    pluginName = pluginId.getIdString();
                    if (disabledPluginNames.containsKey(pluginName)) {
                      pluginName = disabledPluginNames.get(pluginName);
                    }
                  } else {
                    pluginName = descriptor.getName();
                  }

                  message.append(
                      getDisabledPlugins().contains(pluginId.getIdString())
                          ? IdeBundle.message("error.required.plugin.disabled", name, pluginName)
                          : IdeBundle.message(
                              "error.required.plugin.not.installed", name, pluginName));
                }
                it.remove();
                return false;
              }
              return true;
            }
          });
    }
    if (!disabledPluginIds.isEmpty()) {
      myPlugins2Disable = disabledPluginIds;
      myPlugins2Enable = faultyDescriptors;
      message.append("<br>");
      message.append("<br>").append("<a href=\"" + DISABLE + "\">Disable ");
      if (disabledPluginIds.size() == 1) {
        final PluginId pluginId2Disable = PluginId.getId(disabledPluginIds.iterator().next());
        message.append(
            idToDescriptorMap.containsKey(pluginId2Disable)
                ? idToDescriptorMap.get(pluginId2Disable).getName()
                : pluginId2Disable.getIdString());
      } else {
        message.append("not loaded plugins");
      }
      message.append("</a>");
      boolean possibleToEnable = true;
      for (String descriptor : faultyDescriptors) {
        if (disabledPluginNames.get(descriptor) == null) {
          possibleToEnable = false;
          break;
        }
      }
      if (possibleToEnable) {
        message
            .append("<br>")
            .append("<a href=\"" + ENABLE + "\">Enable ")
            .append(
                faultyDescriptors.size() == 1
                    ? disabledPluginNames.get(faultyDescriptors.iterator().next())
                    : " all necessary plugins")
            .append("</a>");
      }
      message.append("<br>").append("<a href=\"" + EDIT + "\">Open plugin manager</a>");
    }
    if (pluginsWithoutIdFound) {
      message.append("<br>");
      message.append(IdeBundle.message("error.plugins.without.id.found"));
    }
    if (message.length() > 0) {
      message.insert(0, IdeBundle.message("error.problems.found.loading.plugins"));
      return message.toString();
    }
    return null;
  }