From d719222bc4176e2b0aa8554aa5ff86fc634afe22 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 28 Mar 2014 19:30:58 +0400 Subject: [PATCH] Delete CommonSuppliers, use Guava directly --- .../autocasts/DelegatingDataFlowInfo.java | 7 +- .../jet/lang/types/SubstitutionUtils.java | 4 +- .../jet/util/slicedmap/SlicedMapImpl.java | 6 +- .../resolve/scopes/WritableScopeImpl.java | 5 +- .../jetbrains/jet/utils/CommonSuppliers.java | 68 ------------------- .../jet/plugin/libraries/MemberMatching.java | 8 +-- 6 files changed, 11 insertions(+), 87 deletions(-) delete mode 100644 core/util.runtime/src/org/jetbrains/jet/utils/CommonSuppliers.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java index 7a4879ce141..f6e062b7657 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DelegatingDataFlowInfo.java @@ -21,9 +21,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.types.JetType; 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; @@ -228,8 +228,7 @@ import static org.jetbrains.jet.lang.resolve.calls.autocasts.Nullability.NOT_NUL @NotNull /* package */ static SetMultimap newTypeInfo() { - return Multimaps.newSetMultimap(Maps.>newHashMap(), - CommonSuppliers.getLinkedHashSetSupplier()); + return LinkedHashMultimap.create(); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/SubstitutionUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/SubstitutionUtils.java index 02daaeda178..cd1c66315d5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/SubstitutionUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/SubstitutionUtils.java @@ -16,13 +16,13 @@ package org.jetbrains.jet.lang.types; +import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; -import org.jetbrains.jet.utils.CommonSuppliers; import java.util.List; import java.util.Map; @@ -58,7 +58,7 @@ public class SubstitutionUtils { */ @NotNull public static Multimap buildDeepSubstitutionMultimap(@NotNull JetType type) { - Multimap fullSubstitution = CommonSuppliers.newLinkedHashSetHashSetMultimap(); + Multimap fullSubstitution = LinkedHashMultimap.create(); Map substitution = Maps.newHashMap(); TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution); // we use the mutability of the map here diff --git a/compiler/frontend/src/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.java b/compiler/frontend/src/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.java index 7a9a7db2b28..e5e3e0aee1b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/util/slicedmap/SlicedMapImpl.java @@ -16,15 +16,13 @@ package org.jetbrains.jet.util.slicedmap; +import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.utils.CommonSuppliers; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -43,7 +41,7 @@ public class SlicedMapImpl implements MutableSlicedMap { } private final Map, Object> map; - private final Multimap, Object> collectiveSliceKeys = Multimaps.newListMultimap(new HashMap, Collection>(), CommonSuppliers.getArrayListSupplier()); + private final Multimap, Object> collectiveSliceKeys = ArrayListMultimap.create(); protected SlicedMapImpl(Map, Object> map) { this.map = map; diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java index 58acf973f4f..a944d1a07b3 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java @@ -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.Name; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; -import org.jetbrains.jet.utils.CommonSuppliers; import org.jetbrains.jet.utils.Printer; import java.util.*; @@ -256,7 +255,7 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull private SetMultimap getPropertyGroups() { if (propertyGroups == null) { - propertyGroups = CommonSuppliers.newLinkedHashSetHashSetMultimap(); + propertyGroups = LinkedHashMultimap.create(); } return propertyGroups; } @@ -264,7 +263,7 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull private SetMultimap getFunctionGroups() { if (functionGroups == null) { - functionGroups = CommonSuppliers.newLinkedHashSetHashSetMultimap(); + functionGroups = LinkedHashMultimap.create(); } return functionGroups; } diff --git a/core/util.runtime/src/org/jetbrains/jet/utils/CommonSuppliers.java b/core/util.runtime/src/org/jetbrains/jet/utils/CommonSuppliers.java deleted file mode 100644 index 8987f70743b..00000000000 --- a/core/util.runtime/src/org/jetbrains/jet/utils/CommonSuppliers.java +++ /dev/null @@ -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 Supplier> getArrayListSupplier() { - //noinspection unchecked - return (Supplier>) ARRAY_LIST_SUPPLIER; - } - - public static Supplier> getLinkedHashSetSupplier() { - //noinspection unchecked - return (Supplier>) LINKED_HASH_SET_SUPPLIER; - } - - public static Supplier> getHashSetSupplier() { - //noinspection unchecked - return (Supplier>) HASH_SET_SUPPLIER; - } - - public static SetMultimap newLinkedHashSetHashSetMultimap() { - return Multimaps.newSetMultimap(Maps.>newHashMap(), CommonSuppliers.getLinkedHashSetSupplier()); - } -} diff --git a/idea/src/org/jetbrains/jet/plugin/libraries/MemberMatching.java b/idea/src/org/jetbrains/jet/plugin/libraries/MemberMatching.java index fa037a8c598..3af25388f2d 100644 --- a/idea/src/org/jetbrains/jet/plugin/libraries/MemberMatching.java +++ b/idea/src/org/jetbrains/jet/plugin/libraries/MemberMatching.java @@ -16,9 +16,8 @@ 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.Multimaps; import com.google.common.collect.Sets; import com.intellij.util.Function; 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.lexer.JetTokens; import org.jetbrains.jet.renderer.DescriptorRenderer; -import org.jetbrains.jet.utils.CommonSuppliers; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; @@ -198,8 +195,7 @@ public class MemberMatching { return false; } - Multimap decompiledParameterToBounds = Multimaps.newSetMultimap( - Maps.>newHashMap(), CommonSuppliers.getHashSetSupplier()); + Multimap decompiledParameterToBounds = HashMultimap.create(); for (JetTypeParameter parameter : decompiledParameters) { JetTypeReference extendsBound = parameter.getExtendsBound(); if (extendsBound != null) {