Skip to content

Commit

Permalink
feature: experimental support for IntelliJ IDEA
Browse files Browse the repository at this point in the history
  • Loading branch information
popovanton0 committed May 22, 2024
1 parent c6e6dfd commit 63be05f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private class KelpConfigService(val project: Project) : Disposable {
data = kelpConfig
AddLiveTemplates.execute(kelpConfig, project.name)
if (!isFirstRun) reloadNotification()
service<GrazieProNotification>().notifyIfNeeded(project, previousConfig, kelpConfig)
project.service<GrazieProNotification>().notifyIfNeeded(previousConfig, kelpConfig)
}.onFailure {
invalidConfigError(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>() ?: GutterIconCache.getInstance()
presentation.icon = gutterIconCache.getIcon(file, resolver, facet)
}

companion object {
Expand Down

0 comments on commit 63be05f

Please sign in to comment.