mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Workspace Model] [IDEA-338250] Set the default value for the primitive maps after deserialization
GitOrigin-RevId: b5182dc42044794b1803f5d5bda97e3d0761c3f6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c89741fefc
commit
0bcb698bb8
+2
@@ -35,6 +35,8 @@ internal fun AbstractEntityStorage.assertConsistency() {
|
||||
if (!connectionId.isParentNullable) {
|
||||
checkStrongConnection(this, map.keys, connectionId.childClass, connectionId.parentClass, connectionId)
|
||||
}
|
||||
|
||||
map.assertConsistency()
|
||||
}
|
||||
|
||||
refs.oneToOneContainer.forEach { (connectionId, map) ->
|
||||
|
||||
+2
-1
@@ -439,7 +439,8 @@ internal class MutableRefsTable(
|
||||
val copiedMap = getOneToManyMutableMap(connectionId)
|
||||
|
||||
// Check if the reference already exists. This is needed to make fewer operations and not to break children ordering
|
||||
if (copiedMap.get(childId.arrayId) == parentId.id.arrayId) return emptyList()
|
||||
val existingParent = copiedMap.get(childId.arrayId)
|
||||
if (existingParent != NonNegativeIntIntBiMap.DEFAULT_RETURN_VALUE && existingParent == parentId.id.arrayId) return emptyList()
|
||||
|
||||
val removedParent = copiedMap.removeKey(childId.arrayId)
|
||||
val removedChildren = copiedMap.putAll(intArrayOf(childId.arrayId), parentId.id.arrayId)
|
||||
|
||||
+4
-5
@@ -110,7 +110,7 @@ internal sealed class NonNegativeIntIntBiMap {
|
||||
get() = key2Value.keys
|
||||
|
||||
inline fun forEachKey(crossinline action: (Int, Int) -> Unit) {
|
||||
Int2IntMaps.fastForEach(`access$key2Value`, Consumer { action(it.intKey, it.intValue) })
|
||||
Int2IntMaps.fastForEach(key2Value, Consumer { action(it.intKey, it.intValue) })
|
||||
}
|
||||
|
||||
fun containsKey(key: Int) = key2Value.containsKey(key)
|
||||
@@ -139,10 +139,9 @@ internal sealed class NonNegativeIntIntBiMap {
|
||||
return result
|
||||
}
|
||||
|
||||
@Suppress("PropertyName")
|
||||
@PublishedApi
|
||||
internal val `access$key2Value`: Int2IntMap
|
||||
get() = key2Value
|
||||
internal fun assertConsistency() {
|
||||
assert(key2Value.defaultReturnValue() == DEFAULT_RETURN_VALUE)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal const val DEFAULT_RETURN_VALUE = -1
|
||||
|
||||
+6
-1
@@ -147,7 +147,12 @@ internal class StorageClassesRegistrar(
|
||||
kryo.register(HashBiMap::class.java).instantiator = ObjectInstantiator { HashBiMap.create<Any, Any>() }
|
||||
kryo.register(LinkedHashSet::class.java).instantiator = ObjectInstantiator { LinkedHashSet<Any>() }
|
||||
kryo.register(LinkedBidirectionalMap::class.java).instantiator = ObjectInstantiator { LinkedBidirectionalMap<Any, Any>() }
|
||||
kryo.register(Int2IntOpenHashMap::class.java).instantiator = ObjectInstantiator { Int2IntOpenHashMap() }
|
||||
kryo.register(Int2IntOpenHashMap::class.java).instantiator = ObjectInstantiator {
|
||||
// We set -1 as a default return value because it's used in all Int2IntOpenHashMap in WM. But it would be better
|
||||
// to wrap "Int2IntOpenHashMap with default -1" with some helper class to avoid possible issues
|
||||
// if in some place we'll use this map with different default return value
|
||||
Int2IntOpenHashMap().also { it.defaultReturnValue(-1) }
|
||||
}
|
||||
@Suppress("SSBasedInspection")
|
||||
kryo.register(ObjectOpenHashSet::class.java).instantiator = ObjectInstantiator { ObjectOpenHashSet<Any>() }
|
||||
@Suppress("SSBasedInspection")
|
||||
|
||||
Reference in New Issue
Block a user