private static void patchRootAreaExtensions() {
    ExtensionsArea rootArea = Extensions.getArea(null);

    for (ToolWindowEP ep : Extensions.getExtensions(ToolWindowEP.EP_NAME)) {
      if (ToolWindowId.FAVORITES_VIEW.equals(ep.id)
          || ToolWindowId.TODO_VIEW.equals(ep.id)
          || EventLog.LOG_TOOL_WINDOW_ID.equals(ep.id)
          || ToolWindowId.STRUCTURE_VIEW.equals(ep.id)) {
        rootArea.getExtensionPoint(ToolWindowEP.EP_NAME).unregisterExtension(ep);
      }
    }

    for (DirectoryProjectConfigurator ep :
        Extensions.getExtensions(DirectoryProjectConfigurator.EP_NAME)) {
      if (ep instanceof PlatformProjectViewOpener) {
        rootArea.getExtensionPoint(DirectoryProjectConfigurator.EP_NAME).unregisterExtension(ep);
      }
    }

    // unregister unrelated tips
    for (TipAndTrickBean tip : Extensions.getExtensions(TipAndTrickBean.EP_NAME)) {
      if (UNRELATED_TIPS.contains(tip.fileName)) {
        rootArea.getExtensionPoint(TipAndTrickBean.EP_NAME).unregisterExtension(tip);
      }
    }

    for (IntentionActionBean ep : Extensions.getExtensions(IntentionManager.EP_INTENTION_ACTIONS)) {
      if ("org.intellij.lang.regexp.intention.CheckRegExpIntentionAction".equals(ep.className)) {
        rootArea.getExtensionPoint(IntentionManager.EP_INTENTION_ACTIONS).unregisterExtension(ep);
      }
    }
  }
 // made public for Upsource
 public void registerExtensionPoints(@NotNull ExtensionsArea area) {
   if (myExtensionsPoints != null) {
     for (Element element : myExtensionsPoints.get(StringUtil.notNullize(area.getAreaClass()))) {
       area.registerExtensionPoint(this, element);
     }
   }
 }
 // made public for Upsource
 public void registerExtensions(@NotNull ExtensionsArea area, @NotNull String epName) {
   if (myExtensions != null) {
     for (Element element : myExtensions.get(epName)) {
       area.registerExtension(this, element);
     }
   }
 }
  private static void patchProjectAreaExtensions(@NotNull final Project project) {
    ExtensionsArea projectArea = Extensions.getArea(project);

    for (SelectInTarget target : Extensions.getExtensions(SelectInTarget.EP_NAME, project)) {
      if (ToolWindowId.FAVORITES_VIEW.equals(target.getToolWindowId())
          || ToolWindowId.STRUCTURE_VIEW.equals(target.getToolWindowId())) {
        projectArea.getExtensionPoint(SelectInTarget.EP_NAME).unregisterExtension(target);
      }
    }

    for (AbstractProjectViewPane pane :
        Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, project)) {
      if (pane.getId().equals(ScopeViewPane.ID)) {
        Disposer.dispose(pane);
        projectArea.getExtensionPoint(AbstractProjectViewPane.EP_NAME).unregisterExtension(pane);
      }
    }
  }
  private static void patchProjectAreaExtensions(@NotNull final Project project) {
    Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    unregisterAction(debugExecutor.getId(), ExecutorRegistryImpl.RUNNERS_GROUP);
    unregisterAction(debugExecutor.getContextActionId(), ExecutorRegistryImpl.RUN_CONTEXT_GROUP);

    ExtensionsArea projectArea = Extensions.getArea(project);

    for (SelectInTarget target : Extensions.getExtensions(SelectInTarget.EP_NAME, project)) {
      if (ToolWindowId.FAVORITES_VIEW.equals(target.getToolWindowId())
          || ToolWindowId.STRUCTURE_VIEW.equals(target.getToolWindowId())) {
        projectArea.getExtensionPoint(SelectInTarget.EP_NAME).unregisterExtension(target);
      }
    }

    for (AbstractProjectViewPane pane :
        Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, project)) {
      if (pane.getId().equals(ScopeViewPane.ID)) {
        Disposer.dispose(pane);
        projectArea.getExtensionPoint(AbstractProjectViewPane.EP_NAME).unregisterExtension(pane);
      }
    }
  }
 public static <T> void registerExtension(
     final ExtensionsArea area,
     final ExtensionPointName<T> name,
     final T t,
     final Disposable parentDisposable) {
   final ExtensionPoint<T> extensionPoint = area.getExtensionPoint(name.getName());
   extensionPoint.registerExtension(t);
   Disposer.register(
       parentDisposable,
       new Disposable() {
         @Override
         public void dispose() {
           extensionPoint.unregisterExtension(t);
         }
       });
 }
  private static void registerExtensionPointsAndExtensions(
      ExtensionsArea area, List<IdeaPluginDescriptorImpl> loadedPlugins) {
    for (IdeaPluginDescriptorImpl descriptor : loadedPlugins) {
      descriptor.registerExtensionPoints(area);
    }

    Set<String> epNames = ContainerUtil.newHashSet();
    for (ExtensionPoint point : area.getExtensionPoints()) {
      epNames.add(point.getName());
    }

    for (IdeaPluginDescriptorImpl descriptor : loadedPlugins) {
      for (String epName : epNames) {
        descriptor.registerExtensions(area, epName);
      }
    }
  }