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