private void processOrphanModules() {
      if (myProject.isDisposed()) return;
      if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
        LOG.info(
            String.format(
                "Checking for orphan modules. External paths returned by external system: '%s'",
                myExternalModulePaths));
      }
      PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
      List<Module> orphanIdeModules = ContainerUtilRt.newArrayList();
      String externalSystemIdAsString = myExternalSystemId.toString();

      for (Module module : platformFacade.getModules(myProject)) {
        String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
        String p = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
        if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
          LOG.info(
              String.format(
                  "IDE module: EXTERNAL_SYSTEM_ID_KEY - '%s', LINKED_PROJECT_PATH_KEY - '%s'.",
                  s, p));
        }
        if (externalSystemIdAsString.equals(s) && !myExternalModulePaths.contains(p)) {
          orphanIdeModules.add(module);
          if (ExternalSystemDebugEnvironment.DEBUG_ORPHAN_MODULES_PROCESSING) {
            LOG.info(
                String.format(
                    "External paths doesn't contain IDE module LINKED_PROJECT_PATH_KEY anymore => add to orphan IDE modules."));
          }
        }
      }

      if (!orphanIdeModules.isEmpty()) {
        ruleOrphanModules(orphanIdeModules, myProject, myExternalSystemId);
      }
    }
 @Nullable
 public static AbstractExternalSystemTaskConfigurationType findConfigurationType(
     @NotNull ProjectSystemId externalSystemId) {
   for (ConfigurationType type :
       Extensions.getExtensions(ConfigurationType.CONFIGURATION_TYPE_EP)) {
     if (type instanceof AbstractExternalSystemTaskConfigurationType) {
       AbstractExternalSystemTaskConfigurationType candidate =
           (AbstractExternalSystemTaskConfigurationType) type;
       if (externalSystemId.equals(candidate.getExternalSystemId())) {
         return candidate;
       }
     }
   }
   return null;
 }
 private static long getTimeStamp(
     @NotNull ExternalProjectSettings externalProjectSettings,
     @NotNull ProjectSystemId externalSystemId) {
   long timeStamp = 0;
   for (ExternalSystemConfigLocator locator :
       ExternalSystemConfigLocator.EP_NAME.getExtensions()) {
     if (!externalSystemId.equals(locator.getTargetExternalSystemId())) {
       continue;
     }
     for (VirtualFile virtualFile : locator.findAll(externalProjectSettings)) {
       timeStamp += virtualFile.getTimeStamp();
     }
   }
   return timeStamp;
 }
  @Nullable
  public static ToolWindow ensureToolWindowContentInitialized(
      @NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    if (toolWindowManager == null) return null;

    final ToolWindow toolWindow =
        toolWindowManager.getToolWindow(externalSystemId.getReadableName());
    if (toolWindow == null) return null;

    if (toolWindow instanceof ToolWindowImpl) {
      ((ToolWindowImpl) toolWindow).ensureContentInitialized();
    }
    return toolWindow;
  }
 public static void ensureToolWindowInitialized(
     @NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
   ToolWindowManager manager = ToolWindowManager.getInstance(project);
   if (!(manager instanceof ToolWindowManagerEx)) {
     return;
   }
   ToolWindowManagerEx managerEx = (ToolWindowManagerEx) manager;
   String id = externalSystemId.getReadableName();
   ToolWindow window = manager.getToolWindow(id);
   if (window != null) {
     return;
   }
   ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
   for (final ToolWindowEP bean : beans) {
     if (id.equals(bean.id)) {
       managerEx.initToolWindow(bean);
     }
   }
 }