Replace the trove4j collections usages with the fastutil ones

The trove4j library is licensed under LGPL, and that causes some troubles while working with it. The fastutil library provides the same functionality in the context of our needs, and is licensed under the Apache license.
^KTI-1135 In Progress
This commit is contained in:
Alexander.Likhachev
2023-12-06 12:48:36 +01:00
committed by Space Team
parent dd5fffebf2
commit 21b438f55d
27 changed files with 71 additions and 86 deletions
@@ -19,7 +19,7 @@ import com.intellij.psi.util.MethodSignatureBackedByPsiMethod
import com.intellij.psi.util.PsiUtil
import com.intellij.util.ArrayUtil
import com.intellij.util.IncorrectOperationException
import gnu.trove.THashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import org.jetbrains.kotlin.asJava.builder.LightMemberOrigin
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
import org.jetbrains.kotlin.asJava.elements.KtLightParameter
@@ -84,7 +84,7 @@ class KotlinClassInnerStuffCache(
private val fieldByNameCache = cache {
val fields = this.fields.takeIf { it.isNotEmpty() } ?: return@cache emptyMap()
Collections.unmodifiableMap(THashMap<String, PsiField>(fields.size).apply {
Collections.unmodifiableMap(Object2ObjectOpenHashMap<String, PsiField>(fields.size).apply {
for (field in fields) {
putIfAbsent(field.name, field)
}
@@ -101,7 +101,7 @@ class KotlinClassInnerStuffCache(
private val methodByNameCache = cache {
val methods = this.methods.takeIf { it.isNotEmpty() } ?: return@cache emptyMap()
Collections.unmodifiableMap(THashMap<String, Array<PsiMethod>>().apply {
Collections.unmodifiableMap(Object2ObjectOpenHashMap<String, Array<PsiMethod>>().apply {
for ((key, list) in methods.groupByTo(HashMap()) { it.name }) {
put(key, list.toTypedArray())
}
@@ -119,7 +119,7 @@ class KotlinClassInnerStuffCache(
private val innerClassByNameCache = cache {
val classes = this.innerClasses.takeIf { it.isNotEmpty() } ?: return@cache emptyMap()
Collections.unmodifiableMap(THashMap<String, PsiClass>().apply {
Collections.unmodifiableMap(Object2ObjectOpenHashMap<String, PsiClass>().apply {
for (psiClass in classes) {
val name = psiClass.name
if (name == null) {