Skip to content

Commit

Permalink
Fixed CCE in lockedCached and test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Jan 15, 2025
1 parent 90a58d3 commit 99ced62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ dependencies {
bundledPlugin("org.jetbrains.plugins.yaml")

testFramework(TestFrameworkType.JUnit5)
testFramework(TestFrameworkType.Platform)
testFramework(TestFrameworkType.Plugin.Java)

pluginVerifier()
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/util/psi-utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -262,9 +263,10 @@ inline fun <T> 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<ParameterizedCachedValue<T, Any>>)
if (value?.hasUpToDateValue() == true) {
return value.getValue(dependencies)
}
}

Expand Down

0 comments on commit 99ced62

Please sign in to comment.