diff --git a/base/src/com/google/idea/blaze/base/async/executor/ProgressIndicatorStub.kt b/base/src/com/google/idea/blaze/base/async/executor/ProgressIndicatorStub.kt index cb3f271855b..795713a150b 100644 --- a/base/src/com/google/idea/blaze/base/async/executor/ProgressIndicatorStub.kt +++ b/base/src/com/google/idea/blaze/base/async/executor/ProgressIndicatorStub.kt @@ -34,7 +34,7 @@ object ProgressIndicatorStub : ProgressIndicatorEx { override fun isModal(): Boolean { return false } - override fun getModalityState(): ModalityState { return ModalityState.defaultModalityState() } + override fun getModalityState(): ModalityState { return ModalityState.nonModal() } override fun setModalityProgress(p0: ProgressIndicator?) { } diff --git a/kotlin/src/com/google/idea/blaze/kotlin/sync/BlazeKotlinSyncPlugin.java b/kotlin/src/com/google/idea/blaze/kotlin/sync/BlazeKotlinSyncPlugin.java index 907b824570f..2847370bba1 100644 --- a/kotlin/src/com/google/idea/blaze/kotlin/sync/BlazeKotlinSyncPlugin.java +++ b/kotlin/src/com/google/idea/blaze/kotlin/sync/BlazeKotlinSyncPlugin.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.idea.blaze.base.async.executor.ProgressIndicatorStub; import com.google.idea.blaze.base.ideinfo.KotlinToolchainIdeInfo; import com.google.idea.blaze.base.model.BlazeProjectData; import com.google.idea.blaze.base.model.BlazeVersionData; @@ -44,6 +45,7 @@ import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.pom.java.LanguageLevel; @@ -326,31 +328,33 @@ public void afterSync( KotlinJavaModuleConfigurator.Companion.getInstance(); NotificationMessageCollector collector = new NotificationMessageCollector(project, "Configuring Kotlin", "Configuring Kotlin"); - Application application = ApplicationManager.getApplication(); - application.invokeAndWait( - () -> { - configurator.getOrCreateKotlinLibrary(project, collector); - }); - - List> writeActions = new ArrayList<>(); - application.runReadAction( - () -> { - configurator.configureModule(workspaceModule, collector, writeActions); - }); - - if (ApplicationManager.getApplication().isUnitTestMode()) { - // do not invoke it later since serviceContainer may be disposed before it get completed + ProgressManager.getInstance().runProcess(() -> { + Application application = ApplicationManager.getApplication(); application.invokeAndWait( () -> { - writeActions.stream().forEach(Function0::invoke); + configurator.getOrCreateKotlinLibrary(project, collector); }); - } else { - application.invokeLater( + + List> writeActions = new ArrayList<>(); + application.runReadAction( () -> { - writeActions.stream().forEach(Function0::invoke); + configurator.configureModule(workspaceModule, collector, writeActions); }); - } + + if (ApplicationManager.getApplication().isUnitTestMode()) { + // do not invoke it later since serviceContainer may be disposed before it get completed + application.invokeAndWait( + () -> { + writeActions.stream().forEach(Function0::invoke); + }); + } else { + application.invokeLater( + () -> { + writeActions.stream().forEach(Function0::invoke); + }); + } + }, ProgressIndicatorStub.INSTANCE); } } }