@Override
  public void runWhenProjectIsInitialized(@NotNull final Runnable action) {
    final Application application = ApplicationManager.getApplication();
    if (application == null) return;

    //noinspection SynchronizeOnThis
    synchronized (this) {
      // in tests which simulate project opening, post-startup activities could have been run
      // already.
      // Then we should act as if the project was initialized
      boolean initialized =
          myProject.isInitialized()
              || application.isUnitTestMode() && myPostStartupActivitiesPassed;
      if (!initialized) {
        registerPostStartupActivity(action);
        return;
      }
    }

    Runnable runnable =
        new Runnable() {
          @Override
          public void run() {
            if (!myProject.isDisposed()) {
              action.run();
            }
          }
        };
    if (application.isDispatchThread() && ModalityState.current() == ModalityState.NON_MODAL) {
      runnable.run();
    } else {
      application.invokeLater(runnable, ModalityState.NON_MODAL);
    }
  }
 @Override
 public synchronized void registerPostStartupActivity(@NotNull Runnable runnable) {
   LOG.assertTrue(
       !myPostStartupActivitiesPassed,
       "Registering post-startup activity that will never be run:"
           + " disposed="
           + myProject.isDisposed()
           + "; open="
           + myProject.isOpen()
           + "; passed="
           + myStartupActivitiesPassed);
   (DumbService.isDumbAware(runnable)
           ? myDumbAwarePostStartupActivities
           : myNotDumbAwarePostStartupActivities)
       .add(runnable);
 }
  private void checkFsSanity() {
    try {
      String path = myProject.getProjectFilePath();
      if (path == null || FileUtil.isAncestor(PathManager.getConfigPath(), path, true)) {
        return;
      }

      boolean actual = FileUtil.isFileSystemCaseSensitive(path);
      LOG.info(path + " case-sensitivity: " + actual);
      if (actual != SystemInfo.isFileSystemCaseSensitive) {
        int prefix =
            SystemInfo.isFileSystemCaseSensitive ? 1 : 0; // IDE=true -> FS=false -> prefix='in'
        String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title");
        String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix);
        Notifications.Bus.notify(
            new Notification(
                Notifications.SYSTEM_MESSAGES_GROUP_ID,
                title,
                text,
                NotificationType.WARNING,
                NotificationListener.URL_OPENING_LISTENER),
            myProject);
      }
    } catch (FileNotFoundException e) {
      LOG.warn(e);
    }
  }