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
This commit is contained in:
+1
-13
@@ -154,18 +154,6 @@ fun showConfigureKotlinNotificationIfNeeded(module: Module) {
|
|||||||
ConfigureKotlinNotificationManager.notify(module.project)
|
ConfigureKotlinNotificationManager.notify(module.project)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: List<Module> = 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 {
|
fun isNotConfiguredNotificationRequired(moduleGroup: ModuleSourceRootGroup): Boolean {
|
||||||
return !SuppressNotificationState.isKotlinNotConfiguredSuppressed(moduleGroup) && !isModuleConfigured(moduleGroup)
|
return !SuppressNotificationState.isKotlinNotConfiguredSuppressed(moduleGroup) && !isModuleConfigured(moduleGroup)
|
||||||
}
|
}
|
||||||
@@ -240,8 +228,8 @@ fun getConfigurationPossibilitiesForConfigureNotification(
|
|||||||
runnableConfigurators.add(configurator)
|
runnableConfigurators.add(configurator)
|
||||||
}
|
}
|
||||||
ConfigureKotlinStatus.CONFIGURED -> moduleAlreadyConfigured = true
|
ConfigureKotlinStatus.CONFIGURED -> moduleAlreadyConfigured = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (moduleCanBeConfigured && !moduleAlreadyConfigured && !SuppressNotificationState.isKotlinNotConfiguredSuppressed(
|
if (moduleCanBeConfigured && !moduleAlreadyConfigured && !SuppressNotificationState.isKotlinNotConfiguredSuppressed(
|
||||||
moduleSourceRootGroup
|
moduleSourceRootGroup
|
||||||
)
|
)
|
||||||
|
|||||||
-63
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.configuration.ui
|
package org.jetbrains.kotlin.idea.configuration.ui
|
||||||
|
|
||||||
import com.intellij.ProjectTopics
|
|
||||||
import com.intellij.notification.NotificationDisplayType
|
import com.intellij.notification.NotificationDisplayType
|
||||||
import com.intellij.notification.NotificationsConfiguration
|
import com.intellij.notification.NotificationsConfiguration
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
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.externalSystem.service.project.manage.ProjectDataImportListener
|
||||||
import com.intellij.openapi.project.DumbService
|
import com.intellij.openapi.project.DumbService
|
||||||
import com.intellij.openapi.project.Project
|
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 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.getModulesWithKotlinFiles
|
||||||
import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary
|
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.configuration.ui.notifications.notifyKotlinStyleUpdateIfNeeded
|
||||||
import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies
|
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
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
class KotlinConfigurationCheckerComponent(val project: Project) : ProjectComponent {
|
class KotlinConfigurationCheckerComponent(val project: Project) : ProjectComponent {
|
||||||
private val syncDepth = AtomicInteger()
|
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 {
|
init {
|
||||||
NotificationsConfiguration.getNotificationsConfiguration()
|
NotificationsConfiguration.getNotificationsConfiguration()
|
||||||
.register(CONFIGURE_NOTIFICATION_GROUP_ID, NotificationDisplayType.STICKY_BALLOON, true)
|
.register(CONFIGURE_NOTIFICATION_GROUP_ID, NotificationDisplayType.STICKY_BALLOON, true)
|
||||||
|
|
||||||
val connection = project.messageBus.connect()
|
val connection = project.messageBus.connect()
|
||||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, moduleRootListener)
|
|
||||||
|
|
||||||
connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener {
|
connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener {
|
||||||
notifyOutdatedBundledCompilerIfNecessary(project)
|
notifyOutdatedBundledCompilerIfNecessary(project)
|
||||||
})
|
})
|
||||||
@@ -116,14 +61,6 @@ class KotlinConfigurationCheckerComponent(val project: Project) : ProjectCompone
|
|||||||
for (module in getModulesWithKotlinFiles(project)) {
|
for (module in getModulesWithKotlinFiles(project)) {
|
||||||
module.getAndCacheLanguageLevelByDependencies()
|
module.getAndCacheLanguageLevelByDependencies()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSyncing) {
|
|
||||||
val libraries = findOutdatedKotlinLibraries(project)
|
|
||||||
val excludeModules = collectModulesWithOutdatedRuntime(libraries)
|
|
||||||
showConfigureKotlinNotificationIfNeeded(project, excludeModules)
|
|
||||||
} else {
|
|
||||||
notificationPostponed = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user