From 99ced62350c3ebd1c82d03b6be852947a2add550 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Thu, 16 Jan 2025 00:06:01 +0100 Subject: [PATCH] Fixed CCE in lockedCached and test dependencies --- build.gradle.kts | 1 + src/main/kotlin/util/psi-utils.kt | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9686388bd..46edd384e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -113,6 +113,7 @@ dependencies { bundledPlugin("org.jetbrains.plugins.yaml") testFramework(TestFrameworkType.JUnit5) + testFramework(TestFrameworkType.Platform) testFramework(TestFrameworkType.Plugin.Java) pluginVerifier() diff --git a/src/main/kotlin/util/psi-utils.kt b/src/main/kotlin/util/psi-utils.kt index 4c3d33041..7a60cedf8 100644 --- a/src/main/kotlin/util/psi-utils.kt +++ b/src/main/kotlin/util/psi-utils.kt @@ -66,6 +66,7 @@ import com.intellij.psi.filters.ElementFilter import com.intellij.psi.util.CachedValue import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager +import com.intellij.psi.util.ParameterizedCachedValue import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTypesUtil import com.intellij.psi.util.TypeConversionUtil @@ -262,9 +263,10 @@ inline fun PsiElement.lockedCached( val cacheLock = cacheLocks.computeIfAbsent(key) { ReentrantReadWriteLock() } cacheLock.read { - val value = getUserData(key)?.upToDateOrNull - if (value != null) { - return value.get() + // The cast seems necessary since 2025.1, ParameterizedCachedValue doesn't extend CachedValue anymore... + @Suppress("UNCHECKED_CAST") val value = getUserData(key as Key>) + if (value?.hasUpToDateValue() == true) { + return value.getValue(dependencies) } }