Remove outdated runtime notification
#KT-23122 Fixed #KT-21634 Fixed #KT-20324 Fixed #KT-18366 Fixed #KT-20910 Fixed Outdated runtime notification was abandoned.
This commit is contained in:
+1
-7
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.idea.configuration.showConfigureKotlinNotificationIf
|
||||
import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies
|
||||
import org.jetbrains.kotlin.idea.versions.collectModulesWithOutdatedRuntime
|
||||
import org.jetbrains.kotlin.idea.versions.findOutdatedKotlinLibraries
|
||||
import org.jetbrains.kotlin.idea.versions.notifyOutdatedKotlinRuntime
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class KotlinConfigurationCheckerComponent(project: Project) : AbstractProjectComponent(project) {
|
||||
@@ -84,13 +83,8 @@ class KotlinConfigurationCheckerComponent(project: Project) : AbstractProjectCom
|
||||
module.getAndCacheLanguageLevelByDependencies()
|
||||
}
|
||||
|
||||
val libraries = findOutdatedKotlinLibraries(myProject)
|
||||
if (!libraries.isEmpty()) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
notifyOutdatedKotlinRuntime(myProject, libraries)
|
||||
}
|
||||
}
|
||||
if (!isSyncing) {
|
||||
val libraries = findOutdatedKotlinLibraries(myProject)
|
||||
val excludeModules = collectModulesWithOutdatedRuntime(libraries)
|
||||
showConfigureKotlinNotificationIfNeeded(myProject, excludeModules)
|
||||
} else {
|
||||
|
||||
@@ -16,12 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.versions
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.notification.NotificationListener
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.notification.Notifications
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||
@@ -32,21 +26,14 @@ import com.intellij.util.text.VersionComparatorUtil
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.framework.JavaRuntimeDetectionUtil
|
||||
import org.jetbrains.kotlin.idea.framework.JsLibraryStdDetectionUtil
|
||||
import javax.swing.event.HyperlinkEvent
|
||||
|
||||
data class VersionedLibrary(val library: Library, val version: String?, val usedInModules: Collection<Module>)
|
||||
|
||||
fun findOutdatedKotlinLibraries(project: Project): List<VersionedLibrary> {
|
||||
val pluginVersion = KotlinPluginUtil.getPluginVersion()
|
||||
if (KotlinPluginUtil.isSnapshotVersion()) return emptyList() // plugin is run from sources, can't compare versions
|
||||
if (KotlinPluginUtil.isDevVersion()) return emptyList()
|
||||
if (project.isDisposed) return emptyList()
|
||||
|
||||
// user already clicked suppress
|
||||
if (pluginVersion == PropertiesComponent.getInstance(project).getValue(SUPPRESSED_PROPERTY_NAME)) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val outdatedLibraries = arrayListOf<VersionedLibrary>()
|
||||
|
||||
for ((library, modules) in findAllUsedLibraries(project).entrySet()) {
|
||||
@@ -86,59 +73,6 @@ private fun isKotlinJsRuntime(library: Library, project: Project) =
|
||||
fun collectModulesWithOutdatedRuntime(libraries: List<VersionedLibrary>): List<Module> =
|
||||
libraries.flatMap { it.usedInModules }
|
||||
|
||||
fun notifyOutdatedKotlinRuntime(project: Project, outdatedLibraries: Collection<VersionedLibrary>) {
|
||||
val pluginVersion = KotlinPluginUtil.getPluginVersion()
|
||||
val message: String = if (outdatedLibraries.size == 1) {
|
||||
val versionedLibrary = outdatedLibraries.first()
|
||||
|
||||
val version = versionedLibrary.version
|
||||
val readableVersion = version ?: "unknown"
|
||||
val libraryName = versionedLibrary.library.name
|
||||
|
||||
"<p>Your version of Kotlin runtime in '$libraryName' library is $readableVersion, while plugin version is $pluginVersion.</p>" +
|
||||
"<p>Runtime library should be updated to avoid compatibility problems.</p>" +
|
||||
"<p><a href=\"update\">Update Runtime</a> <a href=\"ignore\">Ignore</a></p>"
|
||||
} else {
|
||||
val libraryNames = outdatedLibraries.joinToString { it.library.name ?: "unknown library" }
|
||||
|
||||
"<p>Version of Kotlin runtime is outdated in several libraries ($libraryNames). Plugin version is $pluginVersion.</p>" +
|
||||
"<p>Runtime libraries should be updated to avoid compatibility problems.</p>" +
|
||||
"<p><a href=\"update\">Update All</a> <a href=\"ignore\">Ignore</a></p>"
|
||||
}
|
||||
|
||||
|
||||
Notifications.Bus.notify(
|
||||
Notification(
|
||||
OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Outdated Kotlin Runtime", message,
|
||||
NotificationType.WARNING, NotificationListener { notification, event ->
|
||||
if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
when {
|
||||
"update" == event.description -> {
|
||||
val updatedOutdatedLibraries = findOutdatedKotlinLibraries(project).map { it.library }
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
updateLibraries(project, updatedOutdatedLibraries)
|
||||
}
|
||||
}
|
||||
"ignore" == event.description -> {
|
||||
if (!project.isDisposed) {
|
||||
PropertiesComponent.getInstance(project).setValue(SUPPRESSED_PROPERTY_NAME, pluginVersion)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
throw AssertionError()
|
||||
}
|
||||
}
|
||||
notification.expire()
|
||||
}
|
||||
}
|
||||
),
|
||||
project
|
||||
)
|
||||
}
|
||||
|
||||
private const val SUPPRESSED_PROPERTY_NAME = "oudtdated.runtime.suppressed.plugin.version"
|
||||
private const val OUTDATED_RUNTIME_GROUP_DISPLAY_ID = "Outdated Kotlin Runtime"
|
||||
|
||||
fun isRuntimeOutdated(libraryVersion: String?, runtimeVersion: String): Boolean {
|
||||
return libraryVersion == null || libraryVersion.startsWith("internal-") != runtimeVersion.startsWith("internal-") ||
|
||||
VersionComparatorUtil.compare(runtimeVersion.substringBefore("-release-"), libraryVersion) > 0
|
||||
|
||||
Reference in New Issue
Block a user