mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
IJ-CR-146078 do not expose CHM
GitOrigin-RevId: f83c0586798c833f1df2ad0e00d5ee4fab2c303b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fac8a8b57c
commit
7a1188ddac
@@ -1054,7 +1054,7 @@ f:com.intellij.openapi.application.TransactionGuardImpl
|
||||
- assertWriteActionAllowed():V
|
||||
- assertWriteSafeContext(com.intellij.openapi.application.ModalityState):V
|
||||
- enteredModality(com.intellij.openapi.application.ModalityState):V
|
||||
- getContextTransaction():com.intellij.openapi.application.TransactionGuardImpl$TransactionIdImpl
|
||||
- getContextTransaction():com.intellij.openapi.application.TransactionId
|
||||
- isWriteSafeModality(com.intellij.openapi.application.ModalityState):Z
|
||||
- isWritingAllowed():Z
|
||||
- submitTransaction(com.intellij.openapi.Disposable,com.intellij.openapi.application.TransactionId,java.lang.Runnable):V
|
||||
|
||||
@@ -6,7 +6,6 @@ com/intellij/ide/plugins/PluginLoadingResult
|
||||
com/intellij/ide/plugins/PluginManagerState
|
||||
com/intellij/lang/impl/PsiBuilderImpl$MyTreeStructure
|
||||
com/intellij/lang/impl/PsiBuilderImpl$StartMarker
|
||||
com/intellij/openapi/application/TransactionGuardImpl$TransactionIdImpl
|
||||
com/intellij/openapi/command/impl/CoreCommandProcessor$CommandDescriptor
|
||||
com/intellij/openapi/extensions/impl/ExtensionsAreaImpl
|
||||
com/intellij/psi/impl/DiffLog
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
@@ -30,16 +30,16 @@ import java.util.*;
|
||||
public final class CompactVirtualFileSet extends AbstractSet<VirtualFile> implements VirtualFileSetEx {
|
||||
/** Max weirdFiles.size to convert storage to {@link IntSetStorage} */
|
||||
@VisibleForTesting
|
||||
static final int INT_SET_LIMIT = 10;
|
||||
public static final int INT_SET_LIMIT = 10;
|
||||
/**
|
||||
* Max storage.size to convert {@link IntSetStorage} impl to either {@link IdBitSetStorage} or {@link PartitionedBitSetStorage}
|
||||
* (depending on ids range)
|
||||
*/
|
||||
@VisibleForTesting
|
||||
static final int BIT_SET_LIMIT = 1000;
|
||||
public static final int BIT_SET_LIMIT = 1000;
|
||||
/** max fileId range covered by {@link IdBitSetStorage}, to convert it to {@link PartitionedBitSetStorage} */
|
||||
@VisibleForTesting
|
||||
static final int PARTITION_BIT_SET_LIMIT = 20000;
|
||||
public static final int PARTITION_BIT_SET_LIMIT = 20000;
|
||||
/**
|
||||
* If {@link IdBitSetStorage} covers id range more than PARTITION_BIT_SET_LIMIT, and less than this % of {@link IdBitSetStorage}
|
||||
* bits are set -> convert it to {@link PartitionedBitSetStorage}
|
||||
|
||||
@@ -80,6 +80,7 @@ jvm_library(
|
||||
"//platform/testFramework:testFramework_test_lib",
|
||||
"//platform/execution",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"@lib//:assert_j",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -217,6 +217,7 @@ jvm_library(
|
||||
"@lib//:netty-buffer",
|
||||
"//platform/util/progress",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"//platform/core-ui",
|
||||
"@lib//:zip-signer",
|
||||
"@lib//:caffeine",
|
||||
|
||||
@@ -69,6 +69,7 @@ jvm_library(
|
||||
"//platform/platform-api:ide",
|
||||
"//platform/platform-util-io:ide-util-io",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"//platform/analysis-api:analysis",
|
||||
"@lib//:jna",
|
||||
"@lib//:download-pgp-verifier",
|
||||
|
||||
@@ -55,6 +55,7 @@ jvm_library(
|
||||
"//platform/statistics/uploader",
|
||||
"@lib//:fastutil-min",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"//platform/core-ui",
|
||||
"@lib//:jna",
|
||||
"//platform/util",
|
||||
|
||||
@@ -2836,8 +2836,10 @@ com.intellij.util.containers.ConcurrentIntObjectMap
|
||||
- com.intellij.util.containers.IntObjectMap
|
||||
- a:cacheOrGet(I,java.lang.Object):java.lang.Object
|
||||
- a:elements():java.util.Enumeration
|
||||
- a:getOrDefault(I,java.lang.Object):java.lang.Object
|
||||
- a:putIfAbsent(I,java.lang.Object):java.lang.Object
|
||||
- a:remove(I,java.lang.Object):Z
|
||||
- a:replace(I,java.lang.Object):java.lang.Object
|
||||
- a:replace(I,java.lang.Object,java.lang.Object):Z
|
||||
- a:size():I
|
||||
com.intellij.util.containers.ConcurrentList
|
||||
@@ -2851,7 +2853,9 @@ com.intellij.util.containers.ConcurrentLongObjectMap
|
||||
- a:containsValue(java.lang.Object):Z
|
||||
- a:elements():java.util.Iterator
|
||||
- a:entries():java.lang.Iterable
|
||||
- a:entrySet():java.util.Set
|
||||
- a:get(J):java.lang.Object
|
||||
- a:getOrDefault(J,java.lang.Object):java.lang.Object
|
||||
- a:isEmpty():Z
|
||||
- a:keys():J[]
|
||||
- a:put(J,java.lang.Object):java.lang.Object
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
### auto-generated section `build intellij.platform.concurrency` start
|
||||
load("@rules_jvm//:jvm.bzl", "jvm_library")
|
||||
load("@rules_jvm//:jvm.bzl", "jvm_library", "jvm_test")
|
||||
|
||||
jvm_library(
|
||||
name = "concurrency",
|
||||
@@ -16,4 +16,27 @@ jvm_library(
|
||||
"//platform/util/coroutines",
|
||||
]
|
||||
)
|
||||
|
||||
jvm_library(
|
||||
name = "concurrency_test_lib",
|
||||
visibility = ["//visibility:public"],
|
||||
srcs = glob(["testSrc/**/*.kt", "testSrc/**/*.java"], allow_empty = True),
|
||||
associates = [":concurrency"],
|
||||
deps = [
|
||||
"@lib//:kotlin-stdlib",
|
||||
"@lib//:kotlinx-coroutines-core",
|
||||
"//platform/util",
|
||||
"//platform/core-api:core",
|
||||
"@lib//:fastutil-min",
|
||||
"//platform/diagnostic",
|
||||
"//platform/util/coroutines",
|
||||
"@lib//:assert_j",
|
||||
"@lib//:junit5",
|
||||
]
|
||||
)
|
||||
|
||||
jvm_test(
|
||||
name = "concurrency_test",
|
||||
runtime_deps = [":concurrency_test_lib"]
|
||||
)
|
||||
### auto-generated section `build intellij.platform.concurrency` end
|
||||
@@ -4,6 +4,7 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
@@ -14,5 +15,7 @@
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.diagnostic" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
|
||||
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit5" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.concurrency;
|
||||
|
||||
import com.intellij.reference.SoftReference;
|
||||
@@ -37,8 +37,20 @@ abstract class ConcurrentIntKeyRefValueHashMap<V> implements ConcurrentIntObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull V cacheOrGet(int key, @NotNull V value) {
|
||||
public V getOrDefault(int key, V defaultValue) {
|
||||
V v;
|
||||
return (v = get(key)) == null ? defaultValue : v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final V replace(int key, @NotNull V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final @NotNull V cacheOrGet(int key, @NotNull V value) {
|
||||
IntReference<V> newRef = createReference(key, value, myQueue);
|
||||
V result;
|
||||
while (true) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package com.intellij.concurrency;
|
||||
|
||||
@@ -1096,6 +1096,7 @@ final class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
* no mapping for the given key
|
||||
* @return the mapping for the key, if present; else the default value
|
||||
*/
|
||||
@Override
|
||||
public V getOrDefault(int key, V defaultValue) {
|
||||
V v;
|
||||
return (v = get(key)) == null ? defaultValue : v;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package com.intellij.concurrency;
|
||||
|
||||
@@ -905,6 +905,7 @@ final class ConcurrentLongObjectHashMap<V> implements ConcurrentLongObjectMap<V>
|
||||
*
|
||||
* @return the set view
|
||||
*/
|
||||
@Override
|
||||
public Set<LongEntry<V>> entrySet() {
|
||||
EntrySetView<V> es;
|
||||
return (es = entrySet) != null ? es : (entrySet = new EntrySetView<>(this));
|
||||
@@ -1053,6 +1054,7 @@ final class ConcurrentLongObjectHashMap<V> implements ConcurrentLongObjectMap<V>
|
||||
* no mapping for the given key
|
||||
* @return the mapping for the key, if present; else the default value
|
||||
*/
|
||||
@Override
|
||||
public V getOrDefault(long key, V defaultValue) {
|
||||
V v;
|
||||
return (v = get(key)) == null ? defaultValue : v;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.concurrency
|
||||
|
||||
import com.intellij.util.containers.ConcurrentIntObjectMap
|
||||
import com.intellij.util.containers.ConcurrentLongObjectMap
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.util.concurrent.ConcurrentMap
|
||||
|
||||
@TestOnly
|
||||
internal fun <K : Any, V: Any> chMap(): ConcurrentMap<K, V> = ConcurrentHashMap()
|
||||
|
||||
@TestOnly
|
||||
internal fun <K : Any, V: Any> chMap(from: Map<K, V>): ConcurrentMap<K, V> = ConcurrentHashMap(from)
|
||||
|
||||
@TestOnly
|
||||
internal fun <V: Any> chLongMap(): ConcurrentLongObjectMap<V> = ConcurrentLongObjectHashMap<V>()
|
||||
|
||||
internal fun <V: Any> chIntMap(): ConcurrentIntObjectMap<V> = ConcurrentIntObjectHashMap<V>()
|
||||
|
||||
//internal fun <K : Any, V: Any> chMap(from: Map<K, V>): ConcurrentMap<K, V> = ConcurrentHashMap(from)
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.concurrency
|
||||
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.junit.Test
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ConcurrentHashMapTest {
|
||||
@Test
|
||||
fun `put and get`() {
|
||||
val map = ConcurrentHashMap<Int, Int>()
|
||||
val map = chMap<Int, Int>()
|
||||
assertThat(map.size).isEqualTo(0)
|
||||
assertThat(map.isEmpty()).isTrue()
|
||||
map[1] = 0
|
||||
@@ -30,7 +30,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun remove() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2, 2 to 3, 3 to 4))
|
||||
val map = chMap(mapOf(1 to 2, 2 to 3, 3 to 4))
|
||||
assertThat(map.size).isEqualTo(3)
|
||||
assertThat(map.remove(4)).isNull()
|
||||
assertThat(map.remove(3, 5)).isFalse()
|
||||
@@ -46,7 +46,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun entries() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2, 2 to 3, 3 to 4))
|
||||
val map = chMap(mapOf(1 to 2, 2 to 3, 3 to 4))
|
||||
assertThat(map.entries.map { it.key to it.value }).containsExactlyInAnyOrder(1 to 2, 2 to 3, 3 to 4)
|
||||
assertThat(map.keys).containsExactlyInAnyOrder(1, 2, 3)
|
||||
assertThat(map.values).containsExactlyInAnyOrder(2, 3, 4)
|
||||
@@ -54,7 +54,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun `put if absent`() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2))
|
||||
val map = chMap(mapOf(1 to 2))
|
||||
assertThat(map.putIfAbsent(1, 3)).isEqualTo(2)
|
||||
assertThat(map[1]).isEqualTo(2)
|
||||
assertThat(map.putIfAbsent(2, 3)).isNull()
|
||||
@@ -63,7 +63,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun `compute if absent`() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2))
|
||||
val map = chMap(mapOf(1 to 2))
|
||||
assertThat(map.computeIfAbsent(1) { 3 }).isEqualTo(2)
|
||||
assertThat(map[1]).isEqualTo(2)
|
||||
assertThat(map.computeIfAbsent(2) { 3 }).isEqualTo(3)
|
||||
@@ -72,7 +72,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun `compute if present`() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2))
|
||||
val map = chMap(mapOf(1 to 2))
|
||||
assertThat(map.computeIfPresent(2) { _, _ -> 3 }).isNull()
|
||||
assertThat(map[1]).isEqualTo(2)
|
||||
assertThat(map.computeIfPresent(1) { _, _ -> 3 }).isEqualTo(3)
|
||||
@@ -81,7 +81,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun compute() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2))
|
||||
val map = chMap(mapOf(1 to 2))
|
||||
assertThat(map.compute(1) { _, _ -> 3 }).isEqualTo(3)
|
||||
assertThat(map[1]).isEqualTo(3)
|
||||
assertThat(map.compute(2) { _, _ -> 3 }).isEqualTo(3)
|
||||
@@ -90,7 +90,7 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun replace() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2, 2 to 3))
|
||||
val map = chMap(mapOf(1 to 2, 2 to 3))
|
||||
assertThat(map.replace(3, 4)).isNull()
|
||||
assertThat(map.replace(2, 4)).isEqualTo(3)
|
||||
assertThat(map[2]).isEqualTo(4)
|
||||
@@ -101,14 +101,14 @@ class ConcurrentHashMapTest {
|
||||
|
||||
@Test
|
||||
fun `replace all`() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2, 2 to 3))
|
||||
val map = chMap(mapOf(1 to 2, 2 to 3))
|
||||
map.replaceAll { k, v -> k + v}
|
||||
assertThat(map).isEqualTo(mapOf(1 to 3, 2 to 5))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun merge() {
|
||||
val map = ConcurrentHashMap(mapOf(1 to 2, 2 to 3))
|
||||
val map = chMap(mapOf(1 to 2, 2 to 3))
|
||||
assertThat(map.merge(3, 4) { _, _ -> 4 }).isEqualTo(4)
|
||||
assertThat(map[3]).isEqualTo(4)
|
||||
assertThat(map.merge(1, 3) { a, b -> a+b }).isEqualTo(5)
|
||||
@@ -1,14 +1,15 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.concurrency
|
||||
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import com.intellij.util.containers.ConcurrentIntObjectMap
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Assertions.assertNull
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ConcurrentIntObjectHashMapTest {
|
||||
@Test
|
||||
fun `put and get`() {
|
||||
val map = ConcurrentIntObjectHashMap<Int>()
|
||||
val map = chIntMap<Int>()
|
||||
assertThat(map.size()).isEqualTo(0)
|
||||
assertThat(map.isEmpty).isTrue()
|
||||
map.put(1, 0)
|
||||
@@ -18,7 +19,8 @@ class ConcurrentIntObjectHashMapTest {
|
||||
assertThat(map.get(1)).isEqualTo(0)
|
||||
assertThat(map.get(2)).isEqualTo(1)
|
||||
assertThat(map.getOrDefault(2, 4)).isEqualTo(1)
|
||||
assertNull(map.get(3))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.get(3) as Int?).isNull()
|
||||
assertThat(map.getOrDefault(3, 4)).isEqualTo(4)
|
||||
assertThat(map.containsKey(1)).isTrue()
|
||||
assertThat(map.containsKey(3)).isFalse()
|
||||
@@ -33,7 +35,8 @@ class ConcurrentIntObjectHashMapTest {
|
||||
fun remove() {
|
||||
val map = createFrom(1 to 2, 2 to 3, 3 to 4)
|
||||
assertThat(map.size()).isEqualTo(3)
|
||||
assertNull(map.remove(4))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.remove(4) as Int?).isNull()
|
||||
assertThat(map.remove(3, 5)).isFalse()
|
||||
assertThat(map.size()).isEqualTo(3)
|
||||
|
||||
@@ -56,9 +59,11 @@ class ConcurrentIntObjectHashMapTest {
|
||||
@Test
|
||||
fun `put if absent`() {
|
||||
val map = createFrom(1 to 2)
|
||||
assertThat(map.putIfAbsent(1, 3)).isEqualTo(2)
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.putIfAbsent(1, 3) as Int?).isEqualTo(2)
|
||||
assertThat(map[1]).isEqualTo(2)
|
||||
assertNull(map.putIfAbsent(2, 3))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.putIfAbsent(2, 3) as Int?).isNull()
|
||||
assertThat(map[2]).isEqualTo(3)
|
||||
}
|
||||
|
||||
@@ -73,8 +78,8 @@ class ConcurrentIntObjectHashMapTest {
|
||||
assertThat(map[1]).isEqualTo(3)
|
||||
}
|
||||
|
||||
private fun createFrom(vararg pair: Pair<Int, Int>): ConcurrentIntObjectHashMap<Int> {
|
||||
val map = ConcurrentIntObjectHashMap<Int>()
|
||||
private fun createFrom(vararg pair: Pair<Int, Int>): ConcurrentIntObjectMap<Int> {
|
||||
val map = chIntMap<Int>()
|
||||
for (entry in pair) {
|
||||
map.put(entry.first, entry.second)
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.concurrency
|
||||
|
||||
import org.assertj.core.api.Assertions.*
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import com.intellij.util.containers.ConcurrentLongObjectMap
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ConcurrentLongObjectHashMapTest {
|
||||
@Test
|
||||
fun `put and get`() {
|
||||
val map = ConcurrentLongObjectHashMap<Int>()
|
||||
val map = chLongMap<Int>()
|
||||
assertThat(map.size()).isEqualTo(0)
|
||||
assertThat(map.isEmpty).isTrue()
|
||||
map.put(1, 0)
|
||||
@@ -18,7 +18,8 @@ class ConcurrentLongObjectHashMapTest {
|
||||
assertThat(map.get(1)).isEqualTo(0)
|
||||
assertThat(map.get(2)).isEqualTo(1)
|
||||
assertThat(map.getOrDefault(2, 4)).isEqualTo(1)
|
||||
assertNull(map.get(3))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.get(3) as Int?).isNull()
|
||||
assertThat(map.getOrDefault(3, 4)).isEqualTo(4)
|
||||
assertThat(map.containsKey(1)).isTrue()
|
||||
assertThat(map.containsKey(3)).isFalse()
|
||||
@@ -33,7 +34,8 @@ class ConcurrentLongObjectHashMapTest {
|
||||
fun remove() {
|
||||
val map = createFrom(1 to 2, 2 to 3, 3 to 4)
|
||||
assertThat(map.size()).isEqualTo(3)
|
||||
assertNull(map.remove(4))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.remove(4) as Int?).isNull()
|
||||
assertThat(map.remove(3, 5)).isFalse()
|
||||
assertThat(map.size()).isEqualTo(3)
|
||||
|
||||
@@ -58,14 +60,16 @@ class ConcurrentLongObjectHashMapTest {
|
||||
val map = createFrom(1 to 2)
|
||||
assertThat(map.putIfAbsent(1, 3)).isEqualTo(2)
|
||||
assertThat(map[1]).isEqualTo(2)
|
||||
assertNull(map.putIfAbsent(2, 3))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.putIfAbsent(2, 3) as Int?).isNull()
|
||||
assertThat(map[2]).isEqualTo(3)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun replace() {
|
||||
val map = createFrom(1 to 2, 2 to 3)
|
||||
assertNull(map.replace(3, 4))
|
||||
@Suppress("USELESS_CAST")
|
||||
assertThat(map.replace(3, 4) as Int?).isNull()
|
||||
assertThat(map.replace(2, 4)).isEqualTo(3)
|
||||
assertThat(map[2]).isEqualTo(4)
|
||||
assertThat(map.replace(1, 3, 4)).isFalse()
|
||||
@@ -73,8 +77,8 @@ class ConcurrentLongObjectHashMapTest {
|
||||
assertThat(map[1]).isEqualTo(3)
|
||||
}
|
||||
|
||||
private fun createFrom(vararg pair: Pair<Int, Int>): ConcurrentLongObjectHashMap<Int> {
|
||||
val map = ConcurrentLongObjectHashMap<Int>()
|
||||
private fun createFrom(vararg pair: Pair<Int, Int>): ConcurrentLongObjectMap<Int> {
|
||||
val map = chLongMap<Int>()
|
||||
for (entry in pair) {
|
||||
map.put(entry.first.toLong(), entry.second)
|
||||
}
|
||||
@@ -31,6 +31,7 @@ jvm_test(
|
||||
"//platform/testFramework/common",
|
||||
"//platform/util/coroutines",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
]
|
||||
)
|
||||
### auto-generated section `build intellij.platform.util.coroutines.tests` end
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.util.containers.ConcurrentLongObjectMap;
|
||||
@@ -944,6 +944,7 @@ final class ConcurrentLongObjectHashMap<V> implements ConcurrentLongObjectMap<V>
|
||||
*
|
||||
* @return the set view
|
||||
*/
|
||||
@Override
|
||||
public Set<LongEntry<V>> entrySet() {
|
||||
EntrySetView<V> es;
|
||||
return (es = entrySet) != null ? es : (entrySet = new EntrySetView<>(this));
|
||||
@@ -1104,6 +1105,7 @@ final class ConcurrentLongObjectHashMap<V> implements ConcurrentLongObjectMap<V>
|
||||
* no mapping for the given key
|
||||
* @return the mapping for the key, if present; else the default value
|
||||
*/
|
||||
@Override
|
||||
public V getOrDefault(long key, V defaultValue) {
|
||||
V v;
|
||||
return (v = get(key)) == null ? defaultValue : v;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package com.intellij.util.containers;
|
||||
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* Concurrent key:int -> weak value:V map
|
||||
* Null values are NOT allowed
|
||||
* @deprecated Use {@link com.intellij.concurrency.ConcurrentCollectionFactory#createConcurrentIntObjectWeakValueMap()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
class ConcurrentIntKeyWeakValueHashMap<V> extends ConcurrentIntKeyRefValueHashMap<V> {
|
||||
private static final class MyRef<V> extends WeakReference<V> implements IntReference<V> {
|
||||
private final int hash;
|
||||
private final int key;
|
||||
|
||||
private MyRef(int key, @NotNull V referent, @NotNull ReferenceQueue<V> queue) {
|
||||
super(referent, queue);
|
||||
this.key = key;
|
||||
hash = referent.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
V v = get();
|
||||
if (!(obj instanceof MyRef)) {
|
||||
return false;
|
||||
}
|
||||
//noinspection unchecked
|
||||
MyRef<V> other = (MyRef<V>)obj;
|
||||
return other.hash == hash && key == other.getKey() && Comparing.equal(v, other.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull IntReference<V> createReference(int key, @NotNull V value, @NotNull ReferenceQueue<V> queue) {
|
||||
return new MyRef<>(key, value, queue);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package com.intellij.util.containers;
|
||||
|
||||
@@ -1099,6 +1099,7 @@ final class ConcurrentIntObjectHashMap<V> implements ConcurrentIntObjectMap<V> {
|
||||
* no mapping for the given key
|
||||
* @return the mapping for the key, if present; else the default value
|
||||
*/
|
||||
@Override
|
||||
public V getOrDefault(int key, V defaultValue) {
|
||||
V v;
|
||||
return (v = get(key)) == null ? defaultValue : v;
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
*/
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -22,8 +8,9 @@ import java.util.Enumeration;
|
||||
/**
|
||||
* Base interface for concurrent int key -> value:V map
|
||||
* Null values are NOT allowed
|
||||
*
|
||||
* <p>
|
||||
* Methods are adapted from {@link java.util.concurrent.ConcurrentMap} to integer keys
|
||||
*
|
||||
* @see java.util.concurrent.ConcurrentMap
|
||||
*/
|
||||
public interface ConcurrentIntObjectMap<V> extends IntObjectMap<V> {
|
||||
@@ -32,8 +19,14 @@ public interface ConcurrentIntObjectMap<V> extends IntObjectMap<V> {
|
||||
*/
|
||||
@NotNull
|
||||
V cacheOrGet(int key, @NotNull V value);
|
||||
|
||||
boolean remove(int key, @NotNull V value);
|
||||
boolean replace(int key, @NotNull V oldValue, @NotNull V newValue);
|
||||
|
||||
boolean replace(int key, @NotNull V oldValue, @NotNull V newValue);
|
||||
|
||||
V replace(int key, @NotNull V oldValue);
|
||||
|
||||
V getOrDefault(int key, V defaultValue);
|
||||
|
||||
@NotNull
|
||||
Enumeration<V> elements();
|
||||
@@ -43,7 +36,7 @@ public interface ConcurrentIntObjectMap<V> extends IntObjectMap<V> {
|
||||
* The usage is discouraged since
|
||||
* First, in concurrent context it doesn't have much sense
|
||||
* and Second, for weak- or soft- keyed maps it returns the total number of references
|
||||
* rather than alive values because otherwise it would be too expensive
|
||||
* rather than alive values because otherwise it would be too expensive
|
||||
*/
|
||||
@Override
|
||||
int size();
|
||||
@@ -53,5 +46,4 @@ public interface ConcurrentIntObjectMap<V> extends IntObjectMap<V> {
|
||||
* or {@code null} if there was no mapping for the key
|
||||
*/
|
||||
V putIfAbsent(int key, @NotNull V value);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import org.jetbrains.annotations.Debug;
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,10 @@ public interface ConcurrentLongObjectMap<V> {
|
||||
@NotNull
|
||||
V cacheOrGet(long key, @NotNull V value);
|
||||
|
||||
Set<LongEntry<V>> entrySet();
|
||||
|
||||
V getOrDefault(long key, V defaultValue);
|
||||
|
||||
boolean remove(long key, @NotNull V value);
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,7 @@ jvm_library(
|
||||
deps = [
|
||||
"//platform/core-api:core",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"//platform/core-impl",
|
||||
"//platform/platform-api:ide",
|
||||
"//platform/statistics",
|
||||
|
||||
@@ -71,6 +71,7 @@ jvm_library(
|
||||
"//platform/util-ex",
|
||||
"@lib//:kotlin-stdlib",
|
||||
"//platform/util/concurrency",
|
||||
"//platform/util/concurrency:concurrency_test_lib",
|
||||
"@lib//:kotlinx-coroutines-core",
|
||||
"@lib//:kotlinx-serialization-core",
|
||||
"@lib//:kotlinx-serialization-json",
|
||||
|
||||
Reference in New Issue
Block a user