From 63be05ff23f21dd2cb9bcac813dce72e340e3424 Mon Sep 17 00:00:00 2001 From: popovanton0 Date: Wed, 22 May 2024 18:44:27 +0300 Subject: [PATCH] feature: experimental support for IntelliJ IDEA --- README.md | 6 ++++++ gradle.properties | 12 +++++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- .../kelp/pluginConfig/GrazieProNotification.kt | 4 ++-- .../ideplugin/kelp/pluginConfig/KelpConfigService.kt | 2 +- .../kelp/resourceIcons/DsIconLookupElement.kt | 4 +++- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9ec3fb2..89456fb 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,12 @@ color values to the plugin per project. > > Please, disable the Grazie Pro plugin if you want to use this feature. +## Experimental support for IntelliJ IDEA +Kelp plugin supports IntelliJ IDEA in addition to Android Studio. + +> [!WARNING] +> However, IntelliJ IDEA support is experimental and can be **dropped** anytime. **DO NOT** rely on it. + ## Installation 1. Make sure that you are using **Android Studio Koala | 2024.1.1 Canary 3** or later diff --git a/gradle.properties b/gradle.properties index 828b00d..6f1689f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,18 +9,20 @@ pluginVersion = 0.0.7 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html pluginSinceBuild = 241.14494.158 -pluginUntilBuild = 241.* +pluginUntilBuild = 242.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension -platformType = AI -platformVersion = 2024.1.1.1 +platformType = IC +platformVersion = 2024.1.1 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = android, com.intellij.java +# android plugin version is acquired from here: https://plugins.jetbrains.com/plugin/22989-android/versions +# cross-referenced with this: https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html +platformPlugins = org.jetbrains.android:241.15989.150, com.intellij.java, org.jetbrains.kotlin, org.toml.lang # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.4 +gradleVersion = 8.6 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f86..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/GrazieProNotification.kt b/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/GrazieProNotification.kt index 8efcec9..1ec2ddd 100644 --- a/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/GrazieProNotification.kt +++ b/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/GrazieProNotification.kt @@ -13,10 +13,10 @@ import ru.ozon.ideplugin.kelp.KelpBundle * [Issue](https://youtrack.jetbrains.com/issue/GRZ-4351) */ @Service(Service.Level.PROJECT) -class GrazieProNotification { +class GrazieProNotification(private val project: Project) { private var notified = false - fun notifyIfNeeded(project: Project, previousConfig: KelpConfig?, kelpConfig: KelpConfig) = invokeLater { + fun notifyIfNeeded(previousConfig: KelpConfig?, kelpConfig: KelpConfig) = invokeLater { if (!notified && kelpConfig.iconsRendering?.gutterEnabled == true && previousConfig?.iconsRendering?.gutterEnabled != true && diff --git a/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/KelpConfigService.kt b/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/KelpConfigService.kt index 15641cf..b089646 100644 --- a/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/KelpConfigService.kt +++ b/src/main/kotlin/ru/ozon/ideplugin/kelp/pluginConfig/KelpConfigService.kt @@ -60,7 +60,7 @@ private class KelpConfigService(val project: Project) : Disposable { data = kelpConfig AddLiveTemplates.execute(kelpConfig, project.name) if (!isFirstRun) reloadNotification() - service().notifyIfNeeded(project, previousConfig, kelpConfig) + project.service().notifyIfNeeded(previousConfig, kelpConfig) }.onFailure { invalidConfigError(it) } diff --git a/src/main/kotlin/ru/ozon/ideplugin/kelp/resourceIcons/DsIconLookupElement.kt b/src/main/kotlin/ru/ozon/ideplugin/kelp/resourceIcons/DsIconLookupElement.kt index e352968..d6f31e2 100644 --- a/src/main/kotlin/ru/ozon/ideplugin/kelp/resourceIcons/DsIconLookupElement.kt +++ b/src/main/kotlin/ru/ozon/ideplugin/kelp/resourceIcons/DsIconLookupElement.kt @@ -9,6 +9,7 @@ import com.android.tools.idea.util.androidFacet import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementDecorator import com.intellij.codeInsight.lookup.LookupElementPresentation +import com.intellij.openapi.components.serviceOrNull import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import org.jetbrains.android.AndroidAnnotatorUtil @@ -46,7 +47,8 @@ internal class DsIconLookupElement( ?.firstNotNullOfOrNull { it.getSourceAsVirtualFile() } ?: return val resolver = AndroidAnnotatorUtil.pickConfiguration(psiFile.originalFile, facet)?.resourceResolver ?: return - presentation.icon = GutterIconCache.getInstance(psiFile.project).getIcon(file, resolver, facet) + val gutterIconCache = psiFile.project.serviceOrNull() ?: GutterIconCache.getInstance() + presentation.icon = gutterIconCache.getIcon(file, resolver, facet) } companion object {