From b3861199cccafd1e5f4fd575944df022ca75d636 Mon Sep 17 00:00:00 2001 From: David Herman Date: Mon, 24 Jun 2024 14:23:11 -0700 Subject: [PATCH] Update KobwebColorProvider to not use internal analyze APIs Fixes #49 --- .../kobweb/intellij/colors/KobwebColorProvider.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/kotlin/com/varabyte/kobweb/intellij/colors/KobwebColorProvider.kt b/plugin/src/main/kotlin/com/varabyte/kobweb/intellij/colors/KobwebColorProvider.kt index 12a70f7..c6ac0f6 100644 --- a/plugin/src/main/kotlin/com/varabyte/kobweb/intellij/colors/KobwebColorProvider.kt +++ b/plugin/src/main/kotlin/com/varabyte/kobweb/intellij/colors/KobwebColorProvider.kt @@ -8,13 +8,14 @@ import com.intellij.psi.PsiElement import com.intellij.psi.impl.source.tree.LeafPsiElement import com.varabyte.kobweb.intellij.util.kobweb.isInKobwebSource import com.varabyte.kobweb.intellij.util.kobweb.isInReadableKobwebProject -import org.jetbrains.kotlin.analysis.api.analyze -import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode import org.jetbrains.kotlin.idea.base.psi.kotlinFqName +import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.js.translate.declaration.hasCustomGetter import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import java.awt.Color import kotlin.math.abs @@ -174,10 +175,11 @@ private inline fun Collection + val bindingContext = expr.analyze(BodyResolveMode.PARTIAL) + val constant = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expr) ?: return@mapNotNull null + val type = bindingContext.getType(expr) ?: return@mapNotNull null + constant.getValue(type) as? Evaluated } return if (evaluatedArguments.size != argCount) null