mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-17158 rename computeAndGet to computeCachedValue, add javadoc
This commit is contained in:
@@ -126,10 +126,17 @@ public abstract class CachedValuesManager {
|
||||
public static <T> T getCachedValue(@NotNull final PsiElement psi, @NotNull final CachedValueProvider<T> provider) {
|
||||
Key<CachedValue<T>> key = getKeyForClass(provider.getClass(), globalKeyForProvider);
|
||||
CachedValue<T> 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> T computeAndGet(@NotNull final PsiElement psi, @NotNull Key<CachedValue<T>> key, @NotNull final CachedValueProvider<T> 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> T computeCachedValue(@NotNull final PsiElement psi, @NotNull Key<CachedValue<T>> key, @NotNull final CachedValueProvider<T> provider) {
|
||||
return getManager(psi.getProject()).getCachedValue(psi, key, new CachedValueProvider<T>() {
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -24,5 +24,5 @@ import com.intellij.psi.PsiElement
|
||||
*/
|
||||
inline fun <T> PsiElement.getCachedValue(key: Key<CachedValue<T>>, provider: () -> CachedValueProvider<T>): 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
|
||||
}
|
||||
Reference in New Issue
Block a user