move the calculation of configure kotlin notification out of EDT
#KT-10541 Fixed
This commit is contained in:
@@ -16,12 +16,16 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.psi.search.FileTypeIndex
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinNotification
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
|
||||
@@ -56,10 +60,17 @@ fun showConfigureKotlinNotificationIfNeeded(module: Module) {
|
||||
}
|
||||
|
||||
fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: List<Module> = emptyList()) {
|
||||
val modules = getModulesWithKotlinFiles(project) - excludeModules
|
||||
if (modules.all { isModuleConfigured(it) }) return
|
||||
|
||||
ConfigureKotlinNotificationManager.notify(project, excludeModules)
|
||||
ApplicationManager.getApplication().executeOnPooledThread {
|
||||
val notificationString = DumbService.getInstance(project).runReadActionInSmartMode(Computable {
|
||||
val modules = getModulesWithKotlinFiles(project) - excludeModules
|
||||
if (modules.all { isModuleConfigured(it) }) null else ConfigureKotlinNotification.getNotificationString(project, excludeModules)
|
||||
})
|
||||
if (notificationString != null) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
ConfigureKotlinNotificationManager.notify(project, ConfigureKotlinNotification(project, excludeModules, notificationString))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getAbleToRunConfigurators(project: Project): Collection<KotlinProjectConfigurator> {
|
||||
|
||||
+7
-3
@@ -30,9 +30,10 @@ import javax.swing.event.HyperlinkEvent
|
||||
|
||||
class ConfigureKotlinNotification(
|
||||
project: Project,
|
||||
excludeModules: List<Module>) : Notification(KotlinConfigurationCheckerComponent.CONFIGURE_NOTIFICATION_GROUP_ID, "Configure Kotlin",
|
||||
getNotificationString(project, excludeModules),
|
||||
NotificationType.WARNING, NotificationListener { notification, event ->
|
||||
excludeModules: List<Module>,
|
||||
notificationString: String) : Notification(KotlinConfigurationCheckerComponent.CONFIGURE_NOTIFICATION_GROUP_ID, "Configure Kotlin",
|
||||
notificationString,
|
||||
NotificationType.WARNING, NotificationListener { notification, event ->
|
||||
if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
val configurator = getConfiguratorByName(event.description) ?: throw AssertionError("Missed action: " + event.description)
|
||||
notification.expire()
|
||||
@@ -41,6 +42,9 @@ class ConfigureKotlinNotification(
|
||||
}
|
||||
}) {
|
||||
|
||||
constructor(project: Project, excludeModules: List<Module>)
|
||||
: this(project, excludeModules, getNotificationString(project, excludeModules))
|
||||
|
||||
override fun equals(o: Any?): Boolean {
|
||||
if (this === o) return true
|
||||
if (o !is ConfigureKotlinNotification) return false
|
||||
|
||||
Reference in New Issue
Block a user