From 4f12966d666061ba461ceb4507a1f258d9fa50b9 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 11 Jun 2021 17:05:38 +0200 Subject: [PATCH] FIR IDE: warn about enabled Android plugin --- .../AndroidPluginWarningApplicationService.kt | 44 +++++++++++++++++++ idea/resources-fir/META-INF/plugin.xml | 3 ++ 2 files changed, 47 insertions(+) create mode 100644 idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/AndroidPluginWarningApplicationService.kt diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/AndroidPluginWarningApplicationService.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/AndroidPluginWarningApplicationService.kt new file mode 100644 index 00000000000..1eaa701a84b --- /dev/null +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/AndroidPluginWarningApplicationService.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.fir + +import com.intellij.ide.plugins.PluginManagerCore +import com.intellij.notification.Notification +import com.intellij.notification.NotificationDisplayType +import com.intellij.notification.NotificationType +import com.intellij.notification.NotificationsConfiguration +import com.intellij.openapi.extensions.PluginId +import com.intellij.openapi.project.Project +import com.intellij.openapi.startup.StartupActivity + +class AndroidPluginIncompatibilityCheckerStartupActivity : StartupActivity.DumbAware { + override fun runActivity(project: Project) { + NotificationsConfiguration.getNotificationsConfiguration() + .register( + AndroidPluginWarningNotification.ID, + NotificationDisplayType.STICKY_BALLOON, + true + ) + if (PluginManagerCore.getPlugin(PluginId.getId(ANDROID_PLUGIN_ID))?.isEnabled == true) { + AndroidPluginWarningNotification().notify(project) + } + } + + companion object { + private const val ANDROID_PLUGIN_ID = "org.jetbrains.android" + } +} + +private class AndroidPluginWarningNotification : Notification( + ID, + ID, + "Android Plugin is incompatible with FIR IDE. Please, consider disabling Android plugin. Otherwise, Kotlin resolve may not work.", + NotificationType.ERROR, +) { + companion object { + const val ID = "Android Plugin is incompatible with FIR IDE" + } +} \ No newline at end of file diff --git a/idea/resources-fir/META-INF/plugin.xml b/idea/resources-fir/META-INF/plugin.xml index 5694da69875..d38eae65136 100644 --- a/idea/resources-fir/META-INF/plugin.xml +++ b/idea/resources-fir/META-INF/plugin.xml @@ -116,6 +116,9 @@ The Kotlin FIR plugin provides language support in IntelliJ IDEA and Android Stu + + +