From 43eaaef8b83b248beb8438e11576a0a141896cb7 Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Wed, 13 Mar 2024 22:10:16 +0200 Subject: [PATCH] [Workspace Model] [IJPL-583] Changes in storage to support builders without entity interfaces GitOrigin-RevId: a12dbd8c4c017d140be9c7c538e4327211b0a455 --- .../intellij/platform/workspace/storage/entityTreeUtil.kt | 6 +++--- .../intellij/platform/workspace/storage/impl/Entities.kt | 4 ++++ .../workspace/storage/impl/ReplaceBySourceAsTree.kt | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/entityTreeUtil.kt b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/entityTreeUtil.kt index 6b2059844b80..0441b0abf934 100644 --- a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/entityTreeUtil.kt +++ b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/entityTreeUtil.kt @@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.platform.workspace.storage import com.intellij.platform.workspace.storage.impl.AbstractEntityStorage @@ -24,7 +24,7 @@ public fun T.createEntityTreeCopy(requireTopLevelEntity: B val newEntity = entityData.createDetachedEntity(emptyList()) val copied = HashSet() val deferred = HashSet() - val parents = FList.emptyList().prepend(newEntity) + val parents = FList.emptyList>().prepend(newEntity) val parentInterfaces = FList.emptyList>().prepend(entityData.getEntityInterface()) copyChildren(id, parents, parentInterfaces, originalSnapshot, copied, deferred) deferred.removeAll(copied) @@ -34,7 +34,7 @@ public fun T.createEntityTreeCopy(requireTopLevelEntity: B } private fun copyChildren(oldEntityId: EntityId, - parents: FList, + parents: FList>, parentInterfaces: FList>, originalSnapshot: AbstractEntityStorage, copied: MutableSet, diff --git a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/Entities.kt b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/Entities.kt index 91e51270057b..06105e25a119 100644 --- a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/Entities.kt +++ b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/Entities.kt @@ -570,6 +570,10 @@ public abstract class WorkspaceEntityData : Cloneable, Seri throw NotImplementedError() } + public open fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { + throw NotImplementedError() + } + public open fun getRequiredParents(): List> { throw NotImplementedError() } diff --git a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/ReplaceBySourceAsTree.kt b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/ReplaceBySourceAsTree.kt index a1bccbcd3365..c729c38e76db 100644 --- a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/ReplaceBySourceAsTree.kt +++ b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/ReplaceBySourceAsTree.kt @@ -199,11 +199,13 @@ internal class ReplaceBySourceAsTree { private fun addElement(parents: Set?, replaceWithDataSource: EntityId, replaceToTarget: HashBiMap) { val targetParents = mutableListOf() + val targetParentBuilders = mutableListOf>() parents?.forEach { parent -> targetParents += targetStorage.entityDataByIdOrDie(parent).createEntity(targetStorage) + targetParentBuilders += targetStorage.entityDataByIdOrDie(parent).wrapAsModifiable(targetStorage) } - val modifiableEntity = replaceWithStorage.entityDataByIdOrDie(replaceWithDataSource).createDetachedEntity(targetParents) + val modifiableEntity = replaceWithStorage.entityDataByIdOrDie(replaceWithDataSource).createDetachedEntity(targetParentBuilders) modifiableEntity as ModifiableWorkspaceEntityBase> // We actually bind parents in [createDetachedEntity], but we can't do it for external entities (that are defined in a separate module)