ManyMap renamed and moved
This commit is contained in:
@@ -411,7 +411,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||
if (declaration instanceof JetProperty) {
|
||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, (JetProperty) declaration);
|
||||
if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
if (state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
||||
if (initializer != null) {
|
||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
private void generateBackingField(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
||||
if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
if (state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
Object value = null;
|
||||
final JetExpression initializer = p.getInitializer();
|
||||
if (initializer != null) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.util.*;
|
||||
import org.jetbrains.jet.util.slicedmap.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -15,21 +15,21 @@ import java.util.Collection;
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface BindingContext {
|
||||
WritableSlice<JetAnnotationEntry, AnnotationDescriptor> ANNOTATION = ManyMapSlices.createSimpleSlice("ANNOTATION");
|
||||
WritableSlice<JetExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = ManyMapSlices.createSimpleSlice("COMPILE_TIME_VALUE");
|
||||
WritableSlice<JetTypeReference, JetType> TYPE = ManyMapSlices.createSimpleSlice("TYPE");
|
||||
WritableSlice<JetAnnotationEntry, AnnotationDescriptor> ANNOTATION = Slices.createSimpleSlice("ANNOTATION");
|
||||
WritableSlice<JetExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice("COMPILE_TIME_VALUE");
|
||||
WritableSlice<JetTypeReference, JetType> TYPE = Slices.createSimpleSlice("TYPE");
|
||||
WritableSlice<JetExpression, JetType> EXPRESSION_TYPE = new BasicWritableSlice<JetExpression, JetType>("EXPRESSION_TYPE", RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>("REFERENCE_TARGET", RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetExpression, JetType> AUTOCAST = ManyMapSlices.createSimpleSlice("AUTOCAST");
|
||||
WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = ManyMapSlices.createSimpleSlice("RESOLUTION_SCOPE");
|
||||
WritableSlice<JetExpression, JetType> AUTOCAST = Slices.createSimpleSlice("AUTOCAST");
|
||||
WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = Slices.createSimpleSlice("RESOLUTION_SCOPE");
|
||||
|
||||
WritableSlice<JetExpression, Boolean> VARIABLE_REASSIGNMENT = ManyMapSlices.createSimpleSetSlice("VARIABLE_REASSIGNMENT");
|
||||
WritableSlice<JetExpression, Boolean> PROCESSED = ManyMapSlices.createSimpleSetSlice("PROCESSED");
|
||||
WritableSlice<JetElement, Boolean> STATEMENT = ManyMapSlices.createRemovableSetSlice("STATEMENT");
|
||||
WritableSlice<JetExpression, Boolean> VARIABLE_REASSIGNMENT = Slices.createSimpleSetSlice("VARIABLE_REASSIGNMENT");
|
||||
WritableSlice<JetExpression, Boolean> PROCESSED = Slices.createSimpleSetSlice("PROCESSED");
|
||||
WritableSlice<JetElement, Boolean> STATEMENT = Slices.createRemovableSetSlice("STATEMENT");
|
||||
|
||||
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new ManyMapSlices.SetSlice<PropertyDescriptor>("BACKING_FIELD_REQUIRED", RewritePolicy.DO_NOTHING) {
|
||||
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new Slices.SetSlice<PropertyDescriptor>("BACKING_FIELD_REQUIRED", RewritePolicy.DO_NOTHING) {
|
||||
@Override
|
||||
public Boolean computeValue(ManyMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) {
|
||||
public Boolean computeValue(SlicedMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) {
|
||||
backingFieldRequired = valueNotFound ? false : backingFieldRequired;
|
||||
assert backingFieldRequired != null;
|
||||
PsiElement declarationPsiElement = map.get(DESCRIPTOR_TO_DECLARATION, propertyDescriptor);
|
||||
@@ -57,16 +57,16 @@ public interface BindingContext {
|
||||
}
|
||||
};
|
||||
|
||||
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new ManyMapSlices.SetSlice<JetFunctionLiteralExpression>("BLOCK", RewritePolicy.DO_NOTHING) {
|
||||
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new Slices.SetSlice<JetFunctionLiteralExpression>("BLOCK", RewritePolicy.DO_NOTHING) {
|
||||
@Override
|
||||
public Boolean computeValue(ManyMap map, JetFunctionLiteralExpression expression, Boolean isBlock, boolean valueNotFound) {
|
||||
public Boolean computeValue(SlicedMap map, JetFunctionLiteralExpression expression, Boolean isBlock, boolean valueNotFound) {
|
||||
isBlock = valueNotFound ? false : isBlock;
|
||||
assert isBlock != null;
|
||||
return isBlock && !expression.getFunctionLiteral().hasParameterSpecification();
|
||||
}
|
||||
};
|
||||
|
||||
ManyMapSlices.KeyNormalizer<DeclarationDescriptor> DECLARATION_DESCRIPTOR_NORMALIZER = new ManyMapSlices.KeyNormalizer<DeclarationDescriptor>() {
|
||||
Slices.KeyNormalizer<DeclarationDescriptor> DECLARATION_DESCRIPTOR_NORMALIZER = new Slices.KeyNormalizer<DeclarationDescriptor>() {
|
||||
@Override
|
||||
public DeclarationDescriptor normalize(DeclarationDescriptor declarationDescriptor) {
|
||||
if (declarationDescriptor instanceof VariableAsFunctionDescriptor) {
|
||||
@@ -76,30 +76,30 @@ public interface BindingContext {
|
||||
return declarationDescriptor.getOriginal();
|
||||
}
|
||||
};
|
||||
ReadOnlySlice<DeclarationDescriptor, PsiElement> DESCRIPTOR_TO_DECLARATION = ManyMapSlices.<DeclarationDescriptor, PsiElement>sliceBuilder("DECLARATION_TO_DESCRIPTOR").setKeyNormalizer(DECLARATION_DESCRIPTOR_NORMALIZER).build();
|
||||
ReadOnlySlice<DeclarationDescriptor, PsiElement> DESCRIPTOR_TO_DECLARATION = Slices.<DeclarationDescriptor, PsiElement>sliceBuilder("DECLARATION_TO_DESCRIPTOR").setKeyNormalizer(DECLARATION_DESCRIPTOR_NORMALIZER).build();
|
||||
|
||||
WritableSlice<PsiElement, NamespaceDescriptor> NAMESPACE = ManyMapSlices.<PsiElement, NamespaceDescriptor>sliceBuilder("DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, ClassDescriptor> CLASS = ManyMapSlices.<PsiElement, ClassDescriptor>sliceBuilder("CLASS").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetTypeParameter, TypeParameterDescriptor> TYPE_PARAMETER = ManyMapSlices.<JetTypeParameter, TypeParameterDescriptor>sliceBuilder("TYPE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, FunctionDescriptor> FUNCTION = ManyMapSlices.<PsiElement, FunctionDescriptor>sliceBuilder("FUNCTION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, ConstructorDescriptor> CONSTRUCTOR = ManyMapSlices.<PsiElement, ConstructorDescriptor>sliceBuilder("CONSTRUCTOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, VariableDescriptor> VARIABLE = ManyMapSlices.<PsiElement, VariableDescriptor>sliceBuilder("VARIABLE").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetParameter, VariableDescriptor> VALUE_PARAMETER = ManyMapSlices.<JetParameter, VariableDescriptor>sliceBuilder("VALUE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetPropertyAccessor, PropertyAccessorDescriptor> PROPERTY_ACCESSOR = ManyMapSlices.<JetPropertyAccessor, PropertyAccessorDescriptor>sliceBuilder("PROPERTY_ACCESSOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, NamespaceDescriptor> NAMESPACE = Slices.<PsiElement, NamespaceDescriptor>sliceBuilder("DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, ClassDescriptor> CLASS = Slices.<PsiElement, ClassDescriptor>sliceBuilder("CLASS").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetTypeParameter, TypeParameterDescriptor> TYPE_PARAMETER = Slices.<JetTypeParameter, TypeParameterDescriptor>sliceBuilder("TYPE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, FunctionDescriptor> FUNCTION = Slices.<PsiElement, FunctionDescriptor>sliceBuilder("FUNCTION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, ConstructorDescriptor> CONSTRUCTOR = Slices.<PsiElement, ConstructorDescriptor>sliceBuilder("CONSTRUCTOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, VariableDescriptor> VARIABLE = Slices.<PsiElement, VariableDescriptor>sliceBuilder("VARIABLE").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetParameter, VariableDescriptor> VALUE_PARAMETER = Slices.<JetParameter, VariableDescriptor>sliceBuilder("VALUE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetPropertyAccessor, PropertyAccessorDescriptor> PROPERTY_ACCESSOR = Slices.<JetPropertyAccessor, PropertyAccessorDescriptor>sliceBuilder("PROPERTY_ACCESSOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
|
||||
// normalize value to getOriginal(value)
|
||||
WritableSlice<PsiElement, PropertyDescriptor> PRIMARY_CONSTRUCTOR_PARAMETER = ManyMapSlices.<PsiElement, PropertyDescriptor>sliceBuilder("PRIMARY_CONSTRUCTOR_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetObjectDeclarationName, PropertyDescriptor> OBJECT_DECLARATION = ManyMapSlices.<JetObjectDeclarationName, PropertyDescriptor>sliceBuilder("OBJECT_DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<PsiElement, PropertyDescriptor> PRIMARY_CONSTRUCTOR_PARAMETER = Slices.<PsiElement, PropertyDescriptor>sliceBuilder("PRIMARY_CONSTRUCTOR_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
WritableSlice<JetObjectDeclarationName, PropertyDescriptor> OBJECT_DECLARATION = Slices.<JetObjectDeclarationName, PropertyDescriptor>sliceBuilder("OBJECT_DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||
|
||||
WritableSlice[] DECLARATIONS_TO_DESCRIPTORS = new WritableSlice[] {
|
||||
NAMESPACE, CLASS, TYPE_PARAMETER, FUNCTION, CONSTRUCTOR, VARIABLE, VALUE_PARAMETER, PRIMARY_CONSTRUCTOR_PARAMETER, OBJECT_DECLARATION
|
||||
};
|
||||
|
||||
ReadOnlySlice<PsiElement, DeclarationDescriptor> DECLARATION_TO_DESCRIPTOR = ManyMapSlices.<PsiElement, DeclarationDescriptor>sliceBuilder("DECLARATION_TO_DESCRIPTOR")
|
||||
ReadOnlySlice<PsiElement, DeclarationDescriptor> DECLARATION_TO_DESCRIPTOR = Slices.<PsiElement, DeclarationDescriptor>sliceBuilder("DECLARATION_TO_DESCRIPTOR")
|
||||
.setFurtherLookupSlices(DECLARATIONS_TO_DESCRIPTORS).build();
|
||||
|
||||
WritableSlice<JetReferenceExpression, PsiElement> LABEL_TARGET = ManyMapSlices.<JetReferenceExpression, PsiElement>sliceBuilder("LABEL_TARGET").build();
|
||||
WritableSlice<JetParameter, PropertyDescriptor> VALUE_PARAMETER_AS_PROPERTY = ManyMapSlices.<JetParameter, PropertyDescriptor>sliceBuilder("VALUE_PARAMETER_AS_PROPERTY").build();
|
||||
WritableSlice<JetReferenceExpression, PsiElement> LABEL_TARGET = Slices.<JetReferenceExpression, PsiElement>sliceBuilder("LABEL_TARGET").build();
|
||||
WritableSlice<JetParameter, PropertyDescriptor> VALUE_PARAMETER_AS_PROPERTY = Slices.<JetParameter, PropertyDescriptor>sliceBuilder("VALUE_PARAMETER_AS_PROPERTY").build();
|
||||
|
||||
Collection<JetDiagnostic> getDiagnostics();
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.ErrorHandler;
|
||||
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.WritableSlice;
|
||||
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.jetbrains.jet.lang.resolve;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.ErrorHandler;
|
||||
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.WritableSlice;
|
||||
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.CollectingErrorHandler;
|
||||
import org.jetbrains.jet.lang.ErrorHandler;
|
||||
import org.jetbrains.jet.lang.JetDiagnostic;
|
||||
import org.jetbrains.jet.util.ManyMapImpl;
|
||||
import org.jetbrains.jet.util.MutableManyMap;
|
||||
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.WritableSlice;
|
||||
import org.jetbrains.jet.util.slicedmap.MutableSlicedMap;
|
||||
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.slicedmap.SlicedMapImpl;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -19,7 +19,8 @@ import java.util.List;
|
||||
public class BindingTraceContext implements BindingTrace {
|
||||
private final List<JetDiagnostic> diagnostics = Lists.newArrayList();
|
||||
private final ErrorHandler errorHandler = new CollectingErrorHandler(diagnostics);
|
||||
private final MutableManyMap map = ManyMapImpl.create();
|
||||
|
||||
private final MutableSlicedMap map = SlicedMapImpl.create();
|
||||
|
||||
private final BindingContext bindingContext = new BindingContext() {
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.CollectingErrorHandler;
|
||||
import org.jetbrains.jet.lang.ErrorHandler;
|
||||
import org.jetbrains.jet.lang.JetDiagnostic;
|
||||
import org.jetbrains.jet.util.*;
|
||||
import org.jetbrains.jet.util.slicedmap.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class DelegatingBindingTrace implements BindingTrace {
|
||||
private final BindingContext parentContext;
|
||||
private final MutableManyMap map = ManyMapImpl.create();
|
||||
private final MutableSlicedMap map = SlicedMapImpl.create();
|
||||
private final List<JetDiagnostic> diagnostics = Lists.newArrayList();
|
||||
private final ErrorHandler errorHandler = new CollectingErrorHandler(diagnostics);
|
||||
|
||||
@@ -66,12 +66,12 @@ public class DelegatingBindingTrace implements BindingTrace {
|
||||
}
|
||||
|
||||
public void addAllMyDataTo(BindingTrace trace) {
|
||||
for (Map.Entry<ManyMapKey<?, ?>, ?> entry : map) {
|
||||
ManyMapKey manyMapKey = entry.getKey();
|
||||
for (Map.Entry<SlicedMapKey<?, ?>, ?> entry : map) {
|
||||
SlicedMapKey slicedMapKey = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
||||
//noinspection unchecked
|
||||
trace.record(manyMapKey.getSlice(), manyMapKey.getKey(), value);
|
||||
trace.record(slicedMapKey.getSlice(), slicedMapKey.getKey(), value);
|
||||
}
|
||||
|
||||
AnalyzingUtils.applyHandler(trace.getErrorHandler(), diagnostics);
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.util.WritableSlice;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -449,7 +449,7 @@ public class TopDownAnalyzer {
|
||||
if (!klass.hasPrimaryConstructor()) return;
|
||||
|
||||
// TODO : not all the parameters are real properties
|
||||
JetScope memberScope = classDescriptor.getScopeForMemberResolution(); // TODO : this is REALLY questionable
|
||||
JetScope memberScope = classDescriptor.getScopeForSupertypeResolution(); // TODO : this is REALLY questionable
|
||||
ConstructorDescriptor constructorDescriptor = classDescriptorResolver.resolvePrimaryConstructorDescriptor(memberScope, classDescriptor, klass);
|
||||
for (JetParameter parameter : klass.getPrimaryConstructorParameters()) {
|
||||
PropertyDescriptor propertyDescriptor = classDescriptorResolver.resolvePrimaryConstructorParameterToAProperty(
|
||||
@@ -530,7 +530,7 @@ public class TopDownAnalyzer {
|
||||
JetClass jetClass = entry.getKey();
|
||||
if (classDescriptor.getUnsubstitutedPrimaryConstructor() == null) {
|
||||
for (PropertyDescriptor propertyDescriptor : classDescriptor.getProperties()) {
|
||||
if ((boolean) trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
if (trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||
PsiElement nameIdentifier = jetClass.getNameIdentifier();
|
||||
if (nameIdentifier != null) {
|
||||
trace.getErrorHandler().genericError(nameIdentifier.getNode(),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.jetbrains.jet.lang.types;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.util.CommonSuppliers;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -31,13 +31,7 @@ public class DataFlowInfo {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Supplier<List<JetType>> ARRAY_LIST_SUPPLIER = new Supplier<List<JetType>>() {
|
||||
@Override
|
||||
public List<JetType> get() {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
};
|
||||
private static DataFlowInfo EMPTY = new DataFlowInfo(ImmutableMap.<VariableDescriptor, NullabilityFlags>of(), Multimaps.newListMultimap(Collections.<VariableDescriptor, Collection<JetType>>emptyMap(), ARRAY_LIST_SUPPLIER));
|
||||
private static DataFlowInfo EMPTY = new DataFlowInfo(ImmutableMap.<VariableDescriptor, NullabilityFlags>of(), Multimaps.newListMultimap(Collections.<VariableDescriptor, Collection<JetType>>emptyMap(), CommonSuppliers.<JetType>getArrayListSupplier()));
|
||||
|
||||
public static DataFlowInfo getEmpty() {
|
||||
return EMPTY;
|
||||
@@ -147,7 +141,7 @@ public class DataFlowInfo {
|
||||
}
|
||||
|
||||
private ListMultimap<VariableDescriptor, JetType> copyTypeInfo() {
|
||||
ListMultimap<VariableDescriptor, JetType> newTypeInfo = Multimaps.newListMultimap(Maps.<VariableDescriptor, Collection<JetType>>newHashMap(), ARRAY_LIST_SUPPLIER);
|
||||
ListMultimap<VariableDescriptor, JetType> newTypeInfo = Multimaps.newListMultimap(Maps.<VariableDescriptor, Collection<JetType>>newHashMap(), CommonSuppliers.<JetType>getArrayListSupplier());
|
||||
newTypeInfo.putAll(typeInfo);
|
||||
return newTypeInfo;
|
||||
}
|
||||
@@ -163,7 +157,7 @@ public class DataFlowInfo {
|
||||
builder.put(variableDescriptor, thisFlags.or(otherFlags));
|
||||
}
|
||||
|
||||
ListMultimap<VariableDescriptor, JetType> newTypeInfo = Multimaps.newListMultimap(Maps.<VariableDescriptor, Collection<JetType>>newHashMap(), ARRAY_LIST_SUPPLIER);
|
||||
ListMultimap<VariableDescriptor, JetType> newTypeInfo = Multimaps.newListMultimap(Maps.<VariableDescriptor, Collection<JetType>>newHashMap(), CommonSuppliers.<JetType>getArrayListSupplier());
|
||||
|
||||
Set<VariableDescriptor> keys = newTypeInfo.keySet();
|
||||
keys.retainAll(other.typeInfo.keySet());
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.resolve.constants.ErrorValue;
|
||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
import org.jetbrains.jet.util.WritableSlice;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class JetPsiChecker implements Annotator {
|
||||
public void visitProperty(JetProperty property) {
|
||||
VariableDescriptor propertyDescriptor = bindingContext.get(BindingContext.VARIABLE, property);
|
||||
if (propertyDescriptor instanceof PropertyDescriptor) {
|
||||
if ((boolean) bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) propertyDescriptor)) {
|
||||
if (bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) propertyDescriptor)) {
|
||||
putBackingfieldAnnotation(holder, property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.jetbrains.jet.util;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class CommonSuppliers {
|
||||
private CommonSuppliers() {}
|
||||
|
||||
private static final Supplier<?> ARRAY_LIST_SUPPLIER = new Supplier() {
|
||||
@Override
|
||||
public List get() {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
};
|
||||
|
||||
public static <T> Supplier<List<T>> getArrayListSupplier() {
|
||||
//noinspection unchecked
|
||||
return (Supplier<List<T>>) ARRAY_LIST_SUPPLIER;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.jetbrains.jet.util;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface ReadOnlySlice<K, V> {
|
||||
ManyMapKey<K, V> makeKey(K key);
|
||||
|
||||
V computeValue(ManyMap map, K key, V value, boolean valueNotFound);
|
||||
|
||||
}
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -14,8 +14,8 @@ public class BasicWritableSlice<K, V> implements WritableSlice<K,V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyMapKey<K, V> makeKey(K key) {
|
||||
return new ManyMapKey<K, V>(this, key);
|
||||
public SlicedMapKey<K, V> makeKey(K key) {
|
||||
return new SlicedMapKey<K, V>(this, key);
|
||||
}
|
||||
|
||||
// True to put, false to skip
|
||||
@@ -27,12 +27,12 @@ public class BasicWritableSlice<K, V> implements WritableSlice<K,V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPut(MutableManyMap manyMap, K key, V value) {
|
||||
public void afterPut(MutableSlicedMap map, K key, V value) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) {
|
||||
public V computeValue(SlicedMap map, K key, V value, boolean valueNotFound) {
|
||||
if (valueNotFound) assert value == null;
|
||||
return value;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface MutableManyMap extends ManyMap {
|
||||
public interface MutableSlicedMap extends SlicedMap {
|
||||
|
||||
<K, V> void put(WritableSlice<K, V> slice, K key, V value);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface ReadOnlySlice<K, V> {
|
||||
SlicedMapKey<K, V> makeKey(K key);
|
||||
|
||||
V computeValue(SlicedMap map, K key, V value, boolean valueNotFound);
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface ManyMap extends Iterable<Map.Entry<ManyMapKey<?, ?>, ?>> {
|
||||
public interface SlicedMap extends Iterable<Map.Entry<SlicedMapKey<?, ?>, ?>> {
|
||||
<K, V> V get(ReadOnlySlice<K, V> slice, K key);
|
||||
|
||||
<K, V> boolean containsKey(ReadOnlySlice<K, V> slice, K key);
|
||||
+18
-18
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@@ -8,23 +8,23 @@ import java.util.Map;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class ManyMapImpl implements MutableManyMap {
|
||||
public class SlicedMapImpl implements MutableSlicedMap {
|
||||
|
||||
public static ManyMapImpl create() {
|
||||
return new ManyMapImpl(Maps.<ManyMapKey<?, ?>, Object>newLinkedHashMap());
|
||||
public static SlicedMapImpl create() {
|
||||
return new SlicedMapImpl(Maps.<SlicedMapKey<?, ?>, Object>newLinkedHashMap());
|
||||
}
|
||||
|
||||
public static ManyMapImpl create(Map<ManyMapKey<?, ?>, Object> map) {
|
||||
return new ManyMapImpl(map);
|
||||
public static SlicedMapImpl create(Map<SlicedMapKey<?, ?>, Object> map) {
|
||||
return new SlicedMapImpl(map);
|
||||
}
|
||||
|
||||
public static ManyMapImpl create(MapSupplier mapSupplier) {
|
||||
return new ManyMapImpl(mapSupplier.<ManyMapKey<?, ?>, Object>get());
|
||||
public static SlicedMapImpl create(MapSupplier mapSupplier) {
|
||||
return new SlicedMapImpl(mapSupplier.<SlicedMapKey<?, ?>, Object>get());
|
||||
}
|
||||
|
||||
private final Map<ManyMapKey<?, ?>, Object> map;
|
||||
private final Map<SlicedMapKey<?, ?>, Object> map;
|
||||
|
||||
private ManyMapImpl(Map<ManyMapKey<?, ?>, Object> map) {
|
||||
private SlicedMapImpl(Map<SlicedMapKey<?, ?>, Object> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@@ -33,25 +33,25 @@ public class ManyMapImpl implements MutableManyMap {
|
||||
if (!slice.check(key, value)) {
|
||||
return;
|
||||
}
|
||||
ManyMapKey<K, V> manyMapKey = slice.makeKey(key);
|
||||
SlicedMapKey<K, V> slicedMapKey = slice.makeKey(key);
|
||||
if (slice.getRewritePolicy().rewriteProcessingNeeded(key)) {
|
||||
if (map.containsKey(manyMapKey)) {
|
||||
if (map.containsKey(slicedMapKey)) {
|
||||
//noinspection unchecked
|
||||
if (!slice.getRewritePolicy().processRewrite(slice, key, (V) map.get(manyMapKey), value)) {
|
||||
if (!slice.getRewritePolicy().processRewrite(slice, key, (V) map.get(slicedMapKey), value)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put(manyMapKey, value);
|
||||
map.put(slicedMapKey, value);
|
||||
slice.afterPut(this, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||
ManyMapKey<K, V> manyMapKey = slice.makeKey(key);
|
||||
SlicedMapKey<K, V> slicedMapKey = slice.makeKey(key);
|
||||
//noinspection unchecked
|
||||
V value = (V) map.get(manyMapKey);
|
||||
return slice.computeValue(this, key, value, value == null && !map.containsKey(manyMapKey));
|
||||
V value = (V) map.get(slicedMapKey);
|
||||
return slice.computeValue(this, key, value, value == null && !map.containsKey(slicedMapKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +66,7 @@ public class ManyMapImpl implements MutableManyMap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Map.Entry<ManyMapKey<?, ?>, ?>> iterator() {
|
||||
public Iterator<Map.Entry<SlicedMapKey<?, ?>, ?>> iterator() {
|
||||
//noinspection unchecked
|
||||
return (Iterator) map.entrySet().iterator();
|
||||
}
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public final class ManyMapKey<K, V> {
|
||||
public final class SlicedMapKey<K, V> {
|
||||
|
||||
private final WritableSlice<K, V> slice;
|
||||
private final K key;
|
||||
|
||||
public ManyMapKey(@NotNull WritableSlice<K, V> slice, K key) {
|
||||
public SlicedMapKey(@NotNull WritableSlice<K, V> slice, K key) {
|
||||
this.slice = slice;
|
||||
this.key = key;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public final class ManyMapKey<K, V> {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ManyMapKey that = (ManyMapKey) o;
|
||||
SlicedMapKey that = (SlicedMapKey) o;
|
||||
|
||||
if (key != null ? !key.equals(that.key) : that.key != null) return false;
|
||||
if (!slice.equals(that.slice)) return false;
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class ManyMapSlices {
|
||||
public class Slices {
|
||||
|
||||
public static final RewritePolicy ONLY_REWRITE_TO_EQUAL = new RewritePolicy() {
|
||||
@Override
|
||||
@@ -88,7 +88,7 @@ public class ManyMapSlices {
|
||||
if (defaultValue != null) {
|
||||
return new SliceWithOpposite<K, V>(debugName, rewritePolicy, opposite, keyNormalizer) {
|
||||
@Override
|
||||
public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) {
|
||||
public V computeValue(SlicedMap map, K key, V value, boolean valueNotFound) {
|
||||
if (valueNotFound) return defaultValue;
|
||||
return super.computeValue(map, key, value, valueNotFound);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class ManyMapSlices {
|
||||
if (furtherLookupSlices != null) {
|
||||
return new SliceWithOpposite<K, V>(debugName, rewritePolicy, opposite, keyNormalizer) {
|
||||
@Override
|
||||
public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) {
|
||||
public V computeValue(SlicedMap map, K key, V value, boolean valueNotFound) {
|
||||
if (valueNotFound) {
|
||||
for (ReadOnlySlice<K, V> slice : furtherLookupSlices) {
|
||||
if (map.containsKey(slice, key)) {
|
||||
@@ -143,13 +143,13 @@ public class ManyMapSlices {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPut(MutableManyMap manyMap, K key, V value) {
|
||||
public void afterPut(MutableSlicedMap map, K key, V value) {
|
||||
if (opposite != null) {
|
||||
manyMap.put(opposite, value, key);
|
||||
map.put(opposite, value, key);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ManyMapKey<K, V> makeKey(K key) {
|
||||
public SlicedMapKey<K, V> makeKey(K key) {
|
||||
if (keyNormalizer == null) {
|
||||
return super.makeKey(key);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class ManyMapSlices {
|
||||
super(debugName, rewritePolicy);
|
||||
}
|
||||
@Override
|
||||
public Boolean computeValue(ManyMap map, K key, Boolean value, boolean valueNotFound) {
|
||||
public Boolean computeValue(SlicedMap map, K key, Boolean value, boolean valueNotFound) {
|
||||
if (valueNotFound) return false;
|
||||
return super.computeValue(map, key, value, valueNotFound);
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jet.util;
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -7,7 +7,7 @@ public interface WritableSlice<K, V> extends ReadOnlySlice<K, V> {
|
||||
// True to put, false to skip
|
||||
boolean check(K key, V value);
|
||||
|
||||
void afterPut(MutableManyMap manyMap, K key, V value);
|
||||
void afterPut(MutableSlicedMap map, K key, V value);
|
||||
|
||||
RewritePolicy getRewritePolicy();
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import org.jetbrains.jet.lang.JetDiagnostic;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.WritableSlice;
|
||||
import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user