Your version of Kotlin runtime in '$libraryName' library is $readableVersion, while plugin version is $pluginVersion.
" + + "Runtime library should be updated to avoid compatibility problems.
" + + "" + } + else { + val libraryNames = versionedOutdatedLibraries.keys.joinToString { it.library.name!! } + + "Version of Kotlin runtime is outdated in several libraries ($libraryNames). Plugin version is $pluginVersion.
" + + "Runtime libraries should be updated to avoid compatibility problems.
" + + "" + } + + + Notifications.Bus.notify(Notification(OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Outdated Kotlin Runtime", message, + NotificationType.WARNING, NotificationListener { notification, event -> + if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) { + if ("update" == event.description) { + val outdatedLibraries = findOutdatedKotlinLibraries(project).map { it.key.library } + updateLibraries(project, outdatedLibraries) + suggestDeleteKotlinJsIfNeeded(project, outdatedLibraries) } - - val message: String = if (versionedOutdatedLibraries.size == 1) { - val versionedLibrary = versionedOutdatedLibraries.first() - - val version = versionedLibrary.version - val readableVersion = version ?: "unknown" - val libraryName = versionedLibrary.library.name - - "Your version of Kotlin runtime in '$libraryName' library is $readableVersion, while plugin version is $pluginVersion.
" + - "Runtime library should be updated to avoid compatibility problems.
" + - "" + else if ("ignore" == event.description) { + PropertiesComponent.getInstance(project).setValue(SUPPRESSED_PROPERTY_NAME, pluginVersion) } else { - val libraryNames = versionedOutdatedLibraries.joinToString { it.library.name!! } - - "Version of Kotlin runtime is outdated in several libraries ($libraryNames). Plugin version is $pluginVersion.
" + - "Runtime libraries should be updated to avoid compatibility problems.
" + - "" + throw AssertionError() } + notification.expire() + } + }), project) + return versionedOutdatedLibraries.flatMap { it.value } +} - Notifications.Bus.notify(Notification(OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Outdated Kotlin Runtime", message, - NotificationType.WARNING, NotificationListener { notification, event -> - if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) { - if ("update" == event.description) { - val outdatedLibraries = findOutdatedKotlinLibraries(myProject).map { it.library } - updateLibraries(myProject, outdatedLibraries) - suggestDeleteKotlinJsIfNeeded(outdatedLibraries) - } - else if ("ignore" == event.description) { - PropertiesComponent.getInstance(myProject).setValue(SUPPRESSED_PROPERTY_NAME, pluginVersion) - } - else { - throw AssertionError() - } - notification.expire() - } - }), myProject) - }) - } +private fun deleteKotlinJs(project: Project) { + ApplicationManager.getApplication().invokeLater { + runWriteAction { + val kotlinJsFile = project.baseDir.findFileByRelativePath("script/kotlin.js") ?: return@runWriteAction - private fun deleteKotlinJs() { - ApplicationManager.getApplication().invokeLater { - runWriteAction { - val kotlinJsFile = myProject.baseDir.findFileByRelativePath("script/kotlin.js") ?: return@runWriteAction - - val fileToDelete = getLocalFile(kotlinJsFile) - try { - val parent = fileToDelete.parent - fileToDelete.delete(this) - parent.refresh(false, true) - } - catch (ex: IOException) { - Notifications.Bus.notify( - Notification(OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Error", "Could not delete 'script/kotlin.js': " + ex.message, NotificationType.ERROR)) - } + val fileToDelete = getLocalFile(kotlinJsFile) + try { + val parent = fileToDelete.parent + fileToDelete.delete(null) + parent.refresh(false, true) + } + catch (ex: IOException) { + Notifications.Bus.notify( + Notification(OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Error", "Could not delete 'script/kotlin.js': " + ex.message, NotificationType.ERROR)) } } } - - private fun suggestDeleteKotlinJsIfNeeded(outdatedLibraries: CollectionFile 'script/kotlin.js' was probably created by an older version of the Kotlin plugin.
" + - "The new Kotlin plugin copies an up-to-date version of this file to the output directory automatically, so the old version of it can be deleted.
" + - "" - - Notifications.Bus.notify(Notification(OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Outdated Kotlin Runtime", message, - NotificationType.WARNING, NotificationListener { notification, event -> - if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) { - if ("delete" == event.description) { - deleteKotlinJs() - } - else if ("ignore" == event.description) { - // pass - } - else { - throw AssertionError() - } - notification.expire() - } - }), myProject) - } - - companion object { - private val SUPPRESSED_PROPERTY_NAME = "oudtdated.runtime.suppressed.plugin.version" - private val OUTDATED_RUNTIME_GROUP_DISPLAY_ID = "Outdated Kotlin Runtime" - - private fun findOutdatedKotlinLibraries(project: Project): CollectionFile 'script/kotlin.js' was probably created by an older version of the Kotlin plugin.
" + + "The new Kotlin plugin copies an up-to-date version of this file to the output directory automatically, so the old version of it can be deleted.
" + + "" + + Notifications.Bus.notify(Notification(OUTDATED_RUNTIME_GROUP_DISPLAY_ID, "Outdated Kotlin Runtime", message, + NotificationType.WARNING, NotificationListener { notification, event -> + if (event.eventType == HyperlinkEvent.EventType.ACTIVATED) { + if ("delete" == event.description) { + deleteKotlinJs(project) + } + else if ("ignore" == event.description) { + // pass + } + else { + throw AssertionError() + } + notification.expire() + } + }), project) +} + +private val SUPPRESSED_PROPERTY_NAME = "oudtdated.runtime.suppressed.plugin.version" +private val OUTDATED_RUNTIME_GROUP_DISPLAY_ID = "Outdated Kotlin Runtime" + +private fun findOutdatedKotlinLibraries(project: Project): Map