From ea8575c5a35ee7cc49c7a4a4ba15bd5910a8d8cb Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 22 Apr 2019 17:55:39 +0300 Subject: [PATCH] Remove check for Kotlin misconfiguration for the whole project (KT-30644) Consider an existing project to be previously configured. There's still "Configure Kotlin" action, check for configuration triggered by adding a new Kotlin file, and notification in Kotlin files. #KT-30644 Fixed --- .../ConfigureKotlinInProjectUtils.kt | 14 +---- .../ui/KotlinConfigurationCheckerComponent.kt | 63 ------------------- 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt index dbc799b99ae..e0752fc89f5 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt @@ -154,18 +154,6 @@ fun showConfigureKotlinNotificationIfNeeded(module: Module) { ConfigureKotlinNotificationManager.notify(module.project) } -fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: List = emptyList()) { - val notificationState = DumbService.getInstance(project).runReadActionInSmartMode(Computable { - ConfigureKotlinNotification.getNotificationState(project, excludeModules) - }) - - if (notificationState != null) { - ApplicationManager.getApplication().invokeLater { - ConfigureKotlinNotificationManager.notify(project, ConfigureKotlinNotification(project, excludeModules, notificationState)) - } - } -} - fun isNotConfiguredNotificationRequired(moduleGroup: ModuleSourceRootGroup): Boolean { return !SuppressNotificationState.isKotlinNotConfiguredSuppressed(moduleGroup) && !isModuleConfigured(moduleGroup) } @@ -240,8 +228,8 @@ fun getConfigurationPossibilitiesForConfigureNotification( runnableConfigurators.add(configurator) } ConfigureKotlinStatus.CONFIGURED -> moduleAlreadyConfigured = true + } } - } if (moduleCanBeConfigured && !moduleAlreadyConfigured && !SuppressNotificationState.isKotlinNotConfiguredSuppressed( moduleSourceRootGroup ) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt index 5c0936a5bec..04149e3d1c8 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.idea.configuration.ui -import com.intellij.ProjectTopics import com.intellij.notification.NotificationDisplayType import com.intellij.notification.NotificationsConfiguration import com.intellij.openapi.application.ApplicationManager @@ -25,75 +24,21 @@ import com.intellij.openapi.components.ProjectComponent import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataImportListener import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.ModuleRootEvent -import com.intellij.openapi.roots.ModuleRootListener import com.intellij.openapi.startup.StartupManager -import org.jetbrains.kotlin.idea.configuration.checkHideNonConfiguredNotifications import org.jetbrains.kotlin.idea.configuration.getModulesWithKotlinFiles import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary -import org.jetbrains.kotlin.idea.configuration.showConfigureKotlinNotificationIfNeeded import org.jetbrains.kotlin.idea.configuration.ui.notifications.notifyKotlinStyleUpdateIfNeeded import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies -import org.jetbrains.kotlin.idea.versions.collectModulesWithOutdatedRuntime -import org.jetbrains.kotlin.idea.versions.findOutdatedKotlinLibraries -import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger class KotlinConfigurationCheckerComponent(val project: Project) : ProjectComponent { private val syncDepth = AtomicInteger() - @Volatile - private var notificationPostponed = false - - private val moduleRootListener = object : ModuleRootListener { - - private val checkInProgress = AtomicBoolean(false) - - private val modulesUpdatedDuringCheck = AtomicBoolean(false) - - override fun rootsChanged(event: ModuleRootEvent) { - try { - modulesUpdatedDuringCheck.set(true) - // forbid running multiple checks in parallel - if (!checkInProgress.compareAndSet(false, true)) return - - // if during the execution of the current check the module list has updated, we should re-run this check - do { - modulesUpdatedDuringCheck.set(false) - if (!project.isInitialized) return - - if (notificationPostponed && !isSyncing) { - DumbService.getInstance(project).runWhenSmart { - if (!isSyncing) { - notificationPostponed = false - - val excludeModules = collectModulesWithOutdatedRuntime(findOutdatedKotlinLibraries(project)) - - showConfigureKotlinNotificationIfNeeded( - project, - excludeModules - ) - } - } - } - - checkHideNonConfiguredNotifications(project) - } while ( - modulesUpdatedDuringCheck.get() - ) - } finally { - checkInProgress.set(false) - } - } - } - init { NotificationsConfiguration.getNotificationsConfiguration() .register(CONFIGURE_NOTIFICATION_GROUP_ID, NotificationDisplayType.STICKY_BALLOON, true) val connection = project.messageBus.connect() - connection.subscribe(ProjectTopics.PROJECT_ROOTS, moduleRootListener) - connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener { notifyOutdatedBundledCompilerIfNecessary(project) }) @@ -116,14 +61,6 @@ class KotlinConfigurationCheckerComponent(val project: Project) : ProjectCompone for (module in getModulesWithKotlinFiles(project)) { module.getAndCacheLanguageLevelByDependencies() } - - if (!isSyncing) { - val libraries = findOutdatedKotlinLibraries(project) - val excludeModules = collectModulesWithOutdatedRuntime(libraries) - showConfigureKotlinNotificationIfNeeded(project, excludeModules) - } else { - notificationPostponed = true - } } }