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
+1 -1
View File
@@ -12,7 +12,7 @@ dependencies {
api(project(":core:compiler.common.jvm"))
implementation(project(":analysis:project-structure"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
}
sourceSets {
@@ -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) {
+1 -1
View File
@@ -21,7 +21,7 @@ dependencies {
compileOnly(toolsJarApi())
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.search.GlobalSearchScope
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndex
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
@@ -51,7 +51,7 @@ class CliVirtualFileFinder(
}
override fun findMetadataTopLevelClassesInPackage(packageFqName: FqName): Set<String> {
val result = THashSet<String>()
val result = ObjectOpenHashSet<String>()
index.traverseDirectoriesInPackage(packageFqName, continueSearch = { dir, _ ->
for (child in dir.children) {
if (child.extension == MetadataPackageFragment.METADATA_FILE_EXTENSION) {
@@ -23,8 +23,8 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.*
import com.intellij.psi.impl.file.PsiPackageImpl
import com.intellij.psi.search.GlobalSearchScope
import gnu.trove.THashMap
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndex
import org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex
@@ -50,7 +50,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
private lateinit var index: JvmDependenciesIndex
private lateinit var singleJavaFileRootsIndex: SingleJavaFileRootsIndex
private lateinit var packagePartProviders: List<JvmPackagePartProvider>
private val topLevelClassesCache: MutableMap<FqName, VirtualFile?> = THashMap()
private val topLevelClassesCache: MutableMap<FqName, VirtualFile?> = Object2ObjectOpenHashMap()
private val allScope = GlobalSearchScope.allScope(myPsiManager.project)
private var usePsiClassFilesReading = false
@@ -96,7 +96,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
}?.takeIf { it in searchScope }
}
private val binaryCache: MutableMap<ClassId, JavaClass?> = THashMap()
private val binaryCache: MutableMap<ClassId, JavaClass?> = Object2ObjectOpenHashMap()
private val signatureParsingComponent = BinaryClassSignatureParser()
fun findClass(classId: ClassId, searchScope: GlobalSearchScope) = findClass(JavaClassFinder.Request(classId), searchScope)
@@ -263,7 +263,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
}
override fun knownClassNamesInPackage(packageFqName: FqName): Set<String> {
val result = THashSet<String>()
val result = ObjectOpenHashSet<String>()
index.traverseDirectoriesInPackage(packageFqName, continueSearch = { dir, _ ->
for (child in dir.children) {
if (child.extension == "class" || child.extension == "java" || child.extension == "sig") {
@@ -9,7 +9,7 @@ import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import gnu.trove.THashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import java.util.*
@@ -58,7 +58,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>) : JvmDependenciesIndex {
override val indexedRoots by lazy { roots.asSequence() }
private val packageCache: Array<out MutableMap<String, VirtualFile?>> by lazy {
Array(roots.size) { THashMap<String, VirtualFile?>() }
Array(roots.size) { Object2ObjectOpenHashMap<String, VirtualFile?>() }
}
override fun traverseDirectoriesInPackage(
+1 -1
View File
@@ -9,7 +9,7 @@ dependencies {
compileOnly(project(":compiler:cli"))
compileOnly(project(":compiler:incremental-compilation-impl"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
runtimeOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false }
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.daemon
import gnu.trove.THashMap
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.kotlin.daemon.common.DummyProfiler
import org.jetbrains.kotlin.daemon.common.Profiler
import org.jetbrains.kotlin.daemon.common.withMeasure
@@ -35,7 +35,7 @@ class RemoteLookupTrackerClient(
private val isDoNothing = profiler.withMeasure(this) { facade.lookupTracker_isDoNothing() }
// Map: FileName -> (ScopeFqName -> Set<Name[String] | LookupInfo>)
private val lookups = THashMap<String, MutableMap<String, MutableSet<Any>>>()
private val lookups = Object2ObjectOpenHashMap<String, MutableMap<String, MutableSet<Any>>>()
private val interner = createStringInterner()
override val requiresPosition: Boolean = profiler.withMeasure(this) { facade.lookupTracker_requiresPosition() }
@@ -51,8 +51,7 @@ class RemoteLookupTrackerClient(
LookupInfo(filePath, position, scopeFqName, scopeKind, name)
else
internedName
lookups.getOrPut(filePath, ::THashMap).getOrPut(internedSymbolFqName, ::THashSet).add(objectToPut)
lookups.getOrPut(filePath, ::Object2ObjectOpenHashMap).getOrPut(internedSymbolFqName, ::ObjectOpenHashSet).add(objectToPut)
}
override fun clear() {
@@ -64,7 +63,7 @@ class RemoteLookupTrackerClient(
}
private fun flush() {
if (isDoNothing || lookups.isEmpty) return
if (isDoNothing || lookups.isEmpty()) return
profiler.withMeasure(this) {
facade.lookupTracker_record(
+1 -1
View File
@@ -17,7 +17,7 @@ dependencies {
api(project(":kotlin-script-runtime"))
api(commonDependency("io.javaslang","javaslang"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
compileOnly(libs.guava)
}
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.resolve.lazy
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.incremental.components.LookupLocation
@@ -257,7 +257,7 @@ class FileScopeFactory(
parentScope: ImportingScope
): ImportingScope {
val scope = packageView.memberScope
val names by lazy(LazyThreadSafetyMode.PUBLICATION) { scope.computeAllNames()?.let(::THashSet) }
val names by lazy(LazyThreadSafetyMode.PUBLICATION) { scope.computeAllNames()?.let(::ObjectOpenHashSet) }
val packageName = packageView.fqName
val excludedNames = aliasImportNames.mapNotNull { if (it.parent() == packageName) it.shortName() else null }
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.lazy
import com.google.common.collect.HashMultimap
import com.google.common.collect.ImmutableListMultimap
import com.google.common.collect.ListMultimap
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMapper
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
@@ -130,7 +130,7 @@ open class LazyImportResolver<I : KtImportInfo>(
}
val allNames: Set<Name>? by components.storageManager.createNullableLazyValue {
indexedImports.imports.asIterable().flatMapToNullable(THashSet()) { getImportScope(it).computeImportedNames() }
indexedImports.imports.asIterable().flatMapToNullable(ObjectOpenHashSet()) { getImportScope(it).computeImportedNames() }
}
fun definitelyDoesNotContainName(name: Name): Boolean {
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.types.expressions
import gnu.trove.THashSet
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.psi.KtLoopExpression
@@ -37,7 +37,7 @@ class PreliminaryLoopVisitor private constructor() : AssignedVariablesSearcher()
languageVersionSettings: LanguageVersionSettings
): DataFlowInfo {
var resultFlowInfo = dataFlowInfo
val nonTrivialValues = THashSet<DataFlowValue>().apply {
val nonTrivialValues = ObjectOpenHashSet<DataFlowValue>().apply {
addAll(dataFlowInfo.completeNullabilityInfo.iterator().map { it._1 })
addAll(dataFlowInfo.completeTypeInfo.iterator().map { it._1 })
}
+1 -1
View File
@@ -17,7 +17,7 @@ dependencies {
compileOnly(intellijCore())
compileOnly(libs.guava)
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
jflexPath(commonDependency("org.jetbrains.intellij.deps.jflex", "jflex"))
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.psi
import com.intellij.openapi.util.TextRange
import com.intellij.psi.LiteralTextEscaper
import gnu.trove.TIntArrayList
import it.unimi.dsi.fastutil.ints.IntArrayList
import org.jetbrains.kotlin.psi.psiUtil.getContentRange
import org.jetbrains.kotlin.psi.psiUtil.isSingleQuoted
import kotlin.math.min
@@ -27,7 +27,7 @@ class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : Literal
private var sourceOffsets: IntArray? = null
override fun decode(rangeInsideHost: TextRange, outChars: StringBuilder): Boolean {
val sourceOffsetsList = TIntArrayList()
val sourceOffsetsList = IntArrayList()
var sourceOffset = 0
for (child in myHost.entries) {
@@ -44,7 +44,7 @@ class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : Literal
//don't allow injection if its range starts or ends inside escaped sequence
//but still process offsets for the already decoded part
sourceOffsetsList.add(sourceOffset)
sourceOffsets = sourceOffsetsList.toNativeArray()
sourceOffsets = sourceOffsetsList.toIntArray()
return false
}
val unescaped = child.unescapedValue
@@ -64,7 +64,7 @@ class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : Literal
}
}
sourceOffsetsList.add(sourceOffset)
sourceOffsets = sourceOffsetsList.toNativeArray()
sourceOffsets = sourceOffsetsList.toIntArray()
return true
}
@@ -11,7 +11,7 @@ dependencies {
implementation(commonDependency("io.javaslang","javaslang"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
compileOnly(libs.guava)
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.search.SearchScope
import gnu.trove.THashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.load.java.structure.impl.VirtualFileBoundJavaClass
@@ -64,7 +64,7 @@ class BinaryJavaClass(
// Short name of a nested class of this class -> access flags as seen in the InnerClasses attribute value.
// Note that it doesn't include classes mentioned in other InnerClasses attribute values (those which are not nested in this class).
private val ownInnerClassNameToAccess: MutableMap<Name, Int> = THashMap()
private val ownInnerClassNameToAccess: MutableMap<Name, Int> = Object2ObjectOpenHashMap()
override val innerClassNames get() = ownInnerClassNameToAccess.keys
+1 -1
View File
@@ -8,7 +8,7 @@ dependencies {
api(project(":core:descriptors"))
api(project(":compiler:resolution.common"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
}
sourceSets {
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.resolve.calls.results
import gnu.trove.THashSet
import gnu.trove.TObjectHashingStrategy
import it.unimi.dsi.fastutil.Hash
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.builtins.UnsignedTypes
@@ -26,9 +26,7 @@ import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor
import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides
import org.jetbrains.kotlin.resolve.OverridingUtil
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
import org.jetbrains.kotlin.resolve.descriptorUtil.getKotlinTypeRefiner
import org.jetbrains.kotlin.resolve.descriptorUtil.isTypeRefinementEnabled
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
@@ -55,15 +53,14 @@ open class OverloadingConflictResolver<C : Any>(
private val isTypeRefinementEnabled by lazy { module.isTypeRefinementEnabled() }
private val resolvedCallHashingStrategy = object : TObjectHashingStrategy<C> {
private val resolvedCallHashingStrategy = object : Hash.Strategy<C> {
override fun equals(call1: C?, call2: C?): Boolean =
if (call1 != null && call2 != null)
call1.resultingDescriptor == call2.resultingDescriptor
else
call1 == call2
override fun computeHashCode(call: C?): Int =
call?.resultingDescriptor?.hashCode() ?: 0
override fun hashCode(call: C?): Int = call?.resultingDescriptor?.hashCode() ?: 0
}
private val C.resultingDescriptor: CallableDescriptor get() = getResultingDescriptor(this)
@@ -459,10 +456,10 @@ open class OverloadingConflictResolver<C : Any>(
// Different smart casts may lead to the same candidate descriptor wrapped into different ResolvedCallImpl objects
private fun uniquifyCandidatesSet(candidates: Collection<C>): Set<C> =
THashSet(candidates.size, resolvedCallHashingStrategy).apply { addAll(candidates) }
ObjectOpenCustomHashSet(candidates.size, resolvedCallHashingStrategy).apply { addAll(candidates) }
private fun newResolvedCallSet(expectedSize: Int): MutableSet<C> =
THashSet(expectedSize, resolvedCallHashingStrategy)
ObjectOpenCustomHashSet(expectedSize, resolvedCallHashingStrategy)
private fun FlatSignature<C>.candidateDescriptor() =
origin.resultingDescriptor.original
-1
View File
@@ -77,7 +77,6 @@ dependencies {
testApi(intellijJavaRt()) // for FileComparisonFailure
testImplementation(libs.guava)
testImplementation(commonDependency("org.jetbrains.intellij.deps:trove4j"))
testImplementation(commonDependency("org.jetbrains.intellij.deps:asm-all"))
testImplementation(commonDependency("org.jetbrains.intellij.deps:log4j"))
testImplementation(commonDependency("org.jetbrains.intellij.deps:jdom"))
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.test.testFramework
fun interface Equality<T> {
fun equals(o1: T, o2: T): Boolean
}
@@ -27,8 +27,7 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.PeekableIterator;
import com.intellij.util.containers.PeekableIteratorWrapper;
import com.intellij.util.lang.CompoundRuntimeException;
import gnu.trove.Equality;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.jetbrains.annotations.Contract;
@@ -385,8 +384,8 @@ public abstract class KtUsefulTestCase extends TestCase {
final StringBuilder builder = new StringBuilder();
for (final Object o : collection) {
if (o instanceof THashSet) {
builder.append(new TreeSet<>((THashSet<?>)o));
if (o instanceof ObjectOpenHashSet) {
builder.append(new TreeSet<>((ObjectOpenHashSet<?>)o));
}
else {
builder.append(o);
@@ -439,7 +438,12 @@ public abstract class KtUsefulTestCase extends TestCase {
public static <T> void assertOrderedEquals(@NotNull String errorMsg,
@NotNull Iterable<? extends T> actual,
@NotNull Iterable<? extends T> expected) {
assertOrderedEquals(errorMsg, actual, expected, Equality.CANONICAL);
assertOrderedEquals(errorMsg, actual, expected, new Equality<T>() {
@Override
public boolean equals(T o1, T o2) {
return Objects.equals(o1, o2);
}
});
}
public static <T> void assertOrderedEquals(@NotNull String errorMsg,
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
dependencies {
api(project(":core:descriptors"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
}
sourceSets {
@@ -4,7 +4,7 @@
package org.jetbrains.kotlin.js.backend;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.Collections;
import java.util.Set;
@@ -142,7 +142,7 @@ public class JsReservedIdentifiers {
"$stack", "$stackDepth", "$location",
};
reservedGlobalSymbols = new THashSet<String>(commonBuiltins.length);
reservedGlobalSymbols = new ObjectOpenHashSet<>(commonBuiltins.length);
Collections.addAll(reservedGlobalSymbols, commonBuiltins);
}
@@ -4,6 +4,7 @@
package org.jetbrains.kotlin.js.backend;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import kotlin.text.StringsKt;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.js.backend.ast.*;
@@ -12,7 +13,6 @@ import org.jetbrains.kotlin.js.backend.ast.JsIntLiteral;
import org.jetbrains.kotlin.js.backend.ast.JsVars.JsVar;
import org.jetbrains.kotlin.js.common.IdentifierPolicyKt;
import org.jetbrains.kotlin.js.util.TextOutput;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -190,7 +190,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
* because the statements designated by statementEnds and statementStarts are
* those that appear directly within these global blocks.
*/
private Set<JsBlock> globalBlocks = new THashSet<JsBlock>();
private Set<JsBlock> globalBlocks = new ObjectOpenHashSet<>();
@NotNull
protected final TextOutput p;
+1 -1
View File
@@ -8,7 +8,7 @@ dependencies {
compileOnly(project(":js:js.parser")) // TODO remove, required for JSON AST
compileOnly(project(":js:js.frontend")) // TODO remove
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
}
sourceSets {
@@ -4,7 +4,7 @@
*/
package org.jetbrains.kotlin.js.sourceMap
import gnu.trove.TObjectIntHashMap
import com.intellij.util.containers.ObjectIntHashMap
import org.jetbrains.kotlin.js.parser.sourcemaps.*
import java.io.File
import java.io.IOException
@@ -17,13 +17,6 @@ class SourceMap3Builder(
private val pathPrefix: String
) : SourceMapBuilder {
private class ObjectIntHashMap<T> : TObjectIntHashMap<T>() {
override fun get(key: T): Int {
val index = index(key)
return if (index < 0) -1 else _values[index]
}
}
private val out = StringBuilder(8192)
private val sources = ObjectIntHashMap<SourceKey>()
@@ -98,7 +91,7 @@ class SourceMap3Builder(
private fun getSourceIndex(source: String, fileIdentity: Any?, contentSupplier: Supplier<Reader?>): Int {
val key = SourceKey(source, fileIdentity)
var sourceIndex = sources[key]
var sourceIndex = sources.get(key)
if (sourceIndex == -1) {
sourceIndex = orderedSources.size
sources.put(key, sourceIndex)
@@ -109,7 +102,7 @@ class SourceMap3Builder(
}
private fun getNameIndex(name: String): Int {
var nameIndex = names[name]
var nameIndex = names.get(name)
if (nameIndex == -1) {
nameIndex = orderedNames.size
names.put(name, nameIndex)
@@ -216,23 +216,6 @@ class CodeConformanceTest : TestCase() {
message = "%d source files contain references to package gnu.trove.\n" +
"Please avoid using trove library in new use cases. " +
"These files are affected:\n%s",
allowedFiles = listOf(
"analysis/light-classes-base/src/org/jetbrains/kotlin/asJava/classes/KotlinClassInnerStuffCache.kt",
"compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/compiler/CliVirtualFileFinder.kt",
"compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt",
"compiler/cli/cli-base/src/org/jetbrains/kotlin/cli/jvm/index/JvmDependenciesIndexImpl.kt",
"compiler/daemon/src/org/jetbrains/kotlin/daemon/RemoteLookupTrackerClient.kt",
"compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt",
"compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt",
"compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PreliminaryLoopVisitor.kt",
"compiler/psi/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt",
"compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt",
"compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.kt",
"compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java",
"js/js.ast/src/org/jetbrains/kotlin/js/backend/JsReservedIdentifiers.java",
"js/js.ast/src/org/jetbrains/kotlin/js/backend/JsToStringGenerationVisitor.java",
"js/js.sourcemap/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.kt",
)
) { _, source ->
"gnu.trove" in source
}