diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/PsiModificationTrackerBasedCachedValue.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/PsiModificationTrackerBasedCachedValue.kt deleted file mode 100644 index 7b41e8923b7..00000000000 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/PsiModificationTrackerBasedCachedValue.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.idea.util - -import com.intellij.openapi.project.Project -import com.intellij.psi.util.CachedValueProvider -import com.intellij.psi.util.CachedValuesManager -import com.intellij.psi.util.PsiModificationTracker -import kotlin.properties.ReadOnlyProperty -import kotlin.reflect.KProperty - -/** - * Creates a value which will be cached until until any physical PSI change happens - * To create one please use [psiModificationTrackerBasedCachedValue] - * - * @see com.intellij.psi.util.CachedValue - * @see com.intellij.psi.util.PsiModificationTracker.MODIFICATION_COUNT - */ -class PsiModificationTrackerBasedCachedValue(project: Project, createValue: () -> T) : ReadOnlyProperty { - private val cachedValue = CachedValuesManager.getManager(project).createCachedValue { - CachedValueProvider.Result( - createValue(), - PsiModificationTracker.MODIFICATION_COUNT - ) - } - - override fun getValue(thisRef: Any?, property: KProperty<*>): T = cachedValue.value -} - -/** - * Creates a value which will be cached until until any physical PSI change happens - * - * @see com.intellij.psi.util.CachedValue - * @see com.intellij.psi.util.PsiModificationTracker.MODIFICATION_COUNT - * @see PsiModificationTrackerBasedCachedValue - */ -fun psiModificationTrackerBasedCachedValue(project: Project, createValue: () -> T): PsiModificationTrackerBasedCachedValue = - PsiModificationTrackerBasedCachedValue(project, createValue) \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/trackerUtils.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/trackerUtils.kt index f8c0c750b00..8ef1f15cf7c 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/trackerUtils.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/trackerUtils.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.project.Project import com.intellij.psi.util.CachedValue import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager +import com.intellij.psi.util.PsiModificationTracker import kotlin.reflect.KProperty @Suppress("NOTHING_TO_INLINE") @@ -21,3 +22,12 @@ inline fun cachedValue(project: Project, vararg dependencies: Any, crossinli dependencies ) } + +/** + * Creates a value which will be cached until until any physical PSI change happens + * + * @see com.intellij.psi.util.CachedValue + * @see com.intellij.psi.util.PsiModificationTracker.MODIFICATION_COUNT + */ +fun psiModificationTrackerBasedCachedValue(project: Project, createValue: () -> T) = + cachedValue(project, PsiModificationTracker.MODIFICATION_COUNT, createValue = createValue) \ No newline at end of file