Skip to content

Commit 5a7c345

Browse files
dimonchik0036Space
authored and
Space
committed
[notification] add notification about new jvm ir backend
^KT-44523 Fixed
1 parent f9dd878 commit 5a7c345

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerService.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType
3131
import org.jetbrains.kotlin.idea.KotlinJvmBundle
3232
import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary
3333
import org.jetbrains.kotlin.idea.configuration.ui.notifications.notifyKotlinStyleUpdateIfNeeded
34+
import org.jetbrains.kotlin.idea.configuration.ui.notifications.notifyNewJVMBackendIfNeeded
3435
import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies
3536
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
3637
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
@@ -51,7 +52,7 @@ class KotlinConfigurationCheckerStartupActivity : StartupActivity {
5152
})
5253

5354
notifyKotlinStyleUpdateIfNeeded(project)
54-
55+
notifyNewJVMBackendIfNeeded(project)
5556
KotlinConfigurationCheckerService.getInstance(project).performProjectPostOpenActions()
5657
}
5758
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4+
*/
5+
6+
package org.jetbrains.kotlin.idea.configuration.ui.notifications
7+
8+
import com.intellij.ide.util.PropertiesComponent
9+
import com.intellij.notification.*
10+
import com.intellij.openapi.project.Project
11+
import org.jetbrains.kotlin.idea.KotlinBundle
12+
import org.jetbrains.kotlin.idea.KotlinPluginVersion
13+
14+
15+
private const val NEW_JVM_BACKEND_NOTIFICATION_ID = "New JVM Backend"
16+
private const val NEW_JVM_BACKEND_WAS_PROMOTED = "new.jvm.backend.notification"
17+
private const val NEW_JVM_BACKEND_BLOG_POST = "https://blog.jetbrains.com/kotlin/2021/01/jvm-backend-is-in-beta/"
18+
19+
fun notifyNewJVMBackendIfNeeded(project: Project) {
20+
val propertiesComponent = PropertiesComponent.getInstance()
21+
if (propertiesComponent.getBoolean(NEW_JVM_BACKEND_WAS_PROMOTED)) return
22+
val kotlinVersion = KotlinPluginVersion.getCurrent()?.kotlinVersion ?: return
23+
if (kotlinVersion < "1.4.30" || kotlinVersion >= "1.5.0") return
24+
25+
val notification = Notification(
26+
NEW_JVM_BACKEND_NOTIFICATION_ID,
27+
KotlinBundle.message("notification.title.new.jvm.ir.backend"),
28+
KotlinBundle.message("notification.message.new.jvm.ir.backend"),
29+
NotificationType.INFORMATION,
30+
).apply {
31+
addAction(BrowseNotificationAction(KotlinBundle.message("notification.action.new.jvm.ir.backend"), NEW_JVM_BACKEND_BLOG_POST))
32+
33+
isImportant = true
34+
}
35+
36+
NotificationsConfiguration.getNotificationsConfiguration().register(
37+
NEW_JVM_BACKEND_NOTIFICATION_ID,
38+
NotificationDisplayType.STICKY_BALLOON,
39+
)
40+
41+
notification.notify(project)
42+
propertiesComponent.setValue(NEW_JVM_BACKEND_WAS_PROMOTED, true)
43+
}
44+

idea/resources-en/messages/KotlinBundle.properties

+5-1
Original file line numberDiff line numberDiff line change
@@ -2222,4 +2222,8 @@ hints.codevision.inheritors.to_many.format={0,number}+ Inheritors
22222222
hints.codevision.overrides.format={0, choice, 1#1 Override|2#{0,number} Overrides}
22232223
hints.codevision.overrides.to_many.format={0,number}+ Overrides
22242224
hints.codevision.settings=Settings...
2225-
inspection.unused.result.of.data.class.copy=Unused result of data class copy
2225+
inspection.unused.result.of.data.class.copy=Unused result of data class copy
2226+
2227+
notification.title.new.jvm.ir.backend=It's Time to Try the JVM IR Backend
2228+
notification.message.new.jvm.ir.backend=The new JVM backend has reached the Beta stage. Read about its benefits in this blog post.<br>We plan to enable it by default from Kotlin 1.5 (coming in spring 2021). We kindly ask you to test it on your main project. This blog post explains how to enable it and share your feedback.
2229+
notification.action.new.jvm.ir.backend=Open the blog

0 commit comments

Comments
 (0)