Delete CommonSuppliers, use Guava directly

This commit is contained in:
Alexander Udalov
2014-03-28 19:30:58 +04:00
parent 7c4079fd32
commit d719222bc4
6 changed files with 11 additions and 87 deletions
@@ -21,9 +21,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.utils.CommonSuppliers;
import java.util.*; import java.util.Map;
import java.util.Set;
import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NULL; import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NULL;
@@ -228,8 +228,7 @@ import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NUL
@NotNull @NotNull
/* package */ static SetMultimap<DataFlowValue, JetType> newTypeInfo() { /* package */ static SetMultimap<DataFlowValue, JetType> newTypeInfo() {
return Multimaps.newSetMultimap(Maps.<DataFlowValue, Collection<JetType>>newHashMap(), return LinkedHashMultimap.create();
CommonSuppliers.<JetType>getLinkedHashSetSupplier());
} }
@Override @Override
@@ -16,13 +16,13 @@
package org.jetbrains.jet.lang.types; package org.jetbrains.jet.lang.types;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
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.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.utils.CommonSuppliers;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -58,7 +58,7 @@ public class SubstitutionUtils {
*/ */
@NotNull @NotNull
public static Multimap<TypeConstructor, TypeProjection> buildDeepSubstitutionMultimap(@NotNull JetType type) { public static Multimap<TypeConstructor, TypeProjection> buildDeepSubstitutionMultimap(@NotNull JetType type) {
Multimap<TypeConstructor, TypeProjection> fullSubstitution = CommonSuppliers.newLinkedHashSetHashSetMultimap(); Multimap<TypeConstructor, TypeProjection> fullSubstitution = LinkedHashMultimap.create();
Map<TypeConstructor, TypeProjection> substitution = Maps.newHashMap(); Map<TypeConstructor, TypeProjection> substitution = Maps.newHashMap();
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution); TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
// we use the mutability of the map here // we use the mutability of the map here
@@ -16,15 +16,13 @@
package org.jetbrains.jet.util.slicedmap; package org.jetbrains.jet.util.slicedmap;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.utils.CommonSuppliers;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@@ -43,7 +41,7 @@ public class SlicedMapImpl implements MutableSlicedMap {
} }
private final Map<SlicedMapKey<?, ?>, Object> map; private final Map<SlicedMapKey<?, ?>, Object> map;
private final Multimap<WritableSlice<?, ?>, Object> collectiveSliceKeys = Multimaps.newListMultimap(new HashMap<WritableSlice<?, ?>, Collection<Object>>(), CommonSuppliers.getArrayListSupplier()); private final Multimap<WritableSlice<?, ?>, Object> collectiveSliceKeys = ArrayListMultimap.create();
protected SlicedMapImpl(Map<SlicedMapKey<?, ?>, Object> map) { protected SlicedMapImpl(Map<SlicedMapKey<?, ?>, Object> map) {
this.map = map; this.map = map;
@@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.name.LabelName; import org.jetbrains.jet.lang.resolve.name.LabelName;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.utils.CommonSuppliers;
import org.jetbrains.jet.utils.Printer; import org.jetbrains.jet.utils.Printer;
import java.util.*; import java.util.*;
@@ -256,7 +255,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@NotNull @NotNull
private SetMultimap<Name, VariableDescriptor> getPropertyGroups() { private SetMultimap<Name, VariableDescriptor> getPropertyGroups() {
if (propertyGroups == null) { if (propertyGroups == null) {
propertyGroups = CommonSuppliers.newLinkedHashSetHashSetMultimap(); propertyGroups = LinkedHashMultimap.create();
} }
return propertyGroups; return propertyGroups;
} }
@@ -264,7 +263,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@NotNull @NotNull
private SetMultimap<Name, FunctionDescriptor> getFunctionGroups() { private SetMultimap<Name, FunctionDescriptor> getFunctionGroups() {
if (functionGroups == null) { if (functionGroups == null) {
functionGroups = CommonSuppliers.newLinkedHashSetHashSetMultimap(); functionGroups = LinkedHashMultimap.create();
} }
return functionGroups; return functionGroups;
} }
@@ -1,68 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.utils;
import com.google.common.base.Supplier;
import com.google.common.collect.*;
import java.util.Collection;
import java.util.List;
import java.util.Set;
public class CommonSuppliers {
private CommonSuppliers() {}
private static final Supplier<?> ARRAY_LIST_SUPPLIER = new Supplier() {
@Override
public List get() {
return Lists.newArrayList();
}
};
private static final Supplier<?> LINKED_HASH_SET_SUPPLIER = new Supplier() {
@Override
public Set get() {
return Sets.newLinkedHashSet();
}
};
private static final Supplier<?> HASH_SET_SUPPLIER = new Supplier() {
@Override
public Set get() {
return Sets.newHashSet();
}
};
public static <T> Supplier<List<T>> getArrayListSupplier() {
//noinspection unchecked
return (Supplier<List<T>>) ARRAY_LIST_SUPPLIER;
}
public static <T> Supplier<Set<T>> getLinkedHashSetSupplier() {
//noinspection unchecked
return (Supplier<Set<T>>) LINKED_HASH_SET_SUPPLIER;
}
public static <T> Supplier<Set<T>> getHashSetSupplier() {
//noinspection unchecked
return (Supplier<Set<T>>) HASH_SET_SUPPLIER;
}
public static <K, V> SetMultimap<K, V> newLinkedHashSetHashSetMultimap() {
return Multimaps.newSetMultimap(Maps.<K, Collection<V>>newHashMap(), CommonSuppliers.<V>getLinkedHashSetSupplier());
}
}
@@ -16,9 +16,8 @@
package org.jetbrains.jet.plugin.libraries; package org.jetbrains.jet.plugin.libraries;
import com.google.common.collect.Maps; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.intellij.util.Function; import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtil;
@@ -34,9 +33,7 @@ import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.renderer.DescriptorRenderer; import org.jetbrains.jet.renderer.DescriptorRenderer;
import org.jetbrains.jet.utils.CommonSuppliers;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -198,8 +195,7 @@ public class MemberMatching {
return false; return false;
} }
Multimap<Name, String> decompiledParameterToBounds = Multimaps.newSetMultimap( Multimap<Name, String> decompiledParameterToBounds = HashMultimap.create();
Maps.<Name, Collection<String>>newHashMap(), CommonSuppliers.<String>getHashSetSupplier());
for (JetTypeParameter parameter : decompiledParameters) { for (JetTypeParameter parameter : decompiledParameters) {
JetTypeReference extendsBound = parameter.getExtendsBound(); JetTypeReference extendsBound = parameter.getExtendsBound();
if (extendsBound != null) { if (extendsBound != null) {