diff --git a/platform/core-api/src/com/intellij/psi/util/CachedValuesManager.java b/platform/core-api/src/com/intellij/psi/util/CachedValuesManager.java index 86b237803a76..e0879d381d40 100644 --- a/platform/core-api/src/com/intellij/psi/util/CachedValuesManager.java +++ b/platform/core-api/src/com/intellij/psi/util/CachedValuesManager.java @@ -126,10 +126,17 @@ public abstract class CachedValuesManager { public static T getCachedValue(@NotNull final PsiElement psi, @NotNull final CachedValueProvider provider) { Key> key = getKeyForClass(provider.getClass(), globalKeyForProvider); CachedValue value = psi.getUserData(key); - return value == null ? computeAndGet(psi, key, provider) : value.getValue(); + return value == null ? computeCachedValue(psi, key, provider) : value.getValue(); } - public static T computeAndGet(@NotNull final PsiElement psi, @NotNull Key> key, @NotNull final CachedValueProvider provider) { + /** + * Create a cached value with the given provider and non-tracked return value, store it in PSI element's user data. + * + * Consider to use high-level {@link #getCachedValue} or, in Kotlin code, PsiElement.getCachedValue. + * + * @return The cached value + */ + public static T computeCachedValue(@NotNull final PsiElement psi, @NotNull Key> key, @NotNull final CachedValueProvider provider) { return getManager(psi.getProject()).getCachedValue(psi, key, new CachedValueProvider() { @Nullable @Override diff --git a/platform/lang-impl/src/com/intellij/psi/util/cachedValue.kt b/platform/lang-impl/src/com/intellij/psi/util/cachedValue.kt index 35e07fa89c54..b35733005f2d 100644 --- a/platform/lang-impl/src/com/intellij/psi/util/cachedValue.kt +++ b/platform/lang-impl/src/com/intellij/psi/util/cachedValue.kt @@ -24,5 +24,5 @@ import com.intellij.psi.PsiElement */ inline fun PsiElement.getCachedValue(key: Key>, provider: () -> CachedValueProvider): T { val value = getUserData(key) - return if (value == null) CachedValuesManager.computeAndGet(this, key, provider()) else value.value + return if (value == null) CachedValuesManager.computeCachedValue(this, key, provider()) else value.value } \ No newline at end of file