IDEA-CR-17158 rename computeAndGet to computeCachedValue, add javadoc

This commit is contained in:
Vladimir Krivosheev
2017-02-09 12:34:15 +01:00
parent dd09cff85d
commit a0b2549d11
2 changed files with 10 additions and 3 deletions
@@ -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
}