[editor] IJPL-54 Move DocumentEntity to separate module depending on kernel and andel

GitOrigin-RevId: 9c3e3b1bb9a003e8b273302fa8c19f6e56e91a10
This commit is contained in:
Alexandr Trushev
2025-02-19 10:14:21 +01:00
committed by intellij-monorepo-bot
parent 8b94d67062
commit f50ea14677
24 changed files with 96 additions and 44 deletions

1
.idea/modules.xml generated
View File

@@ -817,6 +817,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/object-serializer/intellij.platform.objectSerializer.iml" filepath="$PROJECT_DIR$/platform/object-serializer/intellij.platform.objectSerializer.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/object-serializer/intellij.platform.objectSerializer.annotations.iml" filepath="$PROJECT_DIR$/platform/object-serializer/intellij.platform.objectSerializer.annotations.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/object-serializer/intellij.platform.objectSerializer.tests.iml" filepath="$PROJECT_DIR$/platform/object-serializer/intellij.platform.objectSerializer.tests.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/kernel/pasta/intellij.platform.pasta.iml" filepath="$PROJECT_DIR$/platform/kernel/pasta/intellij.platform.pasta.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/progress/backend/intellij.platform.progress.backend.iml" filepath="$PROJECT_DIR$/platform/progress/backend/intellij.platform.progress.backend.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/project/shared/intellij.platform.project.iml" filepath="$PROJECT_DIR$/platform/project/shared/intellij.platform.project.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/project/backend/intellij.platform.project.backend.iml" filepath="$PROJECT_DIR$/platform/project/backend/intellij.platform.project.backend.iml" />

View File

@@ -13,5 +13,6 @@
<orderEntry type="library" name="kotlinx-serialization-core" level="project" />
<orderEntry type="module" module-name="intellij.platform.kernel" />
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="module" module-name="intellij.platform.pasta" />
</component>
</module>

View File

@@ -3,8 +3,8 @@ package com.intellij.platform.editor
import com.intellij.openapi.application.isRhizomeAdEnabled
import com.intellij.openapi.editor.impl.ad.AdDocumentEntity
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity
import com.intellij.platform.kernel.editor.pasta.common.EditLogEntity
import com.intellij.platform.pasta.common.DocumentEntity
import com.intellij.platform.pasta.common.EditLogEntity
import com.intellij.platform.kernel.EntityTypeProvider
import com.jetbrains.rhizomedb.EntityType

