Rename
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.ResolveSessionUtils.safeNameForLazyResolve;
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.StorageManager.MemoizationMode.STRONG;
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.StorageManager.ReferenceKind.STRONG;
|
||||
|
||||
public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, DP extends DeclarationProvider> implements JetScope {
|
||||
protected final ResolveSession resolveSession;
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class FileBasedDeclarationProviderFactory implements DeclarationProviderF
|
||||
public PackageMemberDeclarationProvider fun(FqName fqName) {
|
||||
return createPackageMemberDeclarationProvider(fqName);
|
||||
}
|
||||
}, StorageManager.MemoizationMode.STRONG);
|
||||
}, StorageManager.ReferenceKind.STRONG);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class LazyPackageMemberScope extends AbstractLazyMemberScope<NamespaceDes
|
||||
public NamespaceDescriptor fun(Name name) {
|
||||
return createPackageDescriptor(name);
|
||||
}
|
||||
}, StorageManager.MemoizationMode.STRONG);
|
||||
}, StorageManager.ReferenceKind.STRONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-7
@@ -32,7 +32,7 @@ import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.StorageManager.MemoizationMode.WEAK;
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.StorageManager.ReferenceKind.WEAK;
|
||||
|
||||
public class LockBasedStorageManager implements StorageManager {
|
||||
|
||||
@@ -45,9 +45,9 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <K, V> Function<K, V> createMemoizedFunction(@NotNull final Function<K, V> compute, @NotNull final MemoizationMode modeForValues) {
|
||||
public <K, V> Function<K, V> createMemoizedFunction(@NotNull final Function<K, V> compute, @NotNull final ReferenceKind valuesReferenceKind) {
|
||||
return new Function<K, V>() {
|
||||
private final ConcurrentMap<K, V> cache = createConcurrentMap(modeForValues);
|
||||
private final ConcurrentMap<K, V> cache = createConcurrentMap(valuesReferenceKind);
|
||||
|
||||
@Override
|
||||
public V fun(@NotNull final K input) {
|
||||
@@ -72,10 +72,10 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public <K, V> Function<K, V> createMemoizedFunctionWithNullableValues(
|
||||
@NotNull final Function<K, V> compute, @NotNull final MemoizationMode modeForValues
|
||||
@NotNull final Function<K, V> compute, @NotNull final ReferenceKind valuesReferenceKind
|
||||
) {
|
||||
return new Function<K, V>() {
|
||||
private final ConcurrentMap<K, LazyValue<V>> cache = createConcurrentMap(modeForValues);
|
||||
private final ConcurrentMap<K, LazyValue<V>> cache = createConcurrentMap(valuesReferenceKind);
|
||||
|
||||
@Override
|
||||
public V fun(@NotNull final K input) {
|
||||
@@ -97,8 +97,8 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
};
|
||||
}
|
||||
|
||||
private static <K, V> ConcurrentMap<K, V> createConcurrentMap(MemoizationMode mode) {
|
||||
return (mode == WEAK) ? new ConcurrentWeakValueHashMap<K, V>() : new ConcurrentHashMap<K, V>();
|
||||
private static <K, V> ConcurrentMap<K, V> createConcurrentMap(ReferenceKind referenceKind) {
|
||||
return (referenceKind == WEAK) ? new ConcurrentWeakValueHashMap<K, V>() : new ConcurrentHashMap<K, V>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.StorageManager.MemoizationMode.WEAK;
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.StorageManager.ReferenceKind.WEAK;
|
||||
|
||||
public class ScopeProvider {
|
||||
private final ResolveSession resolveSession;
|
||||
|
||||
@@ -26,12 +26,15 @@ public interface StorageManager {
|
||||
/**
|
||||
* Given a function compute: K -> V create a memoized version of it that computes a value only once for each key
|
||||
* @param compute the function to be memoized
|
||||
* @param modeForValues how to store teh memoized values
|
||||
* @param valuesReferenceKind how to store teh memoized values
|
||||
*
|
||||
* NOTE: if compute() has side-effects the WEAK reference kind is dangerous: the side-effects will be repeated if
|
||||
* the value gets collected and then re-computed
|
||||
*/
|
||||
@NotNull
|
||||
<K, V> Function<K, V> createMemoizedFunction(@NotNull Function<K, V> compute, @NotNull MemoizationMode modeForValues);
|
||||
<K, V> Function<K, V> createMemoizedFunction(@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind);
|
||||
@NotNull
|
||||
<K, V> Function<K, V> createMemoizedFunctionWithNullableValues(@NotNull Function<K, V> compute, @NotNull MemoizationMode modeForValues);
|
||||
<K, V> Function<K, V> createMemoizedFunctionWithNullableValues(@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind);
|
||||
|
||||
@NotNull
|
||||
<T> LazyValue<T> createLazyValue(@NotNull Computable<T> computable);
|
||||
@@ -56,7 +59,7 @@ public interface StorageManager {
|
||||
@NotNull
|
||||
BindingTrace createSafeTrace(@NotNull BindingTrace originalTrace);
|
||||
|
||||
enum MemoizationMode {
|
||||
enum ReferenceKind {
|
||||
STRONG,
|
||||
WEAK
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user