// queue each activity in smart mode separately so that if one of them starts dumb mode, the next // ones just wait for it to finish private void queueSmartModeActivity(final Runnable activity) { DumbService.getInstance(myProject) .runWhenSmart( new Runnable() { @Override public void run() { runActivity(activity); } }); }
public void runPostStartupActivities() { if (postStartupActivityPassed()) { return; } final Application app = ApplicationManager.getApplication(); if (!app.isHeadlessEnvironment()) { checkFsSanity(); checkProjectRoots(); } runActivities(myDumbAwarePostStartupActivities); DumbService.getInstance(myProject) .runWhenSmart( new Runnable() { @Override public void run() { app.assertIsDispatchThread(); // myDumbAwarePostStartupActivities might be non-empty if new activities were // registered during dumb mode runActivities(myDumbAwarePostStartupActivities); //noinspection SynchronizeOnThis synchronized (StartupManagerImpl.this) { if (!myNotDumbAwarePostStartupActivities.isEmpty()) { while (!myNotDumbAwarePostStartupActivities.isEmpty()) { queueSmartModeActivity(myNotDumbAwarePostStartupActivities.remove(0)); } // return here later to set myPostStartupActivitiesPassed DumbService.getInstance(myProject).runWhenSmart(this); } else { myPostStartupActivitiesPassed = true; } } } }); // otherwise will be stored - we must not create config files in tests if (!app.isUnitTestMode()) { Registry.get("ide.firstStartup").setValue(false); } }