StorageManager API does not use Computable and Function and more
This commit is contained in:
committed by
Alexander Udalov
parent
7d1c46ed2c
commit
239ca9728d
+3
-3
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.descriptors.serialization;
|
package org.jetbrains.jet.descriptors.serialization;
|
||||||
|
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
|
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
|
||||||
@@ -38,9 +38,9 @@ public abstract class AbstractDescriptorFinder implements DescriptorFinder {
|
|||||||
) {
|
) {
|
||||||
this.annotationDeserializer = annotationDeserializer;
|
this.annotationDeserializer = annotationDeserializer;
|
||||||
|
|
||||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function<ClassId, ClassDescriptor>() {
|
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function1<ClassId, ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor fun(ClassId classId) {
|
public ClassDescriptor invoke(ClassId classId) {
|
||||||
ClassData classData = getClassData(classId);
|
ClassData classData = getClassData(classId);
|
||||||
if (classData == null) {
|
if (classData == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+11
-11
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.descriptors.serialization;
|
package org.jetbrains.jet.descriptors.serialization;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.util.Function;
|
|
||||||
import gnu.trove.TIntObjectHashMap;
|
import gnu.trove.TIntObjectHashMap;
|
||||||
|
import jet.Function0;
|
||||||
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedTypeParameterDescriptor;
|
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedTypeParameterDescriptor;
|
||||||
@@ -26,12 +26,12 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -94,9 +94,9 @@ public class TypeDeserializer {
|
|||||||
typeParameterDescriptors.put(typeParameterDescriptor.getProtoId(), typeParameterDescriptor);
|
typeParameterDescriptors.put(typeParameterDescriptor.getProtoId(), typeParameterDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.classDescriptors = storageManager.createMemoizedFunctionWithNullableValues(new Function<Integer, ClassDescriptor>() {
|
this.classDescriptors = storageManager.createMemoizedFunctionWithNullableValues(new Function1<Integer, ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor fun(Integer fqNameIndex) {
|
public ClassDescriptor invoke(Integer fqNameIndex) {
|
||||||
return computeClassDescriptor(fqNameIndex);
|
return computeClassDescriptor(fqNameIndex);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
@@ -210,15 +210,15 @@ public class TypeDeserializer {
|
|||||||
this.typeProto = proto;
|
this.typeProto = proto;
|
||||||
this.arguments = typeArguments(proto.getArgumentList());
|
this.arguments = typeArguments(proto.getArgumentList());
|
||||||
|
|
||||||
this.constructor = storageManager.createLazyValue(new Computable<TypeConstructor>() {
|
this.constructor = storageManager.createLazyValue(new Function0<TypeConstructor>() {
|
||||||
@Override
|
@Override
|
||||||
public TypeConstructor compute() {
|
public TypeConstructor invoke() {
|
||||||
return typeConstructor(typeProto);
|
return typeConstructor(typeProto);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.memberScope = storageManager.createLazyValue(new Computable<JetScope>() {
|
this.memberScope = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return computeMemberScope();
|
return computeMemberScope();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+16
-16
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.*;
|
import org.jetbrains.jet.descriptors.serialization.*;
|
||||||
@@ -26,10 +26,6 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.impl.*;
|
import org.jetbrains.jet.lang.descriptors.impl.*;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
||||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.NullableLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.InnerClassesScopeWrapper;
|
import org.jetbrains.jet.lang.resolve.scopes.InnerClassesScopeWrapper;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
@@ -39,6 +35,10 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
|||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.TypeConstructor;
|
import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.NullableLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -96,9 +96,9 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
|||||||
this.deserializer = outerDeserializer.createChildDeserializer(this, classProto.getTypeParameterList(), typeParameters);
|
this.deserializer = outerDeserializer.createChildDeserializer(this, classProto.getTypeParameterList(), typeParameters);
|
||||||
this.typeDeserializer = deserializer.getTypeDeserializer();
|
this.typeDeserializer = deserializer.getTypeDeserializer();
|
||||||
|
|
||||||
this.containingDeclaration = storageManager.createLazyValue(new Computable<DeclarationDescriptor>() {
|
this.containingDeclaration = storageManager.createLazyValue(new Function0<DeclarationDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public DeclarationDescriptor compute() {
|
public DeclarationDescriptor invoke() {
|
||||||
return computeContainingDeclaration();
|
return computeContainingDeclaration();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -115,23 +115,23 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
|||||||
this.isInner = Flags.INNER.get(flags);
|
this.isInner = Flags.INNER.get(flags);
|
||||||
|
|
||||||
this.annotationDeserializer = annotationResolver;
|
this.annotationDeserializer = annotationResolver;
|
||||||
this.annotations = storageManager.createLazyValue(new Computable<List<AnnotationDescriptor>>() {
|
this.annotations = storageManager.createLazyValue(new Function0<List<AnnotationDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<AnnotationDescriptor> compute() {
|
public List<AnnotationDescriptor> invoke() {
|
||||||
return computeAnnotations();
|
return computeAnnotations();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.primaryConstructor = storageManager.createNullableLazyValue(new Computable<ConstructorDescriptor>() {
|
this.primaryConstructor = storageManager.createNullableLazyValue(new Function0<ConstructorDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ConstructorDescriptor compute() {
|
public ConstructorDescriptor invoke() {
|
||||||
return computePrimaryConstructor();
|
return computePrimaryConstructor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Computable<ClassDescriptor>() {
|
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor compute() {
|
public ClassDescriptor invoke() {
|
||||||
return computeClassObjectDescriptor();
|
return computeClassObjectDescriptor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -490,9 +490,9 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
|||||||
|
|
||||||
public NestedClassDescriptors(@NotNull StorageManager storageManager, @NotNull Set<Name> declaredNames) {
|
public NestedClassDescriptors(@NotNull StorageManager storageManager, @NotNull Set<Name> declaredNames) {
|
||||||
this.declaredNames = declaredNames;
|
this.declaredNames = declaredNames;
|
||||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function<Name, ClassDescriptor>() {
|
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function1<Name, ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor fun(Name name) {
|
public ClassDescriptor invoke(Name name) {
|
||||||
return NestedClassDescriptors.this.declaredNames.contains(name) ?
|
return NestedClassDescriptors.this.declaredNames.contains(name) ?
|
||||||
descriptorFinder.findClass(classId.createNestedClassId(name)) :
|
descriptorFinder.findClass(classId.createNestedClassId(name)) :
|
||||||
null;
|
null;
|
||||||
|
|||||||
+13
-13
@@ -16,20 +16,20 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.DescriptorDeserializer;
|
import org.jetbrains.jet.descriptors.serialization.DescriptorDeserializer;
|
||||||
import org.jetbrains.jet.descriptors.serialization.Flags;
|
import org.jetbrains.jet.descriptors.serialization.Flags;
|
||||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -73,27 +73,27 @@ public abstract class DeserializedMemberScope implements JetScope {
|
|||||||
this.deserializer = deserializer;
|
this.deserializer = deserializer;
|
||||||
|
|
||||||
this.membersProtos = groupByName(membersList);
|
this.membersProtos = groupByName(membersList);
|
||||||
this.functions = storageManager.createMemoizedFunction(new Function<Name, Collection<FunctionDescriptor>>() {
|
this.functions = storageManager.createMemoizedFunction(new Function1<Name, Collection<FunctionDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<FunctionDescriptor> fun(Name name) {
|
public Collection<FunctionDescriptor> invoke(Name name) {
|
||||||
return computeFunctions(name);
|
return computeFunctions(name);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
this.properties = storageManager.createMemoizedFunction(new Function<Name, Collection<VariableDescriptor>>() {
|
this.properties = storageManager.createMemoizedFunction(new Function1<Name, Collection<VariableDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<VariableDescriptor> fun(Name name) {
|
public Collection<VariableDescriptor> invoke(Name name) {
|
||||||
return computeProperties(name);
|
return computeProperties(name);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
this.allDescriptors = storageManager.createLazyValue(new Computable<Collection<DeclarationDescriptor>>() {
|
this.allDescriptors = storageManager.createLazyValue(new Function0<Collection<DeclarationDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<DeclarationDescriptor> compute() {
|
public Collection<DeclarationDescriptor> invoke() {
|
||||||
return computeAllDescriptors();
|
return computeAllDescriptors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.objectDescriptors = storageManager.createLazyValue(new Computable<Collection<ClassDescriptor>>() {
|
this.objectDescriptors = storageManager.createLazyValue(new Function0<Collection<ClassDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<ClassDescriptor> compute() {
|
public Collection<ClassDescriptor> invoke() {
|
||||||
return computeAllObjectDescriptors();
|
return computeAllObjectDescriptors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.Computable;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.tree.IElementType;
|
import com.intellij.psi.tree.IElementType;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -316,9 +317,9 @@ public class DescriptorResolver {
|
|||||||
DeferredType.create(trace,
|
DeferredType.create(trace,
|
||||||
createRecursionIntolerantLazyValueWithDefault(
|
createRecursionIntolerantLazyValueWithDefault(
|
||||||
ErrorUtils.createErrorType("Recursive dependency"),
|
ErrorUtils.createErrorType("Recursive dependency"),
|
||||||
new Computable<JetType>() {
|
new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
JetType type = expressionTypingServices
|
JetType type = expressionTypingServices
|
||||||
.getBodyExpressionType(trace, scope, dataFlowInfo, function,
|
.getBodyExpressionType(trace, scope, dataFlowInfo, function,
|
||||||
functionDescriptor);
|
functionDescriptor);
|
||||||
@@ -1037,9 +1038,9 @@ public class DescriptorResolver {
|
|||||||
trace,
|
trace,
|
||||||
createRecursionIntolerantLazyValueWithDefault(
|
createRecursionIntolerantLazyValueWithDefault(
|
||||||
ErrorUtils.createErrorType("Recursive dependency"),
|
ErrorUtils.createErrorType("Recursive dependency"),
|
||||||
new Computable<JetType>() {
|
new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return resolveDelegatedPropertyType((PropertyDescriptor) variableDescriptor, scope,
|
return resolveDelegatedPropertyType((PropertyDescriptor) variableDescriptor, scope,
|
||||||
propertyDelegateExpression, dataFlowInfo, trace);
|
propertyDelegateExpression, dataFlowInfo, trace);
|
||||||
}
|
}
|
||||||
@@ -1056,9 +1057,9 @@ public class DescriptorResolver {
|
|||||||
return DeferredType.create(trace,
|
return DeferredType.create(trace,
|
||||||
createRecursionIntolerantLazyValueWithDefault(
|
createRecursionIntolerantLazyValueWithDefault(
|
||||||
ErrorUtils.createErrorType("Recursive dependency"),
|
ErrorUtils.createErrorType("Recursive dependency"),
|
||||||
new Computable<JetType>() {
|
new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
JetType type =
|
JetType type =
|
||||||
resolveInitializerType(scope, initializer, dataFlowInfo, trace);
|
resolveInitializerType(scope, initializer, dataFlowInfo, trace);
|
||||||
|
|
||||||
@@ -1384,9 +1385,9 @@ public class DescriptorResolver {
|
|||||||
final ClassDescriptor enumClassDescriptor = (ClassDescriptor) classObject.getContainingDeclaration();
|
final ClassDescriptor enumClassDescriptor = (ClassDescriptor) classObject.getContainingDeclaration();
|
||||||
assert DescriptorUtils.isEnumClass(enumClassDescriptor) : "values should be created in enum class: " + enumClassDescriptor;
|
assert DescriptorUtils.isEnumClass(enumClassDescriptor) : "values should be created in enum class: " + enumClassDescriptor;
|
||||||
return DescriptorFactory
|
return DescriptorFactory
|
||||||
.createEnumClassObjectValuesMethod(classObject, DeferredType.create(trace, new Computable<JetType>() {
|
.createEnumClassObjectValuesMethod(classObject, DeferredType.create(trace, new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return KotlinBuiltIns.getInstance().getArrayType(enumClassDescriptor.getDefaultType());
|
return KotlinBuiltIns.getInstance().getArrayType(enumClassDescriptor.getDefaultType());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -1401,9 +1402,9 @@ public class DescriptorResolver {
|
|||||||
final ClassDescriptor enumClassDescriptor = (ClassDescriptor) classObject.getContainingDeclaration();
|
final ClassDescriptor enumClassDescriptor = (ClassDescriptor) classObject.getContainingDeclaration();
|
||||||
assert DescriptorUtils.isEnumClass(enumClassDescriptor) : "valueOf should be created in enum class: " + enumClassDescriptor;
|
assert DescriptorUtils.isEnumClass(enumClassDescriptor) : "valueOf should be created in enum class: " + enumClassDescriptor;
|
||||||
return DescriptorFactory
|
return DescriptorFactory
|
||||||
.createEnumClassObjectValueOfMethod(classObject, DeferredType.create(trace, new Computable<JetType>() {
|
.createEnumClassObjectValueOfMethod(classObject, DeferredType.create(trace, new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return enumClassDescriptor.getDefaultType();
|
return enumClassDescriptor.getDefaultType();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve;
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -240,9 +240,9 @@ public class TypeResolver {
|
|||||||
return typeParameterDescriptor.getUpperBoundsAsType().getMemberScope();
|
return typeParameterDescriptor.getUpperBoundsAsType().getMemberScope();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new LazyScopeAdapter(NO_LOCKS.createLazyValue(new Computable<JetScope>() {
|
return new LazyScopeAdapter(NO_LOCKS.createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return typeParameterDescriptor.getUpperBoundsAsType().getMemberScope();
|
return typeParameterDescriptor.getUpperBoundsAsType().getMemberScope();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.lazy;
|
package org.jetbrains.jet.lang.resolve.lazy;
|
||||||
|
|
||||||
import com.google.common.collect.*;
|
import com.google.common.collect.*;
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -35,9 +35,9 @@ class ImportsProvider {
|
|||||||
|
|
||||||
public ImportsProvider(StorageManager storageManager, final List<JetImportDirective> importDirectives) {
|
public ImportsProvider(StorageManager storageManager, final List<JetImportDirective> importDirectives) {
|
||||||
this.importDirectives = importDirectives;
|
this.importDirectives = importDirectives;
|
||||||
this.importsCacheValue = storageManager.createLazyValue(new Computable<NameToImportsCache>() {
|
this.importsCacheValue = storageManager.createLazyValue(new Function0<NameToImportsCache>() {
|
||||||
@Override
|
@Override
|
||||||
public NameToImportsCache compute() {
|
public NameToImportsCache invoke() {
|
||||||
return NameToImportsCache.createIndex(importDirectives);
|
return NameToImportsCache.createIndex(importDirectives);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ package org.jetbrains.jet.lang.resolve.lazy;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -27,11 +27,11 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
|||||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.Importer;
|
import org.jetbrains.jet.lang.resolve.Importer;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -75,9 +75,9 @@ public class LazyImportScope implements JetScope {
|
|||||||
return status.scope;
|
return status.scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolveSession.getStorageManager().compute(new Computable<JetScope>() {
|
return resolveSession.getStorageManager().compute(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
ImportResolveStatus cachedStatus = importResolveStatus;
|
ImportResolveStatus cachedStatus = importResolveStatus;
|
||||||
if (cachedStatus != null && (cachedStatus.lookupMode == mode || cachedStatus.lookupMode == LookupMode.EVERYTHING)) {
|
if (cachedStatus != null && (cachedStatus.lookupMode == mode || cachedStatus.lookupMode == LookupMode.EVERYTHING)) {
|
||||||
return cachedStatus.scope;
|
return cachedStatus.scope;
|
||||||
@@ -130,9 +130,9 @@ public class LazyImportScope implements JetScope {
|
|||||||
this.traceForImportResolve = traceForImportResolve;
|
this.traceForImportResolve = traceForImportResolve;
|
||||||
this.debugName = debugName;
|
this.debugName = debugName;
|
||||||
|
|
||||||
this.importedScopesProvider = resolveSession.getStorageManager().createMemoizedFunction(new Function<JetImportDirective, ImportDirectiveResolveCache>() {
|
this.importedScopesProvider = resolveSession.getStorageManager().createMemoizedFunction(new Function1<JetImportDirective, ImportDirectiveResolveCache>() {
|
||||||
@Override
|
@Override
|
||||||
public ImportDirectiveResolveCache fun(JetImportDirective directive) {
|
public ImportDirectiveResolveCache invoke(JetImportDirective directive) {
|
||||||
return new ImportDirectiveResolveCache(directive);
|
return new ImportDirectiveResolveCache(directive);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
@@ -165,9 +165,9 @@ public class LazyImportScope implements JetScope {
|
|||||||
final LookupMode lookupMode,
|
final LookupMode lookupMode,
|
||||||
final JetScopeSelectorUtil.ScopeByNameSelector<D> descriptorSelector
|
final JetScopeSelectorUtil.ScopeByNameSelector<D> descriptorSelector
|
||||||
) {
|
) {
|
||||||
return resolveSession.getStorageManager().compute(new Computable<D>() {
|
return resolveSession.getStorageManager().compute(new Function0<D>() {
|
||||||
@Override
|
@Override
|
||||||
public D compute() {
|
public D invoke() {
|
||||||
for (JetImportDirective directive : importsProvider.getImports(name)) {
|
for (JetImportDirective directive : importsProvider.getImports(name)) {
|
||||||
if (directive == directiveUnderResolve) {
|
if (directive == directiveUnderResolve) {
|
||||||
// This is the recursion in imports analysis
|
// This is the recursion in imports analysis
|
||||||
@@ -191,9 +191,9 @@ public class LazyImportScope implements JetScope {
|
|||||||
final LookupMode lookupMode,
|
final LookupMode lookupMode,
|
||||||
final JetScopeSelectorUtil.ScopeByNameMultiSelector<D> descriptorsSelector
|
final JetScopeSelectorUtil.ScopeByNameMultiSelector<D> descriptorsSelector
|
||||||
) {
|
) {
|
||||||
return resolveSession.getStorageManager().compute(new Computable<Collection<D>>() {
|
return resolveSession.getStorageManager().compute(new Function0<Collection<D>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<D> compute() {
|
public Collection<D> invoke() {
|
||||||
Set<D> descriptors = Sets.newHashSet();
|
Set<D> descriptors = Sets.newHashSet();
|
||||||
for (JetImportDirective directive : importsProvider.getImports(name)) {
|
for (JetImportDirective directive : importsProvider.getImports(name)) {
|
||||||
if (directive == directiveUnderResolve) {
|
if (directive == directiveUnderResolve) {
|
||||||
@@ -214,9 +214,9 @@ public class LazyImportScope implements JetScope {
|
|||||||
final LookupMode lookupMode,
|
final LookupMode lookupMode,
|
||||||
final JetScopeSelectorUtil.ScopeDescriptorSelector<D> descriptorsSelector
|
final JetScopeSelectorUtil.ScopeDescriptorSelector<D> descriptorsSelector
|
||||||
) {
|
) {
|
||||||
return resolveSession.getStorageManager().compute(new Computable<Collection<D>>() {
|
return resolveSession.getStorageManager().compute(new Function0<Collection<D>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<D> compute() {
|
public Collection<D> invoke() {
|
||||||
Set<D> descriptors = Sets.newHashSet();
|
Set<D> descriptors = Sets.newHashSet();
|
||||||
for (JetImportDirective directive : importsProvider.getAllImports()) {
|
for (JetImportDirective directive : importsProvider.getAllImports()) {
|
||||||
if (directive == directiveUnderResolve) {
|
if (directive == directiveUnderResolve) {
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ package org.jetbrains.jet.lang.resolve.lazy;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.di.InjectorForLazyResolve;
|
import org.jetbrains.jet.di.InjectorForLazyResolve;
|
||||||
@@ -216,9 +216,9 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
|||||||
final JetClassLikeInfo classObjectInfo = parentClassDescriptor.getClassObjectInfo(classObject);
|
final JetClassLikeInfo classObjectInfo = parentClassDescriptor.getClassObjectInfo(classObject);
|
||||||
if (classObjectInfo != null) {
|
if (classObjectInfo != null) {
|
||||||
final Name name = DescriptorUtils.getClassObjectName(parentClassDescriptor.getName());
|
final Name name = DescriptorUtils.getClassObjectName(parentClassDescriptor.getName());
|
||||||
return storageManager.compute(new Computable<LazyClassDescriptor>() {
|
return storageManager.compute(new Function0<LazyClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public LazyClassDescriptor compute() {
|
public LazyClassDescriptor invoke() {
|
||||||
// Create under lock to avoid premature access to published 'this'
|
// Create under lock to avoid premature access to published 'this'
|
||||||
return new LazyClassDescriptor(ResolveSession.this, parentClassDescriptor, name, classObjectInfo);
|
return new LazyClassDescriptor(ResolveSession.this, parentClassDescriptor, name, classObjectInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,21 +17,21 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.lazy;
|
package org.jetbrains.jet.lang.resolve.lazy;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import com.intellij.util.Function;
|
import jet.Function0;
|
||||||
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor;
|
import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.ChainedScope;
|
import org.jetbrains.jet.lang.resolve.scopes.ChainedScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -48,16 +48,16 @@ public class ScopeProvider {
|
|||||||
public ScopeProvider(@NotNull ResolveSession resolveSession) {
|
public ScopeProvider(@NotNull ResolveSession resolveSession) {
|
||||||
this.resolveSession = resolveSession;
|
this.resolveSession = resolveSession;
|
||||||
|
|
||||||
this.fileScopes = resolveSession.getStorageManager().createMemoizedFunction(new Function<JetFile, JetScope>() {
|
this.fileScopes = resolveSession.getStorageManager().createMemoizedFunction(new Function1<JetFile, JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope fun(@NotNull JetFile file) {
|
public JetScope invoke(@NotNull JetFile file) {
|
||||||
return createFileScope(file);
|
return createFileScope(file);
|
||||||
}
|
}
|
||||||
}, WEAK);
|
}, WEAK);
|
||||||
|
|
||||||
this.defaultImportsScope = resolveSession.getStorageManager().createLazyValue(new Computable<JetScope>() {
|
this.defaultImportsScope = resolveSession.getStorageManager().createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return createScopeWithDefaultImports();
|
return createScopeWithDefaultImports();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-4
@@ -19,15 +19,15 @@ package org.jetbrains.jet.lang.resolve.lazy.data;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -41,9 +41,9 @@ public class FilteringClassLikeInfo implements JetClassLikeInfo {
|
|||||||
@NotNull final Predicate<? super JetDeclaration> declarationFilter
|
@NotNull final Predicate<? super JetDeclaration> declarationFilter
|
||||||
) {
|
) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.filteredDeclarations = storageManager.createLazyValue(new Computable<List<JetDeclaration>>() {
|
this.filteredDeclarations = storageManager.createLazyValue(new Function0<List<JetDeclaration>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<JetDeclaration> compute() {
|
public List<JetDeclaration> invoke() {
|
||||||
return Lists.newArrayList(Collections2.filter(delegate.getDeclarations(), declarationFilter));
|
return Lists.newArrayList(Collections2.filter(delegate.getDeclarations(), declarationFilter));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-4
@@ -20,12 +20,12 @@ import com.google.common.collect.ArrayListMultimap;
|
|||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -70,9 +70,9 @@ public abstract class AbstractPsiBasedDeclarationProvider implements Declaration
|
|||||||
private final NotNullLazyValue<Index> index;
|
private final NotNullLazyValue<Index> index;
|
||||||
|
|
||||||
public AbstractPsiBasedDeclarationProvider(@NotNull StorageManager storageManager) {
|
public AbstractPsiBasedDeclarationProvider(@NotNull StorageManager storageManager) {
|
||||||
index = storageManager.createLazyValue(new Computable<Index>() {
|
index = storageManager.createLazyValue(new Function0<Index>() {
|
||||||
@Override
|
@Override
|
||||||
public Index compute() {
|
public Index invoke() {
|
||||||
Index index = new Index();
|
Index index = new Index();
|
||||||
doCreateIndex(index);
|
doCreateIndex(index);
|
||||||
return index;
|
return index;
|
||||||
|
|||||||
+7
-6
@@ -19,20 +19,21 @@ package org.jetbrains.jet.lang.resolve.lazy.declarations;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.*;
|
import com.google.common.collect.*;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.NavigatablePsiElement;
|
import com.intellij.psi.NavigatablePsiElement;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
|
import jet.Function0;
|
||||||
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetNamespaceHeader;
|
import org.jetbrains.jet.lang.psi.JetNamespaceHeader;
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo;
|
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
import org.jetbrains.jet.util.QualifiedNamesUtil;
|
import org.jetbrains.jet.util.QualifiedNamesUtil;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -64,15 +65,15 @@ public class FileBasedDeclarationProviderFactory implements DeclarationProviderF
|
|||||||
) {
|
) {
|
||||||
this.storageManager = storageManager;
|
this.storageManager = storageManager;
|
||||||
this.isPackageDeclaredExternally = isPackageDeclaredExternally;
|
this.isPackageDeclaredExternally = isPackageDeclaredExternally;
|
||||||
this.index = storageManager.createLazyValue(new Computable<Index>() {
|
this.index = storageManager.createLazyValue(new Function0<Index>() {
|
||||||
@Override
|
@Override
|
||||||
public Index compute() {
|
public Index invoke() {
|
||||||
return computeFilesByPackage(files);
|
return computeFilesByPackage(files);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.packageDeclarationProviders = storageManager.createMemoizedFunctionWithNullableValues(new Function<FqName, PackageMemberDeclarationProvider>() {
|
this.packageDeclarationProviders = storageManager.createMemoizedFunctionWithNullableValues(new Function1<FqName, PackageMemberDeclarationProvider>() {
|
||||||
@Override
|
@Override
|
||||||
public PackageMemberDeclarationProvider fun(FqName fqName) {
|
public PackageMemberDeclarationProvider invoke(FqName fqName) {
|
||||||
return createPackageMemberDeclarationProvider(fqName);
|
return createPackageMemberDeclarationProvider(fqName);
|
||||||
}
|
}
|
||||||
}, StorageManager.ReferenceKind.STRONG);
|
}, StorageManager.ReferenceKind.STRONG);
|
||||||
|
|||||||
+5
-5
@@ -16,15 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.lazy.declarations;
|
package org.jetbrains.jet.lang.resolve.lazy.declarations;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.NavigatablePsiElement;
|
import com.intellij.psi.NavigatablePsiElement;
|
||||||
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ public class FileBasedPackageMemberDeclarationProvider extends AbstractPsiBasedD
|
|||||||
this.fqName = _fqName;
|
this.fqName = _fqName;
|
||||||
this.factory = _factory;
|
this.factory = _factory;
|
||||||
this.packageFiles = packageFiles;
|
this.packageFiles = packageFiles;
|
||||||
this.allDeclaredPackages = storageManager.createLazyValue(new Computable<Collection<FqName>>() {
|
this.allDeclaredPackages = storageManager.createLazyValue(new Function0<Collection<FqName>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<FqName> compute() {
|
public Collection<FqName> invoke() {
|
||||||
return factory.getAllDeclaredSubPackagesOf(fqName);
|
return factory.getAllDeclaredSubPackagesOf(fqName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+15
-14
@@ -17,9 +17,10 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.lazy.descriptors;
|
package org.jetbrains.jet.lang.resolve.lazy.descriptors;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
|
import jet.Function0;
|
||||||
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -28,12 +29,12 @@ import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
|||||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassInfoUtil;
|
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassInfoUtil;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.DeclarationProvider;
|
import org.jetbrains.jet.lang.resolve.lazy.declarations.DeclarationProvider;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -71,35 +72,35 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
|||||||
this.thisDescriptor = thisDescriptor;
|
this.thisDescriptor = thisDescriptor;
|
||||||
|
|
||||||
StorageManager storageManager = resolveSession.getStorageManager();
|
StorageManager storageManager = resolveSession.getStorageManager();
|
||||||
this.classDescriptors = storageManager.createMemoizedFunction(new Function<Name, List<ClassDescriptor>>() {
|
this.classDescriptors = storageManager.createMemoizedFunction(new Function1<Name, List<ClassDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<ClassDescriptor> fun(Name name) {
|
public List<ClassDescriptor> invoke(Name name) {
|
||||||
return resolveClassOrObjectDescriptor(name, false);
|
return resolveClassOrObjectDescriptor(name, false);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
this.objectDescriptors = storageManager.createMemoizedFunction(new Function<Name, List<ClassDescriptor>>() {
|
this.objectDescriptors = storageManager.createMemoizedFunction(new Function1<Name, List<ClassDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<ClassDescriptor> fun(Name name) {
|
public List<ClassDescriptor> invoke(Name name) {
|
||||||
return resolveClassOrObjectDescriptor(name, true);
|
return resolveClassOrObjectDescriptor(name, true);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
|
|
||||||
this.functionDescriptors = storageManager.createMemoizedFunction(new Function<Name, Set<FunctionDescriptor>>() {
|
this.functionDescriptors = storageManager.createMemoizedFunction(new Function1<Name, Set<FunctionDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<FunctionDescriptor> fun(Name name) {
|
public Set<FunctionDescriptor> invoke(Name name) {
|
||||||
return doGetFunctions(name);
|
return doGetFunctions(name);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
this.propertyDescriptors = storageManager.createMemoizedFunction(new Function<Name, Set<VariableDescriptor>>() {
|
this.propertyDescriptors = storageManager.createMemoizedFunction(new Function1<Name, Set<VariableDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<VariableDescriptor> fun(Name name) {
|
public Set<VariableDescriptor> invoke(Name name) {
|
||||||
return doGetProperties(name);
|
return doGetProperties(name);
|
||||||
}
|
}
|
||||||
}, STRONG);
|
}, STRONG);
|
||||||
|
|
||||||
this.allDescriptors = storageManager.createLazyValue(new Computable<AllDescriptors>() {
|
this.allDescriptors = storageManager.createLazyValue(new Function0<AllDescriptors>() {
|
||||||
@Override
|
@Override
|
||||||
public AllDescriptors compute() {
|
public AllDescriptors invoke() {
|
||||||
return computeAllDescriptors();
|
return computeAllDescriptors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+23
-23
@@ -20,10 +20,9 @@ import com.google.common.base.Predicate;
|
|||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.util.Consumer;
|
import jet.Function0;
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -124,39 +123,39 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
|||||||
this.isInner = isInnerClass(modifierList);
|
this.isInner = isInnerClass(modifierList);
|
||||||
|
|
||||||
StorageManager storageManager = resolveSession.getStorageManager();
|
StorageManager storageManager = resolveSession.getStorageManager();
|
||||||
this.thisAsReceiverParameter = storageManager.createLazyValue(new Computable<ReceiverParameterDescriptor>() {
|
this.thisAsReceiverParameter = storageManager.createLazyValue(new Function0<ReceiverParameterDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ReceiverParameterDescriptor compute() {
|
public ReceiverParameterDescriptor invoke() {
|
||||||
return DescriptorFactory.createLazyReceiverParameterDescriptor(LazyClassDescriptor.this);
|
return DescriptorFactory.createLazyReceiverParameterDescriptor(LazyClassDescriptor.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.annotations = storageManager.createLazyValue(new Computable<List<AnnotationDescriptor>>() {
|
this.annotations = storageManager.createLazyValue(new Function0<List<AnnotationDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<AnnotationDescriptor> compute() {
|
public List<AnnotationDescriptor> invoke() {
|
||||||
return resolveAnnotations();
|
return resolveAnnotations();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Computable<ClassDescriptor>() {
|
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<ClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor compute() {
|
public ClassDescriptor invoke() {
|
||||||
return computeClassObjectDescriptor();
|
return computeClassObjectDescriptor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Computable<JetScope>() {
|
this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return computeScopeForClassHeaderResolution();
|
return computeScopeForClassHeaderResolution();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.scopeForMemberDeclarationResolution = storageManager.createLazyValue(new Computable<JetScope>() {
|
this.scopeForMemberDeclarationResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return computeScopeForMemberDeclarationResolution();
|
return computeScopeForMemberDeclarationResolution();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.scopeForPropertyInitializerResolution = storageManager.createLazyValue(new Computable<JetScope>() {
|
this.scopeForPropertyInitializerResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return computeScopeForPropertyInitializerResolution();
|
return computeScopeForPropertyInitializerResolution();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -374,9 +373,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
|||||||
|
|
||||||
private class LazyClassTypeConstructor implements LazyDescriptor, TypeConstructor {
|
private class LazyClassTypeConstructor implements LazyDescriptor, TypeConstructor {
|
||||||
private final NotNullLazyValue<Collection<JetType>> supertypes = resolveSession.getStorageManager().createLazyValueWithPostCompute(
|
private final NotNullLazyValue<Collection<JetType>> supertypes = resolveSession.getStorageManager().createLazyValueWithPostCompute(
|
||||||
new Computable<Collection<JetType>>() {
|
new Function0<Collection<JetType>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<JetType> compute() {
|
public Collection<JetType> invoke() {
|
||||||
if (resolveSession.isClassSpecial(DescriptorUtils.getFQName(LazyClassDescriptor.this))) {
|
if (resolveSession.isClassSpecial(DescriptorUtils.getFQName(LazyClassDescriptor.this))) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -396,22 +395,23 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function<Boolean, Collection<JetType>>() {
|
new Function1<Boolean, Collection<JetType>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<JetType> fun(Boolean firstTime) {
|
public Collection<JetType> invoke(Boolean firstTime) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Consumer<Collection<JetType>>() {
|
new Function1<Collection<JetType>, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void consume(@NotNull Collection<JetType> supertypes) {
|
public Void invoke(@NotNull Collection<JetType> supertypes) {
|
||||||
findAndDisconnectLoopsInTypeHierarchy(supertypes);
|
findAndDisconnectLoopsInTypeHierarchy(supertypes);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
private final NotNullLazyValue<List<TypeParameterDescriptor>> parameters = resolveSession.getStorageManager().createLazyValue(new Computable<List<TypeParameterDescriptor>>() {
|
private final NotNullLazyValue<List<TypeParameterDescriptor>> parameters = resolveSession.getStorageManager().createLazyValue(new Function0<List<TypeParameterDescriptor>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<TypeParameterDescriptor> compute() {
|
public List<TypeParameterDescriptor> invoke() {
|
||||||
JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
|
JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
|
||||||
List<JetTypeParameter> typeParameters = classInfo.getTypeParameters();
|
List<JetTypeParameter> typeParameters = classInfo.getTypeParameters();
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.lazy.descriptors;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -82,9 +82,9 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
|||||||
@NotNull LazyClassDescriptor thisClass
|
@NotNull LazyClassDescriptor thisClass
|
||||||
) {
|
) {
|
||||||
super(resolveSession, declarationProvider, thisClass);
|
super(resolveSession, declarationProvider, thisClass);
|
||||||
this.primaryConstructor = resolveSession.getStorageManager().createNullableLazyValue(new Computable<ConstructorDescriptor>() {
|
this.primaryConstructor = resolveSession.getStorageManager().createNullableLazyValue(new Function0<ConstructorDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public ConstructorDescriptor compute() {
|
public ConstructorDescriptor invoke() {
|
||||||
return resolvePrimaryConstructor();
|
return resolvePrimaryConstructor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -378,9 +378,9 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
|||||||
|
|
||||||
private void setDeferredReturnType(@NotNull ConstructorDescriptorImpl descriptor) {
|
private void setDeferredReturnType(@NotNull ConstructorDescriptorImpl descriptor) {
|
||||||
descriptor.setReturnType(DeferredType.create(resolveSession.getTrace(), resolveSession.getStorageManager().createLazyValue(
|
descriptor.setReturnType(DeferredType.create(resolveSession.getTrace(), resolveSession.getStorageManager().createLazyValue(
|
||||||
new Computable<JetType>() {
|
new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return thisDescriptor.getDefaultType();
|
return thisDescriptor.getDefaultType();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+5
-5
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.lazy.descriptors;
|
package org.jetbrains.jet.lang.resolve.lazy.descriptors;
|
||||||
|
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -25,11 +25,11 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
|||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.PackageMemberDeclarationProvider;
|
import org.jetbrains.jet.lang.resolve.lazy.declarations.PackageMemberDeclarationProvider;
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -44,9 +44,9 @@ public class LazyPackageMemberScope extends AbstractLazyMemberScope<NamespaceDes
|
|||||||
super(resolveSession, declarationProvider, thisPackage);
|
super(resolveSession, declarationProvider, thisPackage);
|
||||||
|
|
||||||
this.packageDescriptors = resolveSession.getStorageManager().createMemoizedFunctionWithNullableValues(
|
this.packageDescriptors = resolveSession.getStorageManager().createMemoizedFunctionWithNullableValues(
|
||||||
new Function<Name, NamespaceDescriptor>() {
|
new Function1<Name, NamespaceDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor fun(Name name) {
|
public NamespaceDescriptor invoke(Name name) {
|
||||||
return createPackageDescriptor(name);
|
return createPackageDescriptor(name);
|
||||||
}
|
}
|
||||||
}, StorageManager.ReferenceKind.STRONG);
|
}, StorageManager.ReferenceKind.STRONG);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.types;
|
package org.jetbrains.jet.lang.types;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
@@ -38,7 +38,7 @@ public class DeferredType implements JetType {
|
|||||||
return deferredType;
|
return deferredType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DeferredType create(BindingTrace trace, Computable<JetType> compute) {
|
public static DeferredType create(BindingTrace trace, Function0<JetType> compute) {
|
||||||
return create(trace, LockBasedStorageManager.NO_LOCKS.createLazyValue(compute));
|
return create(trace, LockBasedStorageManager.NO_LOCKS.createLazyValue(compute));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -17,10 +17,10 @@
|
|||||||
package org.jetbrains.jet.lang.types.expressions;
|
package org.jetbrains.jet.lang.types.expressions;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.Function;
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -69,9 +69,9 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
if (slice == CLASS && declaration == expression.getObjectDeclaration()) {
|
if (slice == CLASS && declaration == expression.getObjectDeclaration()) {
|
||||||
JetType defaultType = DeferredType.create(context.trace, createRecursionIntolerantLazyValueWithDefault(
|
JetType defaultType = DeferredType.create(context.trace, createRecursionIntolerantLazyValueWithDefault(
|
||||||
ErrorUtils.createErrorType("Recursive dependency"),
|
ErrorUtils.createErrorType("Recursive dependency"),
|
||||||
new Computable<JetType>() {
|
new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return descriptor.getDefaultType();
|
return descriptor.getDefaultType();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package org.jetbrains.jet.storage;
|
package org.jetbrains.jet.storage;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.util.Consumer;
|
|
||||||
import com.intellij.util.Function;
|
|
||||||
import jet.Function0;
|
import jet.Function0;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@@ -167,9 +164,9 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
public void testRecursionIntolerance() throws Exception {
|
public void testRecursionIntolerance() throws Exception {
|
||||||
class C {
|
class C {
|
||||||
NotNullLazyValue<String> rec = m.createLazyValue(new Computable<String>() {
|
NotNullLazyValue<String> rec = m.createLazyValue(new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
return rec.invoke();
|
return rec.invoke();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -186,9 +183,9 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
public void testNullableRecursionIntolerance() throws Exception {
|
public void testNullableRecursionIntolerance() throws Exception {
|
||||||
class C {
|
class C {
|
||||||
NullableLazyValue<String> rec = m.createNullableLazyValue(new Computable<String>() {
|
NullableLazyValue<String> rec = m.createNullableLazyValue(new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
return rec.invoke();
|
return rec.invoke();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -205,9 +202,9 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
public void testRecursionTolerance() throws Exception {
|
public void testRecursionTolerance() throws Exception {
|
||||||
class C {
|
class C {
|
||||||
NotNullLazyValue<String> rec = m.createRecursionTolerantLazyValue(new Computable<String>() {
|
NotNullLazyValue<String> rec = m.createRecursionTolerantLazyValue(new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
assertEquals("rec", rec.invoke());
|
assertEquals("rec", rec.invoke());
|
||||||
return "tolerant!";
|
return "tolerant!";
|
||||||
}
|
}
|
||||||
@@ -219,9 +216,9 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
public void testNullableRecursionTolerance() throws Exception {
|
public void testNullableRecursionTolerance() throws Exception {
|
||||||
class C {
|
class C {
|
||||||
NullableLazyValue<String> rec = m.createRecursionTolerantNullableLazyValue(new Computable<String>() {
|
NullableLazyValue<String> rec = m.createRecursionTolerantNullableLazyValue(new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
assertEquals(null, rec.invoke());
|
assertEquals(null, rec.invoke());
|
||||||
return "tolerant!";
|
return "tolerant!";
|
||||||
}
|
}
|
||||||
@@ -235,14 +232,19 @@ public class StorageManagerTest extends TestCase {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
class C {
|
class C {
|
||||||
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
||||||
new Computable<String>() {
|
new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
return rec.invoke();
|
return rec.invoke();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
Consumer.EMPTY_CONSUMER
|
new Function1<String, Void>() {
|
||||||
|
@Override
|
||||||
|
public Void invoke(String s) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,23 +261,24 @@ public class StorageManagerTest extends TestCase {
|
|||||||
final CounterImpl counter = new CounterImpl();
|
final CounterImpl counter = new CounterImpl();
|
||||||
class C {
|
class C {
|
||||||
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
||||||
new Computable<String>() {
|
new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
return rec.invoke();
|
return rec.invoke();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function<Boolean, String>() {
|
new Function1<Boolean, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String fun(Boolean aBoolean) {
|
public String invoke(Boolean aBoolean) {
|
||||||
return "tolerant";
|
return "tolerant";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Consumer<String>() {
|
new Function1<String, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void consume(String s) {
|
public Void invoke(String s) {
|
||||||
counter.inc();
|
counter.inc();
|
||||||
assertEquals("tolerant", s);
|
assertEquals("tolerant", s);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -290,20 +293,21 @@ public class StorageManagerTest extends TestCase {
|
|||||||
public void testPostComputeNoRecursion() throws Exception {
|
public void testPostComputeNoRecursion() throws Exception {
|
||||||
final CounterImpl counter = new CounterImpl();
|
final CounterImpl counter = new CounterImpl();
|
||||||
NotNullLazyValue<Collection<String>> v = m.createLazyValueWithPostCompute(
|
NotNullLazyValue<Collection<String>> v = m.createLazyValueWithPostCompute(
|
||||||
new Computable<Collection<String>>() {
|
new Function0<Collection<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> compute() {
|
public Collection<String> invoke() {
|
||||||
List<String> strings = new ArrayList<String>();
|
List<String> strings = new ArrayList<String>();
|
||||||
strings.add("first");
|
strings.add("first");
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
new Consumer<Collection<String>>() {
|
new Function1<Collection<String>, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void consume(Collection<String> strings) {
|
public Void invoke(Collection<String> strings) {
|
||||||
counter.inc();
|
counter.inc();
|
||||||
strings.add("postComputed");
|
strings.add("postComputed");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -316,19 +320,20 @@ public class StorageManagerTest extends TestCase {
|
|||||||
public void testNullablePostComputeNoRecursion() throws Exception {
|
public void testNullablePostComputeNoRecursion() throws Exception {
|
||||||
final CounterImpl counter = new CounterImpl();
|
final CounterImpl counter = new CounterImpl();
|
||||||
NullableLazyValue<Collection<String>> v = m.createNullableLazyValueWithPostCompute(
|
NullableLazyValue<Collection<String>> v = m.createNullableLazyValueWithPostCompute(
|
||||||
new Computable<Collection<String>>() {
|
new Function0<Collection<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> compute() {
|
public Collection<String> invoke() {
|
||||||
ArrayList<String> strings = new ArrayList<String>();
|
ArrayList<String> strings = new ArrayList<String>();
|
||||||
strings.add("first");
|
strings.add("first");
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Consumer<Collection<String>>() {
|
new Function1<Collection<String>, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void consume(Collection<String> strings) {
|
public Void invoke(Collection<String> strings) {
|
||||||
counter.inc();
|
counter.inc();
|
||||||
strings.add("postComputed");
|
strings.add("postComputed");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -342,25 +347,26 @@ public class StorageManagerTest extends TestCase {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
class C {
|
class C {
|
||||||
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
||||||
new Computable<String>() {
|
new Function0<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
return rec.invoke();
|
return rec.invoke();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Function<Boolean, String>() {
|
new Function1<Boolean, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String fun(Boolean firstTime) {
|
public String invoke(Boolean firstTime) {
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
throw new ReenteringLazyValueComputationException();
|
throw new ReenteringLazyValueComputationException();
|
||||||
}
|
}
|
||||||
return "second";
|
return "second";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Consumer<String>() {
|
new Function1<String, Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void consume(String s) {
|
public Void invoke(String s) {
|
||||||
fail("Recursion-tolerating value should not be post computed");
|
fail("Recursion-tolerating value should not be post computed");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -407,9 +413,9 @@ public class StorageManagerTest extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CounterValueNull extends CounterImpl implements Computable<String>, Counter {
|
private static class CounterValueNull extends CounterImpl implements Function0<String>, Counter {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
inc();
|
inc();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -417,7 +423,7 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
private static class CounterValue extends CounterValueNull {
|
private static class CounterValue extends CounterValueNull {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
inc();
|
inc();
|
||||||
return "ok" + getCount();
|
return "ok" + getCount();
|
||||||
}
|
}
|
||||||
@@ -425,15 +431,15 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
private static class ExceptionCounterValue extends CounterValueNull {
|
private static class ExceptionCounterValue extends CounterValueNull {
|
||||||
@Override
|
@Override
|
||||||
public String compute() {
|
public String invoke() {
|
||||||
inc();
|
inc();
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CounterFunctionToNull extends CounterImpl implements Function<String, String>, Counter {
|
private static class CounterFunctionToNull extends CounterImpl implements Function1<String, String>, Counter {
|
||||||
@Override
|
@Override
|
||||||
public String fun(String s) {
|
public String invoke(String s) {
|
||||||
inc();
|
inc();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -441,7 +447,7 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
private static class CounterFunction extends CounterFunctionToNull {
|
private static class CounterFunction extends CounterFunctionToNull {
|
||||||
@Override
|
@Override
|
||||||
public String fun(String s) {
|
public String invoke(String s) {
|
||||||
inc();
|
inc();
|
||||||
return s + getCount();
|
return s + getCount();
|
||||||
}
|
}
|
||||||
@@ -449,7 +455,7 @@ public class StorageManagerTest extends TestCase {
|
|||||||
|
|
||||||
private static class ExceptionCounterFunction extends CounterFunctionToNull {
|
private static class ExceptionCounterFunction extends CounterFunctionToNull {
|
||||||
@Override
|
@Override
|
||||||
public String fun(String s) {
|
public String invoke(String s) {
|
||||||
inc();
|
inc();
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.kotlin;
|
package org.jetbrains.jet.lang.resolve.kotlin;
|
||||||
|
|
||||||
import com.intellij.util.Function;
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.JavaProtoBuf;
|
import org.jetbrains.jet.descriptors.serialization.JavaProtoBuf;
|
||||||
@@ -62,10 +62,10 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer
|
|||||||
|
|
||||||
private final MemoizedFunctionToNotNull<KotlinJvmBinaryClass, Map<MemberSignature, List<AnnotationDescriptor>>> memberAnnotations =
|
private final MemoizedFunctionToNotNull<KotlinJvmBinaryClass, Map<MemberSignature, List<AnnotationDescriptor>>> memberAnnotations =
|
||||||
storageManager.createMemoizedFunction(
|
storageManager.createMemoizedFunction(
|
||||||
new Function<KotlinJvmBinaryClass, Map<MemberSignature, List<AnnotationDescriptor>>>() {
|
new Function1<KotlinJvmBinaryClass, Map<MemberSignature, List<AnnotationDescriptor>>>() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Map<MemberSignature, List<AnnotationDescriptor>> fun(@NotNull KotlinJvmBinaryClass kotlinClass) {
|
public Map<MemberSignature, List<AnnotationDescriptor>> invoke(@NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||||
try {
|
try {
|
||||||
return loadMemberAnnotationsFromClass(kotlinClass);
|
return loadMemberAnnotationsFromClass(kotlinClass);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.descriptors.impl;
|
package org.jetbrains.jet.lang.descriptors.impl;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
@@ -65,27 +65,27 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.reified = isReified;
|
this.reified = isReified;
|
||||||
|
|
||||||
this.typeConstructor = storageManager.createLazyValue(new Computable<TypeConstructor>() {
|
this.typeConstructor = storageManager.createLazyValue(new Function0<TypeConstructor>() {
|
||||||
@Override
|
@Override
|
||||||
public TypeConstructor compute() {
|
public TypeConstructor invoke() {
|
||||||
return createTypeConstructor();
|
return createTypeConstructor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.defaultType = storageManager.createLazyValue(new Computable<JetType>() {
|
this.defaultType = storageManager.createLazyValue(new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return createDefaultType(storageManager);
|
return createDefaultType(storageManager);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.upperBounds = storageManager.createLazyValue(new Computable<Set<JetType>>() {
|
this.upperBounds = storageManager.createLazyValue(new Function0<Set<JetType>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<JetType> compute() {
|
public Set<JetType> invoke() {
|
||||||
return resolveUpperBounds();
|
return resolveUpperBounds();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.upperBoundsAsType = storageManager.createLazyValue(new Computable<JetType>() {
|
this.upperBoundsAsType = storageManager.createLazyValue(new Function0<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
public JetType compute() {
|
public JetType invoke() {
|
||||||
return computeUpperBoundsAsType();
|
return computeUpperBoundsAsType();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -198,9 +198,9 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet
|
|||||||
@NotNull
|
@NotNull
|
||||||
private JetType createDefaultType(@NotNull StorageManager storageManager) {
|
private JetType createDefaultType(@NotNull StorageManager storageManager) {
|
||||||
return new JetTypeImpl(getTypeConstructor(), new LazyScopeAdapter(storageManager.createLazyValue(
|
return new JetTypeImpl(getTypeConstructor(), new LazyScopeAdapter(storageManager.createLazyValue(
|
||||||
new Computable<JetScope>() {
|
new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return getUpperBoundsAsType().getMemberScope();
|
return getUpperBoundsAsType().getMemberScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.jet.lang.descriptors.impl;
|
package org.jetbrains.jet.lang.descriptors.impl;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor;
|
||||||
@@ -224,9 +224,9 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
|||||||
getTypeConstructor(),
|
getTypeConstructor(),
|
||||||
TypeUtils.hasNullableLowerBound(this),
|
TypeUtils.hasNullableLowerBound(this),
|
||||||
Collections.<TypeProjection>emptyList(),
|
Collections.<TypeProjection>emptyList(),
|
||||||
new LazyScopeAdapter(NO_LOCKS.createLazyValue(new Computable<JetScope>() {
|
new LazyScopeAdapter(NO_LOCKS.createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope compute() {
|
public JetScope invoke() {
|
||||||
return getUpperBoundsAsType().getMemberScope();
|
return getUpperBoundsAsType().getMemberScope();
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
package org.jetbrains.jet.lang.types.lang;
|
package org.jetbrains.jet.lang.types.lang;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.*;
|
import org.jetbrains.jet.descriptors.serialization.*;
|
||||||
@@ -8,11 +8,11 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPacka
|
|||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.AbstractNamespaceDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.AbstractNamespaceDescriptorImpl;
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||||
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -81,10 +81,10 @@ class BuiltinsNamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl {
|
|||||||
public BuiltInsDescriptorFinder(@NotNull StorageManager storageManager) {
|
public BuiltInsDescriptorFinder(@NotNull StorageManager storageManager) {
|
||||||
super(storageManager, UNSUPPORTED);
|
super(storageManager, UNSUPPORTED);
|
||||||
|
|
||||||
classNames = storageManager.createLazyValue(new Computable<Collection<Name>>() {
|
classNames = storageManager.createLazyValue(new Function0<Collection<Name>>() {
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<Name> compute() {
|
public Collection<Name> invoke() {
|
||||||
InputStream in = getStream(BuiltInsSerializationUtil.getClassNamesFilePath(BuiltinsNamespaceDescriptorImpl.this));
|
InputStream in = getStream(BuiltInsSerializationUtil.getClassNamesFilePath(BuiltinsNamespaceDescriptorImpl.this));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.storage;
|
package org.jetbrains.jet.storage;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.util.Consumer;
|
|
||||||
import com.intellij.util.Function;
|
|
||||||
import com.intellij.util.containers.ConcurrentWeakValueHashMap;
|
import com.intellij.util.containers.ConcurrentWeakValueHashMap;
|
||||||
|
import jet.Function0;
|
||||||
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||||
@@ -52,7 +51,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(
|
public <K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(
|
||||||
@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind
|
@NotNull Function1<K, V> compute, @NotNull ReferenceKind valuesReferenceKind
|
||||||
) {
|
) {
|
||||||
ConcurrentMap<K, Object> map = createConcurrentMap(valuesReferenceKind);
|
ConcurrentMap<K, Object> map = createConcurrentMap(valuesReferenceKind);
|
||||||
return new MapBasedMemoizedFunctionToNotNull<K, V>(lock, map, compute);
|
return new MapBasedMemoizedFunctionToNotNull<K, V>(lock, map, compute);
|
||||||
@@ -61,7 +60,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <K, V> MemoizedFunctionToNullable<K, V> createMemoizedFunctionWithNullableValues(
|
public <K, V> MemoizedFunctionToNullable<K, V> createMemoizedFunctionWithNullableValues(
|
||||||
@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind
|
@NotNull Function1<K, V> compute, @NotNull ReferenceKind valuesReferenceKind
|
||||||
) {
|
) {
|
||||||
ConcurrentMap<K, Object> map = createConcurrentMap(valuesReferenceKind);
|
ConcurrentMap<K, Object> map = createConcurrentMap(valuesReferenceKind);
|
||||||
return new MapBasedMemoizedFunction<K, V>(lock, map, compute);
|
return new MapBasedMemoizedFunction<K, V>(lock, map, compute);
|
||||||
@@ -73,14 +72,14 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NotNullLazyValue<T> createLazyValue(@NotNull Computable<T> computable) {
|
public <T> NotNullLazyValue<T> createLazyValue(@NotNull Function0<T> computable) {
|
||||||
return new LockBasedNotNullLazyValue<T>(lock, computable);
|
return new LockBasedNotNullLazyValue<T>(lock, computable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NotNullLazyValue<T> createRecursionTolerantLazyValue(
|
public <T> NotNullLazyValue<T> createRecursionTolerantLazyValue(
|
||||||
@NotNull Computable<T> computable, @NotNull final T onRecursiveCall
|
@NotNull Function0<T> computable, @NotNull final T onRecursiveCall
|
||||||
) {
|
) {
|
||||||
return new LockBasedNotNullLazyValue<T>(lock, computable) {
|
return new LockBasedNotNullLazyValue<T>(lock, computable) {
|
||||||
@Override
|
@Override
|
||||||
@@ -93,9 +92,9 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
public <T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
||||||
@NotNull Computable<T> computable,
|
@NotNull Function0<T> computable,
|
||||||
final Function<Boolean, T> onRecursiveCall,
|
final Function1<Boolean, T> onRecursiveCall,
|
||||||
@NotNull final Consumer<T> postCompute
|
@NotNull final Function1<T, Void> postCompute
|
||||||
) {
|
) {
|
||||||
return new LockBasedNotNullLazyValue<T>(lock, computable) {
|
return new LockBasedNotNullLazyValue<T>(lock, computable) {
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -104,25 +103,25 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
if (onRecursiveCall == null) {
|
if (onRecursiveCall == null) {
|
||||||
return super.recursionDetected(firstTime);
|
return super.recursionDetected(firstTime);
|
||||||
}
|
}
|
||||||
return onRecursiveCall.fun(firstTime);
|
return onRecursiveCall.invoke(firstTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postCompute(@NotNull T value) {
|
protected void postCompute(@NotNull T value) {
|
||||||
postCompute.consume(value);
|
postCompute.invoke(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NullableLazyValue<T> createNullableLazyValue(@NotNull Computable<T> computable) {
|
public <T> NullableLazyValue<T> createNullableLazyValue(@NotNull Function0<T> computable) {
|
||||||
return new LockBasedLazyValue<T>(lock, computable);
|
return new LockBasedLazyValue<T>(lock, computable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NullableLazyValue<T> createRecursionTolerantNullableLazyValue(@NotNull Computable<T> computable, final T onRecursiveCall) {
|
public <T> NullableLazyValue<T> createRecursionTolerantNullableLazyValue(@NotNull Function0<T> computable, final T onRecursiveCall) {
|
||||||
return new LockBasedLazyValue<T>(lock, computable) {
|
return new LockBasedLazyValue<T>(lock, computable) {
|
||||||
@Override
|
@Override
|
||||||
protected T recursionDetected(boolean firstTime) {
|
protected T recursionDetected(boolean firstTime) {
|
||||||
@@ -134,21 +133,21 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(
|
public <T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(
|
||||||
@NotNull Computable<T> computable, @NotNull final Consumer<T> postCompute
|
@NotNull Function0<T> computable, @NotNull final Function1<T, Void> postCompute
|
||||||
) {
|
) {
|
||||||
return new LockBasedLazyValue<T>(lock, computable) {
|
return new LockBasedLazyValue<T>(lock, computable) {
|
||||||
@Override
|
@Override
|
||||||
protected void postCompute(@Nullable T value) {
|
protected void postCompute(@Nullable T value) {
|
||||||
postCompute.consume(value);
|
postCompute.invoke(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T compute(@NotNull Computable<T> computable) {
|
public <T> T compute(@NotNull Function0<T> computable) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
return computable.compute();
|
return computable.invoke();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -164,12 +163,12 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Lock lock;
|
private final Lock lock;
|
||||||
private final Computable<T> computable;
|
private final Function0<T> computable;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private volatile Object value = NotValue.NOT_COMPUTED;
|
private volatile Object value = NotValue.NOT_COMPUTED;
|
||||||
|
|
||||||
public LockBasedLazyValue(@NotNull Lock lock, @NotNull Computable<T> computable) {
|
public LockBasedLazyValue(@NotNull Lock lock, @NotNull Function0<T> computable) {
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
this.computable = computable;
|
this.computable = computable;
|
||||||
}
|
}
|
||||||
@@ -200,7 +199,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
|
|
||||||
value = NotValue.COMPUTING;
|
value = NotValue.COMPUTING;
|
||||||
try {
|
try {
|
||||||
T typedValue = computable.compute();
|
T typedValue = computable.invoke();
|
||||||
value = typedValue;
|
value = typedValue;
|
||||||
postCompute(typedValue);
|
postCompute(typedValue);
|
||||||
return typedValue;
|
return typedValue;
|
||||||
@@ -234,7 +233,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
|
|
||||||
private static class LockBasedNotNullLazyValue<T> extends LockBasedLazyValue<T> implements NotNullLazyValue<T> {
|
private static class LockBasedNotNullLazyValue<T> extends LockBasedLazyValue<T> implements NotNullLazyValue<T> {
|
||||||
|
|
||||||
public LockBasedNotNullLazyValue(@NotNull Lock lock, @NotNull Computable<T> computable) {
|
public LockBasedNotNullLazyValue(@NotNull Lock lock, @NotNull Function0<T> computable) {
|
||||||
super(lock, computable);
|
super(lock, computable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,9 +249,9 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
private static class MapBasedMemoizedFunction<K, V> implements MemoizedFunctionToNullable<K, V> {
|
private static class MapBasedMemoizedFunction<K, V> implements MemoizedFunctionToNullable<K, V> {
|
||||||
private final Lock lock;
|
private final Lock lock;
|
||||||
private final ConcurrentMap<K, Object> cache;
|
private final ConcurrentMap<K, Object> cache;
|
||||||
private final Function<K, V> compute;
|
private final Function1<K, V> compute;
|
||||||
|
|
||||||
public MapBasedMemoizedFunction(@NotNull Lock lock, @NotNull ConcurrentMap<K, Object> map, @NotNull Function<K, V> compute) {
|
public MapBasedMemoizedFunction(@NotNull Lock lock, @NotNull ConcurrentMap<K, Object> map, @NotNull Function1<K, V> compute) {
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
this.cache = map;
|
this.cache = map;
|
||||||
this.compute = compute;
|
this.compute = compute;
|
||||||
@@ -270,7 +269,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
if (value != null) return WrappedValues.unescapeExceptionOrNull(value);
|
if (value != null) return WrappedValues.unescapeExceptionOrNull(value);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
V typedValue = compute.fun(input);
|
V typedValue = compute.invoke(input);
|
||||||
Object oldValue = cache.put(input, WrappedValues.escapeNull(typedValue));
|
Object oldValue = cache.put(input, WrappedValues.escapeNull(typedValue));
|
||||||
assert oldValue == null : "Race condition detected";
|
assert oldValue == null : "Race condition detected";
|
||||||
|
|
||||||
@@ -294,7 +293,7 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
public MapBasedMemoizedFunctionToNotNull(
|
public MapBasedMemoizedFunctionToNotNull(
|
||||||
@NotNull Lock lock,
|
@NotNull Lock lock,
|
||||||
@NotNull ConcurrentMap<K, Object> map,
|
@NotNull ConcurrentMap<K, Object> map,
|
||||||
@NotNull Function<K, V> compute
|
@NotNull Function1<K, V> compute
|
||||||
) {
|
) {
|
||||||
super(lock, map, compute);
|
super(lock, map, compute);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.storage;
|
package org.jetbrains.jet.storage;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import com.intellij.util.Consumer;
|
import jet.Function1;
|
||||||
import com.intellij.util.Function;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -29,20 +28,20 @@ public interface StorageManager {
|
|||||||
* @param valuesReferenceKind how to store the memoized values
|
* @param valuesReferenceKind how to store the memoized values
|
||||||
*
|
*
|
||||||
* NOTE: if compute() has side-effects the WEAK reference kind is dangerous: the side-effects will be repeated if
|
* 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
|
@NotNull
|
||||||
<K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind);
|
<K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(@NotNull Function1<K, V> compute, @NotNull ReferenceKind valuesReferenceKind);
|
||||||
@NotNull
|
@NotNull
|
||||||
<K, V> MemoizedFunctionToNullable<K, V> createMemoizedFunctionWithNullableValues(@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind);
|
<K, V> MemoizedFunctionToNullable<K, V> createMemoizedFunctionWithNullableValues(@NotNull Function1<K, V> compute, @NotNull ReferenceKind valuesReferenceKind);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NotNullLazyValue<T> createLazyValue(@NotNull Computable<T> computable);
|
<T> NotNullLazyValue<T> createLazyValue(@NotNull Function0<T> computable);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NotNullLazyValue<T> createRecursionTolerantLazyValue(@NotNull Computable<T> computable, @NotNull T onRecursiveCall);
|
<T> NotNullLazyValue<T> createRecursionTolerantLazyValue(@NotNull Function0<T> computable, @NotNull T onRecursiveCall);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param computable
|
||||||
* @param onRecursiveCall is called if the computation calls itself recursively.
|
* @param onRecursiveCall is called if the computation calls itself recursively.
|
||||||
* The parameter to it is {@code true} for the first call, {@code false} otherwise.
|
* The parameter to it is {@code true} for the first call, {@code false} otherwise.
|
||||||
* If {@code onRecursiveCall} is {@code null}, an exception will be thrown on a recursive call,
|
* If {@code onRecursiveCall} is {@code null}, an exception will be thrown on a recursive call,
|
||||||
@@ -51,25 +50,25 @@ public interface StorageManager {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
<T> NotNullLazyValue<T> createLazyValueWithPostCompute(
|
||||||
@NotNull Computable<T> computable,
|
@NotNull Function0<T> computable,
|
||||||
@Nullable Function<Boolean, T> onRecursiveCall,
|
@Nullable Function1<Boolean, T> onRecursiveCall,
|
||||||
@NotNull Consumer<T> postCompute
|
@NotNull Function1<T, Void> postCompute
|
||||||
);
|
);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NullableLazyValue<T> createNullableLazyValue(@NotNull Computable<T> computable);
|
<T> NullableLazyValue<T> createNullableLazyValue(@NotNull Function0<T> computable);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NullableLazyValue<T> createRecursionTolerantNullableLazyValue(@NotNull Computable<T> computable, @Nullable T onRecursiveCall);
|
<T> NullableLazyValue<T> createRecursionTolerantNullableLazyValue(@NotNull Function0<T> computable, @Nullable T onRecursiveCall);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code postCompute} is called after the value is computed, but before any other thread sees it (the current thread may
|
* {@code postCompute} is called after the value is computed, but before any other thread sees it (the current thread may
|
||||||
* see it in between)
|
* see it in between)
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
<T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(@NotNull Computable<T> computable, @NotNull Consumer<T> postCompute);
|
<T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(@NotNull Function0<T> computable, @NotNull Function1<T, Void> postCompute);
|
||||||
|
|
||||||
<T> T compute(@NotNull Computable<T> computable);
|
<T> T compute(@NotNull Function0<T> computable);
|
||||||
|
|
||||||
enum ReferenceKind {
|
enum ReferenceKind {
|
||||||
STRONG,
|
STRONG,
|
||||||
|
|||||||
@@ -16,29 +16,36 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.storage;
|
package org.jetbrains.jet.storage;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import jet.Function0;
|
||||||
import com.intellij.util.Consumer;
|
import jet.Function1;
|
||||||
import com.intellij.util.Function;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import static org.jetbrains.jet.storage.LockBasedStorageManager.NO_LOCKS;
|
import static org.jetbrains.jet.storage.LockBasedStorageManager.NO_LOCKS;
|
||||||
|
|
||||||
public class StorageUtil {
|
public class StorageUtil {
|
||||||
|
private static final Function1 EMPTY_CONSUMER = new Function1<Object, Void>() {
|
||||||
|
@Override
|
||||||
|
public Void invoke(Object t) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public static <T> NotNullLazyValue<T> createRecursionIntolerantLazyValueWithDefault(
|
public static <T> NotNullLazyValue<T> createRecursionIntolerantLazyValueWithDefault(
|
||||||
@NotNull final T defaultValue,
|
@NotNull final T defaultValue,
|
||||||
@NotNull Computable<T> compute
|
@NotNull Function0<T> compute
|
||||||
) {
|
) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return NO_LOCKS.createLazyValueWithPostCompute(
|
return NO_LOCKS.createLazyValueWithPostCompute(
|
||||||
compute,
|
compute,
|
||||||
new Function<Boolean, T>() {
|
new Function1<Boolean, T>() {
|
||||||
@Override
|
@Override
|
||||||
public T fun(Boolean firstTime) {
|
public T invoke(Boolean firstTime) {
|
||||||
if (firstTime) throw new ReenteringLazyValueComputationException();
|
if (firstTime) throw new ReenteringLazyValueComputationException();
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Consumer.EMPTY_CONSUMER
|
EMPTY_CONSUMER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiFile;
|
import com.intellij.psi.PsiFile;
|
||||||
import com.intellij.psi.util.*;
|
import com.intellij.psi.util.*;
|
||||||
|
import jet.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.di.InjectorForBodyResolve;
|
import org.jetbrains.jet.di.InjectorForBodyResolve;
|
||||||
@@ -67,9 +68,9 @@ public class ResolveElementCache {
|
|||||||
public Result<MemoizedFunctionToNotNull<JetElement, BindingContext>> compute() {
|
public Result<MemoizedFunctionToNotNull<JetElement, BindingContext>> compute() {
|
||||||
StorageManager manager = ResolveElementCache.this.resolveSession.getStorageManager();
|
StorageManager manager = ResolveElementCache.this.resolveSession.getStorageManager();
|
||||||
MemoizedFunctionToNotNull<JetElement, BindingContext> elementsCacheFunction =
|
MemoizedFunctionToNotNull<JetElement, BindingContext> elementsCacheFunction =
|
||||||
manager.createMemoizedFunction(new com.intellij.util.Function<JetElement, BindingContext>() {
|
manager.createMemoizedFunction(new Function1<JetElement, BindingContext>() {
|
||||||
@Override
|
@Override
|
||||||
public BindingContext fun(JetElement jetElement) {
|
public BindingContext invoke(JetElement jetElement) {
|
||||||
return elementAdditionalResolve(jetElement);
|
return elementAdditionalResolve(jetElement);
|
||||||
}
|
}
|
||||||
}, StorageManager.ReferenceKind.WEAK);
|
}, StorageManager.ReferenceKind.WEAK);
|
||||||
|
|||||||
Reference in New Issue
Block a user