Remove deprecated usages of ContainerUtil

This commit is contained in:
Alexander Udalov
2020-08-13 18:29:18 +02:00
parent 2428c180c2
commit 0ef4b22cf3
11 changed files with 32 additions and 35 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.cli.common.messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -25,6 +24,7 @@ import java.io.File;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
public class OutputMessageUtil {
@@ -69,7 +69,7 @@ public class OutputMessageUtil {
}
private static Collection<File> parseSourceFiles(String[] strings, int start) {
Collection<File> sourceFiles = ContainerUtil.newArrayList();
Collection<File> sourceFiles = new ArrayList<>();
for (int i = start; i < strings.length; i++) {
sourceFiles.add(new File(strings[i]));
}
@@ -16,13 +16,13 @@
package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.containers.StringInterner
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.load.java.structure.JavaClassifierType
import org.jetbrains.kotlin.load.java.structure.JavaType
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addToStdlib.flattenTo
import org.jetbrains.kotlin.utils.compact
import org.jetbrains.org.objectweb.asm.Type
@@ -44,7 +44,7 @@ class BinaryClassSignatureParser {
return emptyList()
}
val typeParameters = ContainerUtil.newArrayList<JavaTypeParameter>()
val typeParameters = arrayListOf<JavaTypeParameter>()
signature.next()
while (signature.current() != '>') {
typeParameters.add(parseTypeParameter(signature, context))
@@ -65,7 +65,7 @@ class BinaryClassSignatureParser {
val parameterName = name.toString()
// postpone list allocation till a second bound is seen; ignore sole Object bound
val bounds: MutableList<JavaClassifierType> = ContainerUtil.newSmartList()
val bounds: MutableList<JavaClassifierType> = SmartList()
while (signature.current() == ':') {
signature.next()
val bound = parseClassifierRefSignature(signature, context) ?: continue
@@ -110,7 +110,7 @@ class BinaryClassSignatureParser {
): JavaClassifierType {
val canonicalName = StringBuilder()
val argumentGroups = ContainerUtil.newSmartList<List<JavaType>>()
val argumentGroups = SmartList<List<JavaType>>()
signature.next()
while (signature.current() != ';' && signature.current() != CharacterIterator.DONE) {
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.search.SearchScope
import com.intellij.util.containers.ContainerUtil
import gnu.trove.THashMap
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.load.java.structure.impl.VirtualFileBoundJavaClass
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.org.objectweb.asm.*
import java.text.CharacterIterator
@@ -41,7 +41,7 @@ class BinaryJavaClass(
) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MapBasedJavaAnnotationOwner {
private lateinit var myInternalName: String
override val annotations: MutableCollection<JavaAnnotation> = ContainerUtil.newSmartList()
override val annotations: MutableCollection<JavaAnnotation> = SmartList()
override lateinit var typeParameters: List<JavaTypeParameter>
override lateinit var supertypes: Collection<JavaClassifierType>
override val methods = arrayListOf<JavaMethod>()
@@ -150,7 +150,7 @@ class BinaryJavaClass(
.parseTypeParametersDeclaration(iterator, context)
.also(context::addTypeParameters)
val supertypes = ContainerUtil.newSmartList<JavaClassifierType>()
val supertypes = SmartList<JavaClassifierType>()
supertypes.addIfNotNull(signatureParser.parseClassifierRefSignature(iterator, context))
while (iterator.current() != CharacterIterator.DONE) {
supertypes.addIfNotNull(signatureParser.parseClassifierRefSignature(iterator, context))
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import com.intellij.util.cls.ClsFormatException
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.compact
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
@@ -37,7 +37,7 @@ abstract class BinaryJavaMethodBase(
) : JavaMember, MapBasedJavaAnnotationOwner, BinaryJavaModifierListOwner {
override val annotationsByFqName by buildLazyValueForMap()
override val annotations: Collection<JavaAnnotation> = ContainerUtil.newSmartList()
override val annotations: Collection<JavaAnnotation> = SmartList()
companion object {
private class MethodInfo(
@@ -80,13 +80,10 @@ abstract class BinaryJavaMethodBase(
}
val parameterTypes = info.valueParameterTypes
val parameterList = ContainerUtil.newArrayList<BinaryJavaValueParameter>()
val paramCount = parameterTypes.size
for (i in 0 until paramCount) {
val type = parameterTypes[i]
val parameterList = parameterTypes.mapIndexed { i, type ->
val isEllipsisParam = isVarargs && i == paramCount - 1
parameterList.add(BinaryJavaValueParameter(type, isEllipsisParam))
BinaryJavaValueParameter(type, isEllipsisParam)
}
val member: BinaryJavaMethodBase =
@@ -95,7 +92,7 @@ abstract class BinaryJavaMethodBase(
else
BinaryJavaMethod(
access, containingClass,
parameterList.compact(),
parameterList,
info.typeParameters,
Name.identifier(name), info.returnType
)
@@ -142,7 +139,7 @@ abstract class BinaryJavaMethodBase(
paramTypes = emptyList()
}
else {
paramTypes = ContainerUtil.newArrayList()
paramTypes = mutableListOf()
while (iterator.current() != ')' && iterator.current() != CharacterIterator.DONE) {
paramTypes.add(signatureParser.parseTypeString(iterator, context))
}
@@ -16,10 +16,10 @@
package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassVisitor
@@ -31,7 +31,7 @@ class BinaryJavaField(
override val type: JavaType,
override val initializerValue: Any?
) : JavaField, MapBasedJavaAnnotationOwner, BinaryJavaModifierListOwner {
override val annotations: MutableCollection<JavaAnnotation> = ContainerUtil.newSmartList()
override val annotations: MutableCollection<JavaAnnotation> = SmartList()
override val annotationsByFqName by buildLazyValueForMap()
override val hasConstantNotNullInitializer: Boolean
@@ -53,7 +53,7 @@ class BinaryJavaValueParameter(
override val type: JavaType,
override val isVararg: Boolean
) : JavaValueParameter, MapBasedJavaAnnotationOwner {
override val annotations: MutableCollection<JavaAnnotation> = ContainerUtil.newSmartList()
override val annotations: MutableCollection<JavaAnnotation> = SmartList()
override val annotationsByFqName by buildLazyValueForMap()
override var name: Name? = null
@@ -16,10 +16,10 @@
package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
// They are only used for java class files, but potentially may be used in other cases
@@ -47,7 +47,7 @@ internal class PlainJavaClassifierType(
internal fun addAnnotation(annotation: JavaAnnotation) {
if (_annotations.isEmpty()) {
_annotations = ContainerUtil.newSmartList()
_annotations = SmartList()
}
(_annotations as MutableList).add(annotation)
@@ -5,12 +5,12 @@
package org.jetbrains.kotlin.checkers
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.checkers.diagnostics.TextDiagnostic
import org.jetbrains.kotlin.utils.SmartList
class DiagnosedRange constructor(val start: Int) {
var end: Int = 0
private val diagnostics = ContainerUtil.newSmartList<TextDiagnostic>()
private val diagnostics = SmartList<TextDiagnostic>()
fun getDiagnostics(): List<TextDiagnostic> {
return diagnostics
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.resolve.calls.callResolverUtil
import com.google.common.collect.Lists
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.builtins.isSuspendFunctionType
@@ -38,6 +37,7 @@ import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import org.jetbrains.kotlin.types.typeUtil.contains
import org.jetbrains.kotlin.utils.SmartList
enum class ResolveArgumentsMode {
RESOLVE_FUNCTION_ARGUMENTS,
@@ -108,7 +108,7 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
receiverType = TypeIntersector.intersectUpperBounds(typeParameter, properUpperBounds)
}
}
val fakeTypeArguments = ContainerUtil.newSmartList<TypeProjection>()
val fakeTypeArguments = SmartList<TypeProjection>()
for (typeProjection in receiverType.arguments) {
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.projectionKind, DONT_CARE))
}
@@ -19,8 +19,8 @@ import com.intellij.psi.scope.NameHint
import com.intellij.psi.scope.PsiScopeProcessor
import com.intellij.psi.util.CachedValueProvider
import com.intellij.util.ArrayUtil
import com.intellij.util.containers.ContainerUtil
import gnu.trove.THashMap
import org.jetbrains.kotlin.utils.SmartList
import java.util.concurrent.TimeUnit
import java.util.concurrent.locks.ReentrantLock
@@ -176,17 +176,17 @@ class KotlinClassInnerStuffCache(val myClass: PsiExtensibleClass, externalDepend
val methods = this.methods
if (methods.isEmpty()) return emptyMap()
val collectedMethods = ContainerUtil.newHashMap<String, MutableList<PsiMethod>>()
val collectedMethods = hashMapOf<String, MutableList<PsiMethod>>()
for (method in methods) {
var list: MutableList<PsiMethod>? = collectedMethods[method.name]
if (list == null) {
list = ContainerUtil.newSmartList()
list = SmartList()
collectedMethods[method.name] = list
}
list.add(method)
}
val cachedMethods = ContainerUtil.newTroveMap<String, Array<PsiMethod>>()
val cachedMethods = THashMap<String, Array<PsiMethod>>()
for ((key, list) in collectedMethods) {
cachedMethods[key] = list.toTypedArray()
}
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.lexer.KtTokens;
@@ -29,6 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -54,7 +54,7 @@ public class KtPackageDirective extends KtModifierListOwnerStub<KotlinPlaceHolde
KtExpression nameExpression = getPackageNameExpression();
if (nameExpression == null) return Collections.emptyList();
List<KtSimpleNameExpression> packageNames = ContainerUtil.newArrayList();
List<KtSimpleNameExpression> packageNames = new ArrayList<>();
while (nameExpression instanceof KtQualifiedExpression) {
KtQualifiedExpression qualifiedExpression = (KtQualifiedExpression) nameExpression;
@@ -608,7 +608,7 @@ public class KotlinTestUtils {
}
assert lastChild != null;
List<String> comments = ContainerUtil.newArrayList();
List<String> comments = new ArrayList<>();
while (true) {
if (lastChild.getNode().getElementType().equals(KtTokens.BLOCK_COMMENT)) {
@@ -1006,7 +1006,7 @@ public class KotlinTestUtils {
}
private static Set<String> collectPathsMetadata(Class<?> testCaseClass) {
return ContainerUtil.newHashSet(ContainerUtil.map(collectMethodsMetadata(testCaseClass), KotlinTestUtils::nameToCompare));
return new HashSet<>(ContainerUtil.map(collectMethodsMetadata(testCaseClass), KotlinTestUtils::nameToCompare));
}
@Nullable