View File

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="5" platform="JVM 17" allPlatforms="JVM [17]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-Xjvm-default=all" />
</compilerSettings>
<compilerArguments>
<stringArguments>
<stringArg name="jvmTarget" arg="17" />
<stringArg name="apiVersion" arg="2.0" />
<stringArg name="languageVersion" arg="2.0" />
</stringArguments>
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$KOTLIN_BUNDLED$/lib/kotlinx-serialization-compiler-plugin.jar</arg>
<arg>$MAVEN_REPOSITORY$/jetbrains/fleet/rhizomedb-compiler-plugin/2.1.10-0.1/rhizomedb-compiler-plugin-2.1.10-0.1.jar</arg>
</args>
</arrayArg>
<arrayArg name="pluginOptions" />
</arrayArguments>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/" isTestSource="false" packagePrefix="com.intellij.platform.pasta" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.rpc" exported="" />
<orderEntry type="module" module-name="fleet.andel" exported="" />
<orderEntry type="module" module-name="fleet.kernel" exported="" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
<orderEntry type="library" name="kotlinx-serialization-core" level="project" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.ide.core" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
</component>
</module>

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.AnchorId
import andel.editor.DocumentComponent

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.*
import andel.intervals.AnchorStorage
@@ -41,7 +41,7 @@ internal class DbMutableDocument(
private set
get() {
val res = MutableBoundedOpenMap.emptyBounded<MutableDocument, DocumentComponent>()
val components = entities(DocumentComponentEntity.DocumentAttr, dbDocument)
val components = entities(DocumentComponentEntity.Companion.DocumentAttr, dbDocument)
for (c in components) {
val key = c.getKey()
res.update(key as DocumentComponentKey<DocumentComponent>) { existing ->
@@ -64,7 +64,8 @@ internal class DbMutableDocument(
val versionedOperation = captureOperation(operation)
changeScope.maybeShared(dbDocument) {
mutate(ChangeDocument(
mutate(
ChangeDocument(
operationId = UID.random(),
documentId = dbDocument.eid,
operation = versionedOperation.rebase(this@DbMutableDocument)),
@@ -87,7 +88,7 @@ internal class DbMutableDocument(
override fun removeAnchor(anchorId: AnchorId) {
intermediateAnchorStorage = intermediateAnchorStorage.removeAnchor(anchorId)
with(changeScope) {
entity(LocalAnchor.AnchorIdAttr, anchorId)?.delete()
entity(LocalAnchor.Companion.AnchorIdAttr, anchorId)?.delete()
}
}
@@ -115,7 +116,7 @@ internal class DbMutableDocument(
override fun removeRangeMarker(markerId: RangeMarkerId) {
intermediateAnchorStorage = intermediateAnchorStorage.removeRangeMarker(markerId)
with(changeScope) {
entity(LocalRangeMarker.RangeMarkerIdAttr, markerId)?.delete()
entity(LocalRangeMarker.Companion.RangeMarkerIdAttr, markerId)?.delete()
}
}
@@ -125,17 +126,17 @@ internal class DbMutableDocument(
) {
with(changeScope) {
val storage = ensureLocalAnchorStorageCreated(dbDocument)
storage[LocalAnchorStorageEntity.AnchorStorageAttr] = storage.anchorStorage.batchUpdate(anchorIds, anchorOffsets, rangeIds, ranges)
storage[LocalAnchorStorageEntity.Companion.AnchorStorageAttr] = storage.anchorStorage.batchUpdate(anchorIds, anchorOffsets, rangeIds, ranges)
anchorIds.forEach { anchorId ->
entity(LocalAnchor.AnchorIdAttr, anchorId) ?: LocalAnchor.new {
it[LocalAnchor.AnchorIdAttr] = anchorId
it[LocalAnchor.AnchorStorageAttr] = storage
entity(LocalAnchor.Companion.AnchorIdAttr, anchorId) ?: LocalAnchor.Companion.new {
it[LocalAnchor.Companion.AnchorIdAttr] = anchorId
it[LocalAnchor.Companion.AnchorStorageAttr] = storage
}
}
rangeIds.forEach { rangeMarkerId ->
entity(LocalRangeMarker.RangeMarkerIdAttr, rangeMarkerId) ?: LocalRangeMarker.new {
it[LocalRangeMarker.RangeMarkerIdAttr] = rangeMarkerId
it[LocalRangeMarker.AnchorStorageAttr] = storage
entity(LocalRangeMarker.Companion.RangeMarkerIdAttr, rangeMarkerId) ?: LocalRangeMarker.Companion.new {
it[LocalRangeMarker.Companion.RangeMarkerIdAttr] = rangeMarkerId
it[LocalRangeMarker.Companion.AnchorStorageAttr] = storage
}
}
}

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.operation.Operation
import andel.operation.isIdentity
@@ -83,17 +83,17 @@ data class ChangeDocument(
listOf(
Op.Assert(
eid = documentId,
attribute = DocumentEntity.TextAttr.attr,
attribute = DocumentEntity.Companion.TextAttr.attr,
value = textAfter,
),
Op.Assert(
eid = documentId,
attribute = DocumentEntity.SharedAnchorStorageAttr.attr,
attribute = DocumentEntity.Companion.SharedAnchorStorageAttr.attr,
value = document.sharedAnchorStorage.edit(textBefore, textAfter, operation),
),
Op.Assert(
eid = editLog.eid,
attribute = EditLogEntity.EditLogAttr.attr,
attribute = EditLogEntity.Companion.EditLogAttr.attr,
value = editLog.editLog.append(operationId, operation),
),
)

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.DocumentComponent
import andel.editor.DocumentComponentKey

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.*
import andel.intervals.AnchorStorage

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.operation.EditLog
import com.jetbrains.rhizomedb.ChangeScope

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.AnchorId
import andel.operation.Sticky
@@ -35,7 +35,7 @@ internal data class LocalAnchor(override val eid: EID) : RetractableEntity, Enti
val anchorId = anchorId
return RetractableEntity.Callback {
if (anchorStorage.exists()) {
anchorStorage[LocalAnchorStorageEntity.AnchorStorageAttr] = anchorStorage.anchorStorage.removeAnchor(anchorId)
anchorStorage[LocalAnchorStorageEntity.Companion.AnchorStorageAttr] = anchorStorage.anchorStorage.removeAnchor(anchorId)
}
}
}
@@ -50,7 +50,7 @@ internal fun ChangeScope.createAnchor(
): LocalAnchor {
require(offset >= 0) { "Offset for the anchor should be >= 0" }
val storage = ensureLocalAnchorStorageCreated(document)
storage[LocalAnchorStorageEntity.AnchorStorageAttr] = storage.anchorStorage
storage[LocalAnchorStorageEntity.Companion.AnchorStorageAttr] = storage.anchorStorage
.removeAnchor(anchorId)
.addAnchor(anchorId, offset, sticky)
return entity(LocalAnchor.AnchorIdAttr, anchorId) ?: LocalAnchor.new {

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.AnchorId
import andel.editor.DocumentComponentKey

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.editor.RangeMarkerId
import andel.editor.substring

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import andel.operation.Operation
import andel.operation.Sticky

View File

@@ -1,5 +1,5 @@
// 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.platform.kernel.editor.pasta.common
package com.intellij.platform.pasta.common
import com.jetbrains.rhizomedb.ChangeScope
import com.jetbrains.rhizomedb.Entity

View File

@@ -1,6 +1,6 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@ApiStatus.Experimental
@ApiStatus.Internal
package com.intellij.platform.kernel.editor.pasta.common;
package com.intellij.platform.pasta.common;
import org.jetbrains.annotations.ApiStatus;

View File

@@ -15,7 +15,6 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$KOTLIN_BUNDLED$/lib/kotlinx-serialization-compiler-plugin.jar</arg>
<arg>$MAVEN_REPOSITORY$/jetbrains/fleet/rhizomedb-compiler-plugin/2.1.10-0.1/rhizomedb-compiler-plugin-2.1.10-0.1.jar</arg>
</args>
</arrayArg>
@@ -36,7 +35,6 @@
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.rpc" exported="" />
<orderEntry type="module" module-name="fleet.kernel" exported="" />
<orderEntry type="module" module-name="fleet.andel" exported="" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="kotlinx-collections-immutable" level="project" />
<orderEntry type="library" name="kotlinx-serialization-core" level="project" />
@@ -45,5 +43,6 @@
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.ide.core" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="module" module-name="intellij.platform.pasta" />
</component>
</module>

View File

@@ -7,7 +7,7 @@ import com.intellij.openapi.application.asContextElement
import com.intellij.openapi.extensions.ExtensionPointListener
import com.intellij.openapi.extensions.PluginDescriptor
import com.intellij.platform.kernel.EntityTypeProvider
import com.intellij.platform.kernel.editor.pasta.common.ChangeDocument
import com.intellij.platform.pasta.common.ChangeDocument
import com.jetbrains.rhizomedb.*
import fleet.kernel.*
import fleet.kernel.rebase.*

View File

@@ -13,5 +13,6 @@
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" name="jetbrains-annotations" level="project" />
<orderEntry type="module" module-name="intellij.platform.pasta" />
</component>
</module>

View File

@@ -1,7 +1,7 @@
// 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.platform.ide.bootstrap.kernel
import com.intellij.platform.kernel.editor.pasta.common.ChangeDocument
import com.intellij.platform.pasta.common.ChangeDocument
import com.intellij.platform.kernel.util.kernelCoroutineContext
import com.jetbrains.rhizomedb.EffectInstruction
import com.jetbrains.rhizomedb.MapAttribute

View File

@@ -150,5 +150,6 @@
<orderEntry type="module" module-name="intellij.platform.buildData" />
<orderEntry type="module" module-name="intellij.platform.syntax" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.platform.syntax.psi" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.platform.pasta" />
</component>
</module>

View File

@@ -9,7 +9,7 @@ import com.intellij.openapi.editor.ex.DocumentEx
import com.intellij.openapi.editor.ex.EditReadOnlyListener
import com.intellij.openapi.editor.ex.LineIterator
import com.intellij.openapi.editor.ex.RangeMarkerEx
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity
import com.intellij.platform.pasta.common.DocumentEntity
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.TextRange
import com.intellij.util.Processor

View File

@@ -18,12 +18,12 @@ import com.intellij.openapi.editor.ex.PrioritizedDocumentListener
import com.intellij.openapi.editor.ex.util.EditorUtil
import com.intellij.openapi.editor.impl.EditorImpl
import com.intellij.openapi.editor.impl.ad.ThreadLocalRhizomeDB
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity.Companion.EditLogAttr
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity.Companion.SharedAnchorStorageAttr
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity.Companion.TextAttr
import com.intellij.platform.kernel.editor.pasta.common.DocumentEntity.Companion.WritableAttr
import com.intellij.platform.kernel.editor.pasta.common.createEmptyEditLog
import com.intellij.platform.pasta.common.DocumentEntity
import com.intellij.platform.pasta.common.DocumentEntity.Companion.EditLogAttr
import com.intellij.platform.pasta.common.DocumentEntity.Companion.SharedAnchorStorageAttr
import com.intellij.platform.pasta.common.DocumentEntity.Companion.TextAttr
import com.intellij.platform.pasta.common.DocumentEntity.Companion.WritableAttr
import com.intellij.platform.pasta.common.createEmptyEditLog
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vfs.VirtualFile