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;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
|
||||
@@ -38,9 +38,9 @@ public abstract class AbstractDescriptorFinder implements DescriptorFinder {
|
||||
) {
|
||||
this.annotationDeserializer = annotationDeserializer;
|
||||
|
||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function<ClassId, ClassDescriptor>() {
|
||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function1<ClassId, ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor fun(ClassId classId) {
|
||||
public ClassDescriptor invoke(ClassId classId) {
|
||||
ClassData classData = getClassData(classId);
|
||||
if (classData == null) {
|
||||
return null;
|
||||
|
||||
+11
-11
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.jetbrains.jet.descriptors.serialization;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Function;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.TypeParameterDescriptor;
|
||||
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.types.*;
|
||||
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.Collections;
|
||||
@@ -94,9 +94,9 @@ public class TypeDeserializer {
|
||||
typeParameterDescriptors.put(typeParameterDescriptor.getProtoId(), typeParameterDescriptor);
|
||||
}
|
||||
|
||||
this.classDescriptors = storageManager.createMemoizedFunctionWithNullableValues(new Function<Integer, ClassDescriptor>() {
|
||||
this.classDescriptors = storageManager.createMemoizedFunctionWithNullableValues(new Function1<Integer, ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor fun(Integer fqNameIndex) {
|
||||
public ClassDescriptor invoke(Integer fqNameIndex) {
|
||||
return computeClassDescriptor(fqNameIndex);
|
||||
}
|
||||
}, STRONG);
|
||||
@@ -210,15 +210,15 @@ public class TypeDeserializer {
|
||||
this.typeProto = proto;
|
||||
this.arguments = typeArguments(proto.getArgumentList());
|
||||
|
||||
this.constructor = storageManager.createLazyValue(new Computable<TypeConstructor>() {
|
||||
this.constructor = storageManager.createLazyValue(new Function0<TypeConstructor>() {
|
||||
@Override
|
||||
public TypeConstructor compute() {
|
||||
public TypeConstructor invoke() {
|
||||
return typeConstructor(typeProto);
|
||||
}
|
||||
});
|
||||
this.memberScope = storageManager.createLazyValue(new Computable<JetScope>() {
|
||||
this.memberScope = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
return computeMemberScope();
|
||||
}
|
||||
});
|
||||
|
||||
+16
-16
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Function;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.resolve.DescriptorFactory;
|
||||
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.scopes.InnerClassesScopeWrapper;
|
||||
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.TypeConstructor;
|
||||
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.*;
|
||||
|
||||
@@ -96,9 +96,9 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
||||
this.deserializer = outerDeserializer.createChildDeserializer(this, classProto.getTypeParameterList(), typeParameters);
|
||||
this.typeDeserializer = deserializer.getTypeDeserializer();
|
||||
|
||||
this.containingDeclaration = storageManager.createLazyValue(new Computable<DeclarationDescriptor>() {
|
||||
this.containingDeclaration = storageManager.createLazyValue(new Function0<DeclarationDescriptor>() {
|
||||
@Override
|
||||
public DeclarationDescriptor compute() {
|
||||
public DeclarationDescriptor invoke() {
|
||||
return computeContainingDeclaration();
|
||||
}
|
||||
});
|
||||
@@ -115,23 +115,23 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
||||
this.isInner = Flags.INNER.get(flags);
|
||||
|
||||
this.annotationDeserializer = annotationResolver;
|
||||
this.annotations = storageManager.createLazyValue(new Computable<List<AnnotationDescriptor>>() {
|
||||
this.annotations = storageManager.createLazyValue(new Function0<List<AnnotationDescriptor>>() {
|
||||
@Override
|
||||
public List<AnnotationDescriptor> compute() {
|
||||
public List<AnnotationDescriptor> invoke() {
|
||||
return computeAnnotations();
|
||||
}
|
||||
});
|
||||
|
||||
this.primaryConstructor = storageManager.createNullableLazyValue(new Computable<ConstructorDescriptor>() {
|
||||
this.primaryConstructor = storageManager.createNullableLazyValue(new Function0<ConstructorDescriptor>() {
|
||||
@Override
|
||||
public ConstructorDescriptor compute() {
|
||||
public ConstructorDescriptor invoke() {
|
||||
return computePrimaryConstructor();
|
||||
}
|
||||
});
|
||||
|
||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Computable<ClassDescriptor>() {
|
||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor compute() {
|
||||
public ClassDescriptor invoke() {
|
||||
return computeClassObjectDescriptor();
|
||||
}
|
||||
});
|
||||
@@ -490,9 +490,9 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
||||
|
||||
public NestedClassDescriptors(@NotNull StorageManager storageManager, @NotNull Set<Name> declaredNames) {
|
||||
this.declaredNames = declaredNames;
|
||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function<Name, ClassDescriptor>() {
|
||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues(new Function1<Name, ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor fun(Name name) {
|
||||
public ClassDescriptor invoke(Name name) {
|
||||
return NestedClassDescriptors.this.declaredNames.contains(name) ?
|
||||
descriptorFinder.findClass(classId.createNestedClassId(name)) :
|
||||
null;
|
||||
|
||||
+13
-13
@@ -16,20 +16,20 @@
|
||||
|
||||
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Function;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.descriptors.serialization.DescriptorDeserializer;
|
||||
import org.jetbrains.jet.descriptors.serialization.Flags;
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
||||
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.Name;
|
||||
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.*;
|
||||
|
||||
@@ -73,27 +73,27 @@ public abstract class DeserializedMemberScope implements JetScope {
|
||||
this.deserializer = deserializer;
|
||||
|
||||
this.membersProtos = groupByName(membersList);
|
||||
this.functions = storageManager.createMemoizedFunction(new Function<Name, Collection<FunctionDescriptor>>() {
|
||||
this.functions = storageManager.createMemoizedFunction(new Function1<Name, Collection<FunctionDescriptor>>() {
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> fun(Name name) {
|
||||
public Collection<FunctionDescriptor> invoke(Name name) {
|
||||
return computeFunctions(name);
|
||||
}
|
||||
}, STRONG);
|
||||
this.properties = storageManager.createMemoizedFunction(new Function<Name, Collection<VariableDescriptor>>() {
|
||||
this.properties = storageManager.createMemoizedFunction(new Function1<Name, Collection<VariableDescriptor>>() {
|
||||
@Override
|
||||
public Collection<VariableDescriptor> fun(Name name) {
|
||||
public Collection<VariableDescriptor> invoke(Name name) {
|
||||
return computeProperties(name);
|
||||
}
|
||||
}, STRONG);
|
||||
this.allDescriptors = storageManager.createLazyValue(new Computable<Collection<DeclarationDescriptor>>() {
|
||||
this.allDescriptors = storageManager.createLazyValue(new Function0<Collection<DeclarationDescriptor>>() {
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> compute() {
|
||||
public Collection<DeclarationDescriptor> invoke() {
|
||||
return computeAllDescriptors();
|
||||
}
|
||||
});
|
||||
this.objectDescriptors = storageManager.createLazyValue(new Computable<Collection<ClassDescriptor>>() {
|
||||
this.objectDescriptors = storageManager.createLazyValue(new Function0<Collection<ClassDescriptor>>() {
|
||||
@Override
|
||||
public Collection<ClassDescriptor> compute() {
|
||||
public Collection<ClassDescriptor> invoke() {
|
||||
return computeAllObjectDescriptors();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -316,9 +317,9 @@ public class DescriptorResolver {
|
||||
DeferredType.create(trace,
|
||||
createRecursionIntolerantLazyValueWithDefault(
|
||||
ErrorUtils.createErrorType("Recursive dependency"),
|
||||
new Computable<JetType>() {
|
||||
new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
JetType type = expressionTypingServices
|
||||
.getBodyExpressionType(trace, scope, dataFlowInfo, function,
|
||||
functionDescriptor);
|
||||
@@ -1037,9 +1038,9 @@ public class DescriptorResolver {
|
||||
trace,
|
||||
createRecursionIntolerantLazyValueWithDefault(
|
||||
ErrorUtils.createErrorType("Recursive dependency"),
|
||||
new Computable<JetType>() {
|
||||
new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
return resolveDelegatedPropertyType((PropertyDescriptor) variableDescriptor, scope,
|
||||
propertyDelegateExpression, dataFlowInfo, trace);
|
||||
}
|
||||
@@ -1056,9 +1057,9 @@ public class DescriptorResolver {
|
||||
return DeferredType.create(trace,
|
||||
createRecursionIntolerantLazyValueWithDefault(
|
||||
ErrorUtils.createErrorType("Recursive dependency"),
|
||||
new Computable<JetType>() {
|
||||
new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
JetType type =
|
||||
resolveInitializerType(scope, initializer, dataFlowInfo, trace);
|
||||
|
||||
@@ -1384,9 +1385,9 @@ public class DescriptorResolver {
|
||||
final ClassDescriptor enumClassDescriptor = (ClassDescriptor) classObject.getContainingDeclaration();
|
||||
assert DescriptorUtils.isEnumClass(enumClassDescriptor) : "values should be created in enum class: " + enumClassDescriptor;
|
||||
return DescriptorFactory
|
||||
.createEnumClassObjectValuesMethod(classObject, DeferredType.create(trace, new Computable<JetType>() {
|
||||
.createEnumClassObjectValuesMethod(classObject, DeferredType.create(trace, new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
return KotlinBuiltIns.getInstance().getArrayType(enumClassDescriptor.getDefaultType());
|
||||
}
|
||||
}));
|
||||
@@ -1401,9 +1402,9 @@ public class DescriptorResolver {
|
||||
final ClassDescriptor enumClassDescriptor = (ClassDescriptor) classObject.getContainingDeclaration();
|
||||
assert DescriptorUtils.isEnumClass(enumClassDescriptor) : "valueOf should be created in enum class: " + enumClassDescriptor;
|
||||
return DescriptorFactory
|
||||
.createEnumClassObjectValueOfMethod(classObject, DeferredType.create(trace, new Computable<JetType>() {
|
||||
.createEnumClassObjectValueOfMethod(classObject, DeferredType.create(trace, new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
return enumClassDescriptor.getDefaultType();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -240,9 +240,9 @@ public class TypeResolver {
|
||||
return typeParameterDescriptor.getUpperBoundsAsType().getMemberScope();
|
||||
}
|
||||
else {
|
||||
return new LazyScopeAdapter(NO_LOCKS.createLazyValue(new Computable<JetScope>() {
|
||||
return new LazyScopeAdapter(NO_LOCKS.createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
return typeParameterDescriptor.getUpperBoundsAsType().getMemberScope();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
package org.jetbrains.jet.lang.resolve.lazy;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
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.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -35,9 +35,9 @@ class ImportsProvider {
|
||||
|
||||
public ImportsProvider(StorageManager storageManager, final List<JetImportDirective> importDirectives) {
|
||||
this.importDirectives = importDirectives;
|
||||
this.importsCacheValue = storageManager.createLazyValue(new Computable<NameToImportsCache>() {
|
||||
this.importsCacheValue = storageManager.createLazyValue(new Function0<NameToImportsCache>() {
|
||||
@Override
|
||||
public NameToImportsCache compute() {
|
||||
public NameToImportsCache invoke() {
|
||||
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.Sets;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Function;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.resolve.BindingTrace;
|
||||
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.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.storage.MemoizedFunctionToNotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -75,9 +75,9 @@ public class LazyImportScope implements JetScope {
|
||||
return status.scope;
|
||||
}
|
||||
|
||||
return resolveSession.getStorageManager().compute(new Computable<JetScope>() {
|
||||
return resolveSession.getStorageManager().compute(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
ImportResolveStatus cachedStatus = importResolveStatus;
|
||||
if (cachedStatus != null && (cachedStatus.lookupMode == mode || cachedStatus.lookupMode == LookupMode.EVERYTHING)) {
|
||||
return cachedStatus.scope;
|
||||
@@ -130,9 +130,9 @@ public class LazyImportScope implements JetScope {
|
||||
this.traceForImportResolve = traceForImportResolve;
|
||||
this.debugName = debugName;
|
||||
|
||||
this.importedScopesProvider = resolveSession.getStorageManager().createMemoizedFunction(new Function<JetImportDirective, ImportDirectiveResolveCache>() {
|
||||
this.importedScopesProvider = resolveSession.getStorageManager().createMemoizedFunction(new Function1<JetImportDirective, ImportDirectiveResolveCache>() {
|
||||
@Override
|
||||
public ImportDirectiveResolveCache fun(JetImportDirective directive) {
|
||||
public ImportDirectiveResolveCache invoke(JetImportDirective directive) {
|
||||
return new ImportDirectiveResolveCache(directive);
|
||||
}
|
||||
}, STRONG);
|
||||
@@ -165,9 +165,9 @@ public class LazyImportScope implements JetScope {
|
||||
final LookupMode lookupMode,
|
||||
final JetScopeSelectorUtil.ScopeByNameSelector<D> descriptorSelector
|
||||
) {
|
||||
return resolveSession.getStorageManager().compute(new Computable<D>() {
|
||||
return resolveSession.getStorageManager().compute(new Function0<D>() {
|
||||
@Override
|
||||
public D compute() {
|
||||
public D invoke() {
|
||||
for (JetImportDirective directive : importsProvider.getImports(name)) {
|
||||
if (directive == directiveUnderResolve) {
|
||||
// This is the recursion in imports analysis
|
||||
@@ -191,9 +191,9 @@ public class LazyImportScope implements JetScope {
|
||||
final LookupMode lookupMode,
|
||||
final JetScopeSelectorUtil.ScopeByNameMultiSelector<D> descriptorsSelector
|
||||
) {
|
||||
return resolveSession.getStorageManager().compute(new Computable<Collection<D>>() {
|
||||
return resolveSession.getStorageManager().compute(new Function0<Collection<D>>() {
|
||||
@Override
|
||||
public Collection<D> compute() {
|
||||
public Collection<D> invoke() {
|
||||
Set<D> descriptors = Sets.newHashSet();
|
||||
for (JetImportDirective directive : importsProvider.getImports(name)) {
|
||||
if (directive == directiveUnderResolve) {
|
||||
@@ -214,9 +214,9 @@ public class LazyImportScope implements JetScope {
|
||||
final LookupMode lookupMode,
|
||||
final JetScopeSelectorUtil.ScopeDescriptorSelector<D> descriptorsSelector
|
||||
) {
|
||||
return resolveSession.getStorageManager().compute(new Computable<Collection<D>>() {
|
||||
return resolveSession.getStorageManager().compute(new Function0<Collection<D>>() {
|
||||
@Override
|
||||
public Collection<D> compute() {
|
||||
public Collection<D> invoke() {
|
||||
Set<D> descriptors = Sets.newHashSet();
|
||||
for (JetImportDirective directive : importsProvider.getAllImports()) {
|
||||
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.Predicates;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.Function;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.di.InjectorForLazyResolve;
|
||||
@@ -216,9 +216,9 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
||||
final JetClassLikeInfo classObjectInfo = parentClassDescriptor.getClassObjectInfo(classObject);
|
||||
if (classObjectInfo != null) {
|
||||
final Name name = DescriptorUtils.getClassObjectName(parentClassDescriptor.getName());
|
||||
return storageManager.compute(new Computable<LazyClassDescriptor>() {
|
||||
return storageManager.compute(new Function0<LazyClassDescriptor>() {
|
||||
@Override
|
||||
public LazyClassDescriptor compute() {
|
||||
public LazyClassDescriptor invoke() {
|
||||
// Create under lock to avoid premature access to published 'this'
|
||||
return new LazyClassDescriptor(ResolveSession.this, parentClassDescriptor, name, classObjectInfo);
|
||||
}
|
||||
|
||||
@@ -17,21 +17,21 @@
|
||||
package org.jetbrains.jet.lang.resolve.lazy;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
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.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
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.scopes.ChainedScope;
|
||||
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.List;
|
||||
@@ -48,16 +48,16 @@ public class ScopeProvider {
|
||||
public ScopeProvider(@NotNull ResolveSession resolveSession) {
|
||||
this.resolveSession = resolveSession;
|
||||
|
||||
this.fileScopes = resolveSession.getStorageManager().createMemoizedFunction(new Function<JetFile, JetScope>() {
|
||||
this.fileScopes = resolveSession.getStorageManager().createMemoizedFunction(new Function1<JetFile, JetScope>() {
|
||||
@Override
|
||||
public JetScope fun(@NotNull JetFile file) {
|
||||
public JetScope invoke(@NotNull JetFile file) {
|
||||
return createFileScope(file);
|
||||
}
|
||||
}, WEAK);
|
||||
|
||||
this.defaultImportsScope = resolveSession.getStorageManager().createLazyValue(new Computable<JetScope>() {
|
||||
this.defaultImportsScope = resolveSession.getStorageManager().createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
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.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
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.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,9 +41,9 @@ public class FilteringClassLikeInfo implements JetClassLikeInfo {
|
||||
@NotNull final Predicate<? super JetDeclaration> declarationFilter
|
||||
) {
|
||||
this.delegate = delegate;
|
||||
this.filteredDeclarations = storageManager.createLazyValue(new Computable<List<JetDeclaration>>() {
|
||||
this.filteredDeclarations = storageManager.createLazyValue(new Function0<List<JetDeclaration>>() {
|
||||
@Override
|
||||
public List<JetDeclaration> compute() {
|
||||
public List<JetDeclaration> invoke() {
|
||||
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.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -70,9 +70,9 @@ public abstract class AbstractPsiBasedDeclarationProvider implements Declaration
|
||||
private final NotNullLazyValue<Index> index;
|
||||
|
||||
public AbstractPsiBasedDeclarationProvider(@NotNull StorageManager storageManager) {
|
||||
index = storageManager.createLazyValue(new Computable<Index>() {
|
||||
index = storageManager.createLazyValue(new Function0<Index>() {
|
||||
@Override
|
||||
public Index compute() {
|
||||
public Index invoke() {
|
||||
Index index = new Index();
|
||||
doCreateIndex(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.Predicates;
|
||||
import com.google.common.collect.*;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamespaceHeader;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
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.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.util.QualifiedNamesUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -64,15 +65,15 @@ public class FileBasedDeclarationProviderFactory implements DeclarationProviderF
|
||||
) {
|
||||
this.storageManager = storageManager;
|
||||
this.isPackageDeclaredExternally = isPackageDeclaredExternally;
|
||||
this.index = storageManager.createLazyValue(new Computable<Index>() {
|
||||
this.index = storageManager.createLazyValue(new Function0<Index>() {
|
||||
@Override
|
||||
public Index compute() {
|
||||
public Index invoke() {
|
||||
return computeFilesByPackage(files);
|
||||
}
|
||||
});
|
||||
this.packageDeclarationProviders = storageManager.createMemoizedFunctionWithNullableValues(new Function<FqName, PackageMemberDeclarationProvider>() {
|
||||
this.packageDeclarationProviders = storageManager.createMemoizedFunctionWithNullableValues(new Function1<FqName, PackageMemberDeclarationProvider>() {
|
||||
@Override
|
||||
public PackageMemberDeclarationProvider fun(FqName fqName) {
|
||||
public PackageMemberDeclarationProvider invoke(FqName fqName) {
|
||||
return createPackageMemberDeclarationProvider(fqName);
|
||||
}
|
||||
}, StorageManager.ReferenceKind.STRONG);
|
||||
|
||||
+5
-5
@@ -16,15 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.lazy.declarations;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
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.Name;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -46,9 +46,9 @@ public class FileBasedPackageMemberDeclarationProvider extends AbstractPsiBasedD
|
||||
this.fqName = _fqName;
|
||||
this.factory = _factory;
|
||||
this.packageFiles = packageFiles;
|
||||
this.allDeclaredPackages = storageManager.createLazyValue(new Computable<Collection<FqName>>() {
|
||||
this.allDeclaredPackages = storageManager.createLazyValue(new Function0<Collection<FqName>>() {
|
||||
@Override
|
||||
public Collection<FqName> compute() {
|
||||
public Collection<FqName> invoke() {
|
||||
return factory.getAllDeclaredSubPackagesOf(fqName);
|
||||
}
|
||||
});
|
||||
|
||||
+15
-14
@@ -17,9 +17,10 @@
|
||||
package org.jetbrains.jet.lang.resolve.lazy.descriptors;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.data.JetClassInfoUtil;
|
||||
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.Name;
|
||||
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.Collections;
|
||||
@@ -71,35 +72,35 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
this.thisDescriptor = thisDescriptor;
|
||||
|
||||
StorageManager storageManager = resolveSession.getStorageManager();
|
||||
this.classDescriptors = storageManager.createMemoizedFunction(new Function<Name, List<ClassDescriptor>>() {
|
||||
this.classDescriptors = storageManager.createMemoizedFunction(new Function1<Name, List<ClassDescriptor>>() {
|
||||
@Override
|
||||
public List<ClassDescriptor> fun(Name name) {
|
||||
public List<ClassDescriptor> invoke(Name name) {
|
||||
return resolveClassOrObjectDescriptor(name, false);
|
||||
}
|
||||
}, STRONG);
|
||||
this.objectDescriptors = storageManager.createMemoizedFunction(new Function<Name, List<ClassDescriptor>>() {
|
||||
this.objectDescriptors = storageManager.createMemoizedFunction(new Function1<Name, List<ClassDescriptor>>() {
|
||||
@Override
|
||||
public List<ClassDescriptor> fun(Name name) {
|
||||
public List<ClassDescriptor> invoke(Name name) {
|
||||
return resolveClassOrObjectDescriptor(name, true);
|
||||
}
|
||||
}, STRONG);
|
||||
|
||||
this.functionDescriptors = storageManager.createMemoizedFunction(new Function<Name, Set<FunctionDescriptor>>() {
|
||||
this.functionDescriptors = storageManager.createMemoizedFunction(new Function1<Name, Set<FunctionDescriptor>>() {
|
||||
@Override
|
||||
public Set<FunctionDescriptor> fun(Name name) {
|
||||
public Set<FunctionDescriptor> invoke(Name name) {
|
||||
return doGetFunctions(name);
|
||||
}
|
||||
}, STRONG);
|
||||
this.propertyDescriptors = storageManager.createMemoizedFunction(new Function<Name, Set<VariableDescriptor>>() {
|
||||
this.propertyDescriptors = storageManager.createMemoizedFunction(new Function1<Name, Set<VariableDescriptor>>() {
|
||||
@Override
|
||||
public Set<VariableDescriptor> fun(Name name) {
|
||||
public Set<VariableDescriptor> invoke(Name name) {
|
||||
return doGetProperties(name);
|
||||
}
|
||||
}, STRONG);
|
||||
|
||||
this.allDescriptors = storageManager.createLazyValue(new Computable<AllDescriptors>() {
|
||||
this.allDescriptors = storageManager.createLazyValue(new Function0<AllDescriptors>() {
|
||||
@Override
|
||||
public AllDescriptors compute() {
|
||||
public AllDescriptors invoke() {
|
||||
return computeAllDescriptors();
|
||||
}
|
||||
});
|
||||
|
||||
+23
-23
@@ -20,10 +20,9 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import jet.Function0;
|
||||
import jet.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -124,39 +123,39 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
this.isInner = isInnerClass(modifierList);
|
||||
|
||||
StorageManager storageManager = resolveSession.getStorageManager();
|
||||
this.thisAsReceiverParameter = storageManager.createLazyValue(new Computable<ReceiverParameterDescriptor>() {
|
||||
this.thisAsReceiverParameter = storageManager.createLazyValue(new Function0<ReceiverParameterDescriptor>() {
|
||||
@Override
|
||||
public ReceiverParameterDescriptor compute() {
|
||||
public ReceiverParameterDescriptor invoke() {
|
||||
return DescriptorFactory.createLazyReceiverParameterDescriptor(LazyClassDescriptor.this);
|
||||
}
|
||||
});
|
||||
this.annotations = storageManager.createLazyValue(new Computable<List<AnnotationDescriptor>>() {
|
||||
this.annotations = storageManager.createLazyValue(new Function0<List<AnnotationDescriptor>>() {
|
||||
@Override
|
||||
public List<AnnotationDescriptor> compute() {
|
||||
public List<AnnotationDescriptor> invoke() {
|
||||
return resolveAnnotations();
|
||||
}
|
||||
});
|
||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Computable<ClassDescriptor>() {
|
||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<ClassDescriptor>() {
|
||||
@Override
|
||||
public ClassDescriptor compute() {
|
||||
public ClassDescriptor invoke() {
|
||||
return computeClassObjectDescriptor();
|
||||
}
|
||||
});
|
||||
this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Computable<JetScope>() {
|
||||
this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
return computeScopeForClassHeaderResolution();
|
||||
}
|
||||
});
|
||||
this.scopeForMemberDeclarationResolution = storageManager.createLazyValue(new Computable<JetScope>() {
|
||||
this.scopeForMemberDeclarationResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
return computeScopeForMemberDeclarationResolution();
|
||||
}
|
||||
});
|
||||
this.scopeForPropertyInitializerResolution = storageManager.createLazyValue(new Computable<JetScope>() {
|
||||
this.scopeForPropertyInitializerResolution = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||
@Override
|
||||
public JetScope compute() {
|
||||
public JetScope invoke() {
|
||||
return computeScopeForPropertyInitializerResolution();
|
||||
}
|
||||
});
|
||||
@@ -374,9 +373,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
|
||||
private class LazyClassTypeConstructor implements LazyDescriptor, TypeConstructor {
|
||||
private final NotNullLazyValue<Collection<JetType>> supertypes = resolveSession.getStorageManager().createLazyValueWithPostCompute(
|
||||
new Computable<Collection<JetType>>() {
|
||||
new Function0<Collection<JetType>>() {
|
||||
@Override
|
||||
public Collection<JetType> compute() {
|
||||
public Collection<JetType> invoke() {
|
||||
if (resolveSession.isClassSpecial(DescriptorUtils.getFQName(LazyClassDescriptor.this))) {
|
||||
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
|
||||
public Collection<JetType> fun(Boolean firstTime) {
|
||||
public Collection<JetType> invoke(Boolean firstTime) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
},
|
||||
new Consumer<Collection<JetType>>() {
|
||||
new Function1<Collection<JetType>, Void>() {
|
||||
@Override
|
||||
public void consume(@NotNull Collection<JetType> supertypes) {
|
||||
public Void invoke(@NotNull Collection<JetType> 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
|
||||
public List<TypeParameterDescriptor> compute() {
|
||||
public List<TypeParameterDescriptor> invoke() {
|
||||
JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
|
||||
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.Lists;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -82,9 +82,9 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
@NotNull LazyClassDescriptor thisClass
|
||||
) {
|
||||
super(resolveSession, declarationProvider, thisClass);
|
||||
this.primaryConstructor = resolveSession.getStorageManager().createNullableLazyValue(new Computable<ConstructorDescriptor>() {
|
||||
this.primaryConstructor = resolveSession.getStorageManager().createNullableLazyValue(new Function0<ConstructorDescriptor>() {
|
||||
@Override
|
||||
public ConstructorDescriptor compute() {
|
||||
public ConstructorDescriptor invoke() {
|
||||
return resolvePrimaryConstructor();
|
||||
}
|
||||
});
|
||||
@@ -378,9 +378,9 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
|
||||
private void setDeferredReturnType(@NotNull ConstructorDescriptorImpl descriptor) {
|
||||
descriptor.setReturnType(DeferredType.create(resolveSession.getTrace(), resolveSession.getStorageManager().createLazyValue(
|
||||
new Computable<JetType>() {
|
||||
new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
return thisDescriptor.getDefaultType();
|
||||
}
|
||||
})
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@
|
||||
|
||||
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.Nullable;
|
||||
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.lazy.ResolveSession;
|
||||
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.Name;
|
||||
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.Set;
|
||||
@@ -44,9 +44,9 @@ public class LazyPackageMemberScope extends AbstractLazyMemberScope<NamespaceDes
|
||||
super(resolveSession, declarationProvider, thisPackage);
|
||||
|
||||
this.packageDescriptors = resolveSession.getStorageManager().createMemoizedFunctionWithNullableValues(
|
||||
new Function<Name, NamespaceDescriptor>() {
|
||||
new Function1<Name, NamespaceDescriptor>() {
|
||||
@Override
|
||||
public NamespaceDescriptor fun(Name name) {
|
||||
public NamespaceDescriptor invoke(Name name) {
|
||||
return createPackageDescriptor(name);
|
||||
}
|
||||
}, StorageManager.ReferenceKind.STRONG);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.types;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
@@ -38,7 +38,7 @@ public class DeferredType implements JetType {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.jet.lang.types.expressions;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import jet.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -69,9 +69,9 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (slice == CLASS && declaration == expression.getObjectDeclaration()) {
|
||||
JetType defaultType = DeferredType.create(context.trace, createRecursionIntolerantLazyValueWithDefault(
|
||||
ErrorUtils.createErrorType("Recursive dependency"),
|
||||
new Computable<JetType>() {
|
||||
new Function0<JetType>() {
|
||||
@Override
|
||||
public JetType compute() {
|
||||
public JetType invoke() {
|
||||
return descriptor.getDefaultType();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
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.Function1;
|
||||
import junit.framework.TestCase;
|
||||
@@ -167,9 +164,9 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
public void testRecursionIntolerance() throws Exception {
|
||||
class C {
|
||||
NotNullLazyValue<String> rec = m.createLazyValue(new Computable<String>() {
|
||||
NotNullLazyValue<String> rec = m.createLazyValue(new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
return rec.invoke();
|
||||
}
|
||||
});
|
||||
@@ -186,9 +183,9 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
public void testNullableRecursionIntolerance() throws Exception {
|
||||
class C {
|
||||
NullableLazyValue<String> rec = m.createNullableLazyValue(new Computable<String>() {
|
||||
NullableLazyValue<String> rec = m.createNullableLazyValue(new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
return rec.invoke();
|
||||
}
|
||||
});
|
||||
@@ -205,9 +202,9 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
public void testRecursionTolerance() throws Exception {
|
||||
class C {
|
||||
NotNullLazyValue<String> rec = m.createRecursionTolerantLazyValue(new Computable<String>() {
|
||||
NotNullLazyValue<String> rec = m.createRecursionTolerantLazyValue(new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
assertEquals("rec", rec.invoke());
|
||||
return "tolerant!";
|
||||
}
|
||||
@@ -219,9 +216,9 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
public void testNullableRecursionTolerance() throws Exception {
|
||||
class C {
|
||||
NullableLazyValue<String> rec = m.createRecursionTolerantNullableLazyValue(new Computable<String>() {
|
||||
NullableLazyValue<String> rec = m.createRecursionTolerantNullableLazyValue(new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
assertEquals(null, rec.invoke());
|
||||
return "tolerant!";
|
||||
}
|
||||
@@ -235,14 +232,19 @@ public class StorageManagerTest extends TestCase {
|
||||
@SuppressWarnings("unchecked")
|
||||
class C {
|
||||
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
||||
new Computable<String>() {
|
||||
new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
return rec.invoke();
|
||||
}
|
||||
},
|
||||
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();
|
||||
class C {
|
||||
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
||||
new Computable<String>() {
|
||||
new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
return rec.invoke();
|
||||
}
|
||||
},
|
||||
new Function<Boolean, String>() {
|
||||
new Function1<Boolean, String>() {
|
||||
@Override
|
||||
public String fun(Boolean aBoolean) {
|
||||
public String invoke(Boolean aBoolean) {
|
||||
return "tolerant";
|
||||
}
|
||||
},
|
||||
new Consumer<String>() {
|
||||
new Function1<String, Void>() {
|
||||
@Override
|
||||
public void consume(String s) {
|
||||
public Void invoke(String s) {
|
||||
counter.inc();
|
||||
assertEquals("tolerant", s);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -290,20 +293,21 @@ public class StorageManagerTest extends TestCase {
|
||||
public void testPostComputeNoRecursion() throws Exception {
|
||||
final CounterImpl counter = new CounterImpl();
|
||||
NotNullLazyValue<Collection<String>> v = m.createLazyValueWithPostCompute(
|
||||
new Computable<Collection<String>>() {
|
||||
new Function0<Collection<String>>() {
|
||||
@Override
|
||||
public Collection<String> compute() {
|
||||
public Collection<String> invoke() {
|
||||
List<String> strings = new ArrayList<String>();
|
||||
strings.add("first");
|
||||
return strings;
|
||||
}
|
||||
},
|
||||
null,
|
||||
new Consumer<Collection<String>>() {
|
||||
new Function1<Collection<String>, Void>() {
|
||||
@Override
|
||||
public void consume(Collection<String> strings) {
|
||||
public Void invoke(Collection<String> strings) {
|
||||
counter.inc();
|
||||
strings.add("postComputed");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -316,19 +320,20 @@ public class StorageManagerTest extends TestCase {
|
||||
public void testNullablePostComputeNoRecursion() throws Exception {
|
||||
final CounterImpl counter = new CounterImpl();
|
||||
NullableLazyValue<Collection<String>> v = m.createNullableLazyValueWithPostCompute(
|
||||
new Computable<Collection<String>>() {
|
||||
new Function0<Collection<String>>() {
|
||||
@Override
|
||||
public Collection<String> compute() {
|
||||
public Collection<String> invoke() {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
strings.add("first");
|
||||
return strings;
|
||||
}
|
||||
},
|
||||
new Consumer<Collection<String>>() {
|
||||
new Function1<Collection<String>, Void>() {
|
||||
@Override
|
||||
public void consume(Collection<String> strings) {
|
||||
public Void invoke(Collection<String> strings) {
|
||||
counter.inc();
|
||||
strings.add("postComputed");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -342,25 +347,26 @@ public class StorageManagerTest extends TestCase {
|
||||
@SuppressWarnings("unchecked")
|
||||
class C {
|
||||
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
|
||||
new Computable<String>() {
|
||||
new Function0<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
return rec.invoke();
|
||||
}
|
||||
},
|
||||
new Function<Boolean, String>() {
|
||||
new Function1<Boolean, String>() {
|
||||
@Override
|
||||
public String fun(Boolean firstTime) {
|
||||
public String invoke(Boolean firstTime) {
|
||||
if (firstTime) {
|
||||
throw new ReenteringLazyValueComputationException();
|
||||
}
|
||||
return "second";
|
||||
}
|
||||
},
|
||||
new Consumer<String>() {
|
||||
new Function1<String, Void>() {
|
||||
@Override
|
||||
public void consume(String s) {
|
||||
public Void invoke(String s) {
|
||||
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
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
inc();
|
||||
return null;
|
||||
}
|
||||
@@ -417,7 +423,7 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
private static class CounterValue extends CounterValueNull {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
inc();
|
||||
return "ok" + getCount();
|
||||
}
|
||||
@@ -425,15 +431,15 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
private static class ExceptionCounterValue extends CounterValueNull {
|
||||
@Override
|
||||
public String compute() {
|
||||
public String invoke() {
|
||||
inc();
|
||||
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
|
||||
public String fun(String s) {
|
||||
public String invoke(String s) {
|
||||
inc();
|
||||
return null;
|
||||
}
|
||||
@@ -441,7 +447,7 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
private static class CounterFunction extends CounterFunctionToNull {
|
||||
@Override
|
||||
public String fun(String s) {
|
||||
public String invoke(String s) {
|
||||
inc();
|
||||
return s + getCount();
|
||||
}
|
||||
@@ -449,7 +455,7 @@ public class StorageManagerTest extends TestCase {
|
||||
|
||||
private static class ExceptionCounterFunction extends CounterFunctionToNull {
|
||||
@Override
|
||||
public String fun(String s) {
|
||||
public String invoke(String s) {
|
||||
inc();
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user