mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[workspace model] IJPL-844 Introduce FacetEntityTypeId for FacetEntity
GitOrigin-RevId: d7c64c5247c67a2121092d138dc2aeda38aaa16b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
adff273dbe
commit
0ad19fb54c
+6
-9
@@ -16,10 +16,7 @@ import com.intellij.openapi.util.JDOMExternalizable
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.platform.backend.workspace.WorkspaceModel
|
||||
import com.intellij.platform.workspace.jps.JpsImportedEntitySource
|
||||
import com.intellij.platform.workspace.jps.entities.FacetEntity
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleEntity
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleSettingsBase
|
||||
import com.intellij.platform.workspace.jps.entities.modifyEntity
|
||||
import com.intellij.platform.workspace.jps.entities.*
|
||||
import com.intellij.platform.workspace.storage.*
|
||||
import com.intellij.platform.workspace.storage.instrumentation.EntityStorageInstrumentationApi
|
||||
import com.intellij.platform.workspace.storage.instrumentation.MutableEntityStorageInstrumentation
|
||||
@@ -136,7 +133,7 @@ class FacetModelBridge(private val moduleBridge: ModuleBridge) : FacetModelBase(
|
||||
// Initialize facet bridges after loading from cache
|
||||
val moduleEntity = (moduleBridge.diff ?: moduleBridge.entityStorage.current).resolve(moduleBridge.moduleEntityId)
|
||||
?: error("Module entity should be available")
|
||||
val facetTypeToSerializer = BaseIdeSerializationContext.CUSTOM_FACET_RELATED_ENTITY_SERIALIZER_EP.extensionList.associateBy { it.supportedFacetType }
|
||||
val facetTypeToSerializer = BaseIdeSerializationContext.CUSTOM_FACET_RELATED_ENTITY_SERIALIZER_EP.extensionList.associateBy { FacetEntityTypeId(it.supportedFacetType) }
|
||||
val facetMapping = facetMapping()
|
||||
val mappings = ArrayList<Pair<WorkspaceEntity, Facet<*>>>()
|
||||
for (facetContributor in WorkspaceFacetContributor.EP_NAME.extensionList) {
|
||||
@@ -148,7 +145,7 @@ class FacetModelBridge(private val moduleBridge: ModuleBridge) : FacetModelBase(
|
||||
}
|
||||
}
|
||||
else {
|
||||
moduleEntity.facets.filter { !facetTypeToSerializer.containsKey(it.facetType) }.forEach {
|
||||
moduleEntity.facets.filter { !facetTypeToSerializer.containsKey(it.typeId) }.forEach {
|
||||
fun initFacet(entity: FacetEntity): Facet<*> {
|
||||
val under = entity.underlyingFacet?.let { initFacet(it) }
|
||||
var existingFacet = facetMapping().getDataByEntity(entity)
|
||||
@@ -190,13 +187,13 @@ class FacetModelBridge(private val moduleBridge: ModuleBridge) : FacetModelBase(
|
||||
|
||||
internal fun createFacet(entity: FacetEntity, underlyingFacet: Facet<*>?): Facet<*> {
|
||||
val registry = FacetTypeRegistry.getInstance()
|
||||
val facetType = registry.findFacetType(entity.facetType)
|
||||
val facetType = registry.findFacetType(entity.typeId.name)
|
||||
if (facetType == null) {
|
||||
return FacetManagerBase.createInvalidFacet(moduleBridge, FacetState().apply {
|
||||
name = entity.name
|
||||
setFacetType(entity.facetType)
|
||||
setFacetType(entity.typeId.name)
|
||||
configuration = entity.configurationXmlTag?.let { JDOMUtil.load(it) }
|
||||
}, underlyingFacet, ProjectBundle.message("error.message.unknown.facet.type.0", entity.facetType), true, true)
|
||||
}, underlyingFacet, ProjectBundle.message("error.message.unknown.facet.type.0", entity.typeId.name), true, true)
|
||||
}
|
||||
|
||||
val configuration = facetType.createDefaultConfiguration()
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ class ModifiableFacetModelBridgeImpl(private val initialStorage: EntityStorage,
|
||||
val facetConfigurationXml = FacetUtil.saveFacetConfiguration(facet)?.let { JDOMUtil.write(it) }
|
||||
val underlyingEntity = facet.underlyingFacet?.let { diff.facetMapping().getEntities(it).single() as FacetEntity }
|
||||
val facetTypeId = if (facet !is InvalidFacet) facet.type.stringId else facet.configuration.facetState.facetType
|
||||
val entity = diff addEntity FacetEntity(facet.name, moduleEntity.symbolicId, facetTypeId, source) {
|
||||
val entity = diff addEntity FacetEntity(facet.name, moduleEntity.symbolicId, FacetEntityTypeId(facetTypeId), source) {
|
||||
configurationXmlTag = facetConfigurationXml
|
||||
module = moduleEntity
|
||||
underlyingFacet = underlyingEntity
|
||||
|
||||
+2
-5
@@ -4,10 +4,7 @@ package com.intellij.workspaceModel.ide.impl
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.backend.workspace.WorkspaceModel
|
||||
import com.intellij.platform.workspace.jps.entities.FacetEntity
|
||||
import com.intellij.platform.workspace.jps.entities.FacetId
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleEntity
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleId
|
||||
import com.intellij.platform.workspace.jps.entities.*
|
||||
import com.intellij.platform.workspace.storage.EntityChange
|
||||
import com.intellij.platform.workspace.storage.EntityStorage
|
||||
import com.intellij.platform.workspace.storage.WorkspaceEntity
|
||||
@@ -22,7 +19,7 @@ class EntityTracingLogger {
|
||||
when (tokens.size) {
|
||||
3 -> {
|
||||
val (moduleName, facetTypeId, facetName) = tokens
|
||||
FacetId(facetName, facetTypeId, ModuleId(moduleName))
|
||||
FacetId(facetName, FacetEntityTypeId(facetTypeId), ModuleId(moduleName))
|
||||
}
|
||||
1 -> ModuleId(tokens.first())
|
||||
else -> null
|
||||
|
||||
+7
-6
@@ -163,7 +163,7 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name =
|
||||
|
||||
typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.FacetId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "type", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "type", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.FacetEntityTypeId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf())), withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "parentId", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.ModuleId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId"))), withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId"))
|
||||
|
||||
@@ -412,12 +412,12 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name =
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "moduleId", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.ModuleId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId"))), withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "module", valueType = ValueTypeMetadata.EntityReference(connectionType = ConnectionId.ConnectionType.ONE_TO_MANY, entityFqName = "com.intellij.platform.workspace.jps.entities.ModuleEntity", isChild = false, isNullable = false), withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "facetType", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "typeId", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.FacetEntityTypeId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf())), withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "configurationXmlTag", valueType = primitiveTypeStringNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "underlyingFacet", valueType = ValueTypeMetadata.EntityReference(connectionType = ConnectionId.ConnectionType.ONE_TO_MANY, entityFqName = "com.intellij.platform.workspace.jps.entities.FacetEntity", isChild = false, isNullable = true), withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = true, isKey = false, isOpen = false, name = "symbolicId", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.FacetId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "type", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "type", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.FacetEntityTypeId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf())), withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "parentId", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "com.intellij.platform.workspace.jps.entities.ModuleId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false),
|
||||
OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId"))), withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId"))), withDefault = false)), extProperties = listOf(ExtPropertyMetadata(isComputable = false, isOpen = false, name = "childrenFacets", receiverFqn = "com.intellij.platform.workspace.jps.entities.FacetEntity", valueType = ValueTypeMetadata.EntityReference(connectionType = ConnectionId.ConnectionType.ONE_TO_MANY, entityFqName = "com.intellij.platform.workspace.jps.entities.FacetEntity", isChild = true, isNullable = false), withDefault = false)), isAbstract = false)
|
||||
|
||||
@@ -599,7 +599,7 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name =
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.ExcludeUrlEntity", metadataHash = -827124331)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.ExcludeUrlOrderEntity", metadataHash = -2115225774)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.ExternalSystemModuleOptionsEntity", metadataHash = 1113105028)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.FacetEntity", metadataHash = 2025153625)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.FacetEntity", metadataHash = 1372939205)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.FacetsOrderEntity", metadataHash = 351485456)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryEntity", metadataHash = 856518134)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryPropertiesEntity", metadataHash = 242117557)
|
||||
@@ -618,7 +618,8 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name =
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryTableId\$ModuleLibraryTableId", metadataHash = -1817822292)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.ModuleId", metadataHash = -684863835)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryTableId\$ProjectLibraryTableId", metadataHash = -1574432194)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.FacetId", metadataHash = 126109331)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.FacetEntityTypeId", metadataHash = -963163377)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.FacetId", metadataHash = 1507367017)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryTypeId", metadataHash = 282033134)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryRoot", metadataHash = -909142712)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.LibraryRootTypeId", metadataHash = -389178127)
|
||||
@@ -635,7 +636,7 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name =
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.SdkRoot", metadataHash = 18907249)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.SdkRootTypeId", metadataHash = 1718825746)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.SourceRootTypeId", metadataHash = 619871016)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.storage.SymbolicEntityId", metadataHash = 1426059948)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.storage.SymbolicEntityId", metadataHash = 1670602672)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.storage.EntitySource", metadataHash = 1035119344)
|
||||
addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.CustomModuleEntitySource", metadataHash = -826697445)
|
||||
addMetadataHash(typeFqn = "com.intellij.java.configurationStore.SampleDummyParentCustomModuleEntitySource", metadataHash = -1785529430)
|
||||
|
||||
+19
-19
@@ -1,7 +1,6 @@
|
||||
// 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.jps.entities
|
||||
|
||||
import com.intellij.platform.workspace.storage.*
|
||||
import com.intellij.platform.workspace.storage.EntityInformation
|
||||
import com.intellij.platform.workspace.storage.EntitySource
|
||||
import com.intellij.platform.workspace.storage.EntityType
|
||||
@@ -57,10 +56,10 @@ open class FacetEntityImpl(private val dataSource: FacetEntityData) : FacetEntit
|
||||
override val module: ModuleEntity
|
||||
get() = snapshot.extractOneToManyParent(MODULE_CONNECTION_ID, this)!!
|
||||
|
||||
override val facetType: String
|
||||
override val typeId: FacetEntityTypeId
|
||||
get() {
|
||||
readField("facetType")
|
||||
return dataSource.facetType
|
||||
readField("typeId")
|
||||
return dataSource.typeId
|
||||
}
|
||||
|
||||
override val configurationXmlTag: String?
|
||||
@@ -131,8 +130,8 @@ open class FacetEntityImpl(private val dataSource: FacetEntityData) : FacetEntit
|
||||
error("Field FacetEntity#module should be initialized")
|
||||
}
|
||||
}
|
||||
if (!getEntityData().isFacetTypeInitialized()) {
|
||||
error("Field FacetEntity#facetType should be initialized")
|
||||
if (!getEntityData().isTypeIdInitialized()) {
|
||||
error("Field FacetEntity#typeId should be initialized")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +145,7 @@ open class FacetEntityImpl(private val dataSource: FacetEntityData) : FacetEntit
|
||||
if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource
|
||||
if (this.name != dataSource.name) this.name = dataSource.name
|
||||
if (this.moduleId != dataSource.moduleId) this.moduleId = dataSource.moduleId
|
||||
if (this.facetType != dataSource.facetType) this.facetType = dataSource.facetType
|
||||
if (this.typeId != dataSource.typeId) this.typeId = dataSource.typeId
|
||||
if (this.configurationXmlTag != dataSource?.configurationXmlTag) this.configurationXmlTag = dataSource.configurationXmlTag
|
||||
updateChildToParentReferences(parents)
|
||||
}
|
||||
@@ -217,12 +216,13 @@ open class FacetEntityImpl(private val dataSource: FacetEntityData) : FacetEntit
|
||||
changedProperty.add("module")
|
||||
}
|
||||
|
||||
override var facetType: String
|
||||
get() = getEntityData().facetType
|
||||
override var typeId: FacetEntityTypeId
|
||||
get() = getEntityData().typeId
|
||||
set(value) {
|
||||
checkModificationAllowed()
|
||||
getEntityData(true).facetType = value
|
||||
changedProperty.add("facetType")
|
||||
getEntityData(true).typeId = value
|
||||
changedProperty.add("typeId")
|
||||
|
||||
}
|
||||
|
||||
override var configurationXmlTag: String?
|
||||
@@ -279,12 +279,12 @@ open class FacetEntityImpl(private val dataSource: FacetEntityData) : FacetEntit
|
||||
class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity>(), SoftLinkable {
|
||||
lateinit var name: String
|
||||
lateinit var moduleId: ModuleId
|
||||
lateinit var facetType: String
|
||||
lateinit var typeId: FacetEntityTypeId
|
||||
var configurationXmlTag: String? = null
|
||||
|
||||
internal fun isNameInitialized(): Boolean = ::name.isInitialized
|
||||
internal fun isModuleIdInitialized(): Boolean = ::moduleId.isInitialized
|
||||
internal fun isFacetTypeInitialized(): Boolean = ::facetType.isInitialized
|
||||
internal fun isTypeIdInitialized(): Boolean = ::typeId.isInitialized
|
||||
|
||||
override fun getLinks(): Set<SymbolicEntityId<*>> {
|
||||
val result = HashSet<SymbolicEntityId<*>>()
|
||||
@@ -347,7 +347,7 @@ class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity
|
||||
}
|
||||
|
||||
override fun symbolicId(): SymbolicEntityId<*> {
|
||||
return FacetId(name, facetType, moduleId)
|
||||
return FacetId(name, typeId, moduleId)
|
||||
}
|
||||
|
||||
override fun getEntityInterface(): Class<out WorkspaceEntity> {
|
||||
@@ -361,7 +361,7 @@ class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity
|
||||
}
|
||||
|
||||
override fun createDetachedEntity(parents: List<WorkspaceEntity>): WorkspaceEntity {
|
||||
return FacetEntity(name, moduleId, facetType, entitySource) {
|
||||
return FacetEntity(name, moduleId, typeId, entitySource) {
|
||||
this.configurationXmlTag = this@FacetEntityData.configurationXmlTag
|
||||
parents.filterIsInstance<ModuleEntity>().singleOrNull()?.let { this.module = it }
|
||||
this.underlyingFacet = parents.filterIsInstance<FacetEntity>().singleOrNull()
|
||||
@@ -383,7 +383,7 @@ class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity
|
||||
if (this.entitySource != other.entitySource) return false
|
||||
if (this.name != other.name) return false
|
||||
if (this.moduleId != other.moduleId) return false
|
||||
if (this.facetType != other.facetType) return false
|
||||
if (this.typeId != other.typeId) return false
|
||||
if (this.configurationXmlTag != other.configurationXmlTag) return false
|
||||
return true
|
||||
}
|
||||
@@ -396,7 +396,7 @@ class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity
|
||||
|
||||
if (this.name != other.name) return false
|
||||
if (this.moduleId != other.moduleId) return false
|
||||
if (this.facetType != other.facetType) return false
|
||||
if (this.typeId != other.typeId) return false
|
||||
if (this.configurationXmlTag != other.configurationXmlTag) return false
|
||||
return true
|
||||
}
|
||||
@@ -405,7 +405,7 @@ class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity
|
||||
var result = entitySource.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + moduleId.hashCode()
|
||||
result = 31 * result + facetType.hashCode()
|
||||
result = 31 * result + typeId.hashCode()
|
||||
result = 31 * result + configurationXmlTag.hashCode()
|
||||
return result
|
||||
}
|
||||
@@ -414,7 +414,7 @@ class FacetEntityData : WorkspaceEntityData.WithCalculableSymbolicId<FacetEntity
|
||||
var result = javaClass.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + moduleId.hashCode()
|
||||
result = 31 * result + facetType.hashCode()
|
||||
result = 31 * result + typeId.hashCode()
|
||||
result = 31 * result + configurationXmlTag.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
+10
-6
@@ -24,10 +24,12 @@ import org.jetbrains.annotations.NonNls
|
||||
|
||||
@GeneratedCodeApiVersion(2)
|
||||
@GeneratedCodeImplVersion(3)
|
||||
open class LibraryPropertiesEntityImpl(private val dataSource: LibraryPropertiesEntityData) : LibraryPropertiesEntity, WorkspaceEntityBase(dataSource) {
|
||||
open class LibraryPropertiesEntityImpl(private val dataSource: LibraryPropertiesEntityData) : LibraryPropertiesEntity, WorkspaceEntityBase(
|
||||
dataSource) {
|
||||
|
||||
private companion object {
|
||||
internal val LIBRARY_CONNECTION_ID: ConnectionId = ConnectionId.create(LibraryEntity::class.java, LibraryPropertiesEntity::class.java, ConnectionId.ConnectionType.ONE_TO_ONE, false)
|
||||
internal val LIBRARY_CONNECTION_ID: ConnectionId = ConnectionId.create(LibraryEntity::class.java, LibraryPropertiesEntity::class.java,
|
||||
ConnectionId.ConnectionType.ONE_TO_ONE, false)
|
||||
|
||||
private val connections = listOf<ConnectionId>(
|
||||
LIBRARY_CONNECTION_ID,
|
||||
@@ -55,7 +57,8 @@ open class LibraryPropertiesEntityImpl(private val dataSource: LibraryProperties
|
||||
}
|
||||
|
||||
|
||||
class Builder(result: LibraryPropertiesEntityData?) : ModifiableWorkspaceEntityBase<LibraryPropertiesEntity, LibraryPropertiesEntityData>(result), LibraryPropertiesEntity.Builder {
|
||||
class Builder(result: LibraryPropertiesEntityData?) : ModifiableWorkspaceEntityBase<LibraryPropertiesEntity, LibraryPropertiesEntityData>(
|
||||
result), LibraryPropertiesEntity.Builder {
|
||||
constructor() : this(LibraryPropertiesEntityData())
|
||||
|
||||
override fun applyToBuilder(builder: MutableEntityStorage) {
|
||||
@@ -125,8 +128,8 @@ open class LibraryPropertiesEntityImpl(private val dataSource: LibraryProperties
|
||||
get() {
|
||||
val _diff = diff
|
||||
return if (_diff != null) {
|
||||
_diff.extractOneToOneParent(LIBRARY_CONNECTION_ID, this)
|
||||
?: this.entityLinks[EntityLink(false, LIBRARY_CONNECTION_ID)]!! as LibraryEntity
|
||||
_diff.extractOneToOneParent(LIBRARY_CONNECTION_ID, this) ?: this.entityLinks[EntityLink(false,
|
||||
LIBRARY_CONNECTION_ID)]!! as LibraryEntity
|
||||
}
|
||||
else {
|
||||
this.entityLinks[EntityLink(false, LIBRARY_CONNECTION_ID)]!! as LibraryEntity
|
||||
@@ -192,7 +195,8 @@ class LibraryPropertiesEntityData : WorkspaceEntityData<LibraryPropertiesEntity>
|
||||
}
|
||||
|
||||
override fun getMetadata(): EntityMetadata {
|
||||
return MetadataStorageImpl.getMetadataByTypeFqn("com.intellij.platform.workspace.jps.entities.LibraryPropertiesEntity") as EntityMetadata
|
||||
return MetadataStorageImpl.getMetadataByTypeFqn(
|
||||
"com.intellij.platform.workspace.jps.entities.LibraryPropertiesEntity") as EntityMetadata
|
||||
}
|
||||
|
||||
override fun getEntityInterface(): Class<out WorkspaceEntity> {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// 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.jps.entities
|
||||
|
||||
import com.intellij.platform.workspace.storage.*
|
||||
import com.intellij.platform.workspace.storage.EntitySource
|
||||
import com.intellij.platform.workspace.storage.EntityType
|
||||
import com.intellij.platform.workspace.storage.GeneratedCodeApiVersion
|
||||
@@ -10,19 +9,21 @@ import com.intellij.platform.workspace.storage.WorkspaceEntity
|
||||
import com.intellij.platform.workspace.storage.annotations.Child
|
||||
import org.jetbrains.annotations.NonNls
|
||||
|
||||
data class FacetEntityTypeId(val name: @NonNls String)
|
||||
|
||||
/**
|
||||
* Describes a [Facet][com.intellij.facet.Facet].
|
||||
* See [package documentation](psi_element://com.intellij.platform.workspace.jps.entities) for more details.
|
||||
*/
|
||||
interface FacetEntity: ModuleSettingsBase {
|
||||
val module: ModuleEntity
|
||||
val facetType: @NonNls String
|
||||
val typeId: FacetEntityTypeId
|
||||
val configurationXmlTag: @NonNls String?
|
||||
|
||||
// underlyingFacet is a parent facet!!
|
||||
val underlyingFacet: FacetEntity?
|
||||
override val symbolicId: FacetId
|
||||
get() = FacetId(name, facetType, moduleId)
|
||||
get() = FacetId(name, typeId, moduleId)
|
||||
|
||||
//region generated code
|
||||
@GeneratedCodeApiVersion(2)
|
||||
@@ -31,7 +32,7 @@ interface FacetEntity: ModuleSettingsBase {
|
||||
override var name: String
|
||||
override var moduleId: ModuleId
|
||||
override var module: ModuleEntity
|
||||
override var facetType: String
|
||||
override var typeId: FacetEntityTypeId
|
||||
override var configurationXmlTag: String?
|
||||
override var underlyingFacet: FacetEntity?
|
||||
}
|
||||
@@ -43,14 +44,14 @@ interface FacetEntity: ModuleSettingsBase {
|
||||
operator fun invoke(
|
||||
name: String,
|
||||
moduleId: ModuleId,
|
||||
facetType: String,
|
||||
typeId: FacetEntityTypeId,
|
||||
entitySource: EntitySource,
|
||||
init: (Builder.() -> Unit)? = null,
|
||||
): FacetEntity {
|
||||
val builder = builder()
|
||||
builder.name = name
|
||||
builder.moduleId = moduleId
|
||||
builder.facetType = facetType
|
||||
builder.typeId = typeId
|
||||
builder.entitySource = entitySource
|
||||
init?.invoke(builder)
|
||||
return builder
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ data class ModuleId(val name: @NlsSafe String) : SymbolicEntityId<ModuleEntity>
|
||||
override fun hashCode(): Int = name.hashCode()
|
||||
}
|
||||
|
||||
data class FacetId(val name: @NlsSafe String, val type: @NonNls String, val parentId: ModuleId) : SymbolicEntityId<FacetEntity> {
|
||||
data class FacetId(val name: @NlsSafe String, val type: FacetEntityTypeId, val parentId: ModuleId) : SymbolicEntityId<FacetEntity> {
|
||||
override val presentableName: String
|
||||
get() = name
|
||||
}
|
||||
|
||||
+9
-8
@@ -3,16 +3,16 @@ package com.intellij.platform.workspace.jps.serialization.impl
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.platform.workspace.jps.JpsImportedEntitySource
|
||||
import com.intellij.platform.workspace.jps.entities.FacetEntity
|
||||
import com.intellij.platform.workspace.jps.entities.FacetId
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleEntity
|
||||
import com.intellij.platform.workspace.jps.entities.childrenFacets
|
||||
import com.intellij.platform.workspace.jps.entities.*
|
||||
import com.intellij.platform.workspace.storage.EntitySource
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.jps.model.serialization.facet.FacetState
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.function.Function
|
||||
|
||||
private val facetEntityTypes = ConcurrentFactoryMap.createMap<String, FacetEntityTypeId> { FacetEntityTypeId(it) }
|
||||
|
||||
class DefaultFacetEntitySerializer: CustomFacetRelatedEntitySerializer<FacetEntity> {
|
||||
override val rootEntityType: Class<FacetEntity>
|
||||
get() = FacetEntity::class.java
|
||||
@@ -40,8 +40,9 @@ class DefaultFacetEntitySerializer: CustomFacetRelatedEntitySerializer<FacetEnti
|
||||
val configurationXmlTag = configurationXmlTagRaw?.let { configurationStringInterner.computeIfAbsent(it, Function.identity()) }
|
||||
|
||||
// Check for existing facet it's needed in cases when we read sub-facet located in .xml but underling facet is from .iml,
|
||||
// thus same root facet will be declared in two places
|
||||
val newFacetId = FacetId(facetState.name, facetState.facetType, moduleEntity.symbolicId)
|
||||
// thus the same root facet will be declared in two places
|
||||
val facetEntityTypeId = facetEntityTypes[facetState.facetType]!!
|
||||
val newFacetId = FacetId(facetState.name, facetEntityTypeId, moduleEntity.symbolicId)
|
||||
var facetEntity: FacetEntity? = null
|
||||
val existingFacet = findFacetById(moduleEntity.facets, newFacetId)
|
||||
if (existingFacet != null && configurationXmlTag != null) {
|
||||
@@ -55,7 +56,7 @@ class DefaultFacetEntitySerializer: CustomFacetRelatedEntitySerializer<FacetEnti
|
||||
}
|
||||
|
||||
if (existingFacet == null) {
|
||||
facetEntity = FacetEntity(facetState.name, moduleEntity.symbolicId, facetState.facetType, entitySource) {
|
||||
facetEntity = FacetEntity(facetState.name, moduleEntity.symbolicId, facetEntityTypeId, entitySource) {
|
||||
this.configurationXmlTag = configurationXmlTag
|
||||
this.module = moduleEntity
|
||||
this.underlyingFacet = underlyingFacet
|
||||
@@ -93,7 +94,7 @@ class DefaultFacetEntitySerializer: CustomFacetRelatedEntitySerializer<FacetEnti
|
||||
|
||||
val state = FacetState().apply {
|
||||
name = facetEntity.name
|
||||
facetType = facetEntity.facetType
|
||||
facetType = facetEntity.typeId.name
|
||||
val externalSystemIdValue = (facetEntity.entitySource as? JpsImportedEntitySource)?.externalSystemId
|
||||
if (storeExternally) {
|
||||
externalSystemId = externalSystemIdValue
|
||||
|
||||
+7
-4
@@ -13,6 +13,7 @@ import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.platform.backend.workspace.WorkspaceModel
|
||||
import com.intellij.platform.workspace.jps.JpsProjectFileEntitySource
|
||||
import com.intellij.platform.workspace.jps.entities.FacetEntity
|
||||
import com.intellij.platform.workspace.jps.entities.FacetEntityTypeId
|
||||
import com.intellij.platform.workspace.jps.entities.ModuleEntity
|
||||
import com.intellij.platform.workspace.jps.entities.modifyEntity
|
||||
import com.intellij.platform.workspace.storage.MutableEntityStorage
|
||||
@@ -38,6 +39,8 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.assertDoesNotThrow
|
||||
|
||||
internal val MOCK_FACET_TYPE_ID = FacetEntityTypeId("MockFacetId")
|
||||
|
||||
class FacetModelBridgeTest {
|
||||
companion object {
|
||||
@ClassRule
|
||||
@@ -101,7 +104,7 @@ class FacetModelBridgeTest {
|
||||
|
||||
val moduleEntity = builder addEntity ModuleEntity(name = "test", dependencies = emptyList(), entitySource = source)
|
||||
|
||||
builder addEntity FacetEntity("MyFacet", moduleEntity.symbolicId, "MockFacetId", source) {
|
||||
builder addEntity FacetEntity("MyFacet", moduleEntity.symbolicId, MOCK_FACET_TYPE_ID, source) {
|
||||
configurationXmlTag = """<configuration data="foo" />"""
|
||||
module = moduleEntity
|
||||
}
|
||||
@@ -132,7 +135,7 @@ class FacetModelBridgeTest {
|
||||
|
||||
val moduleEntity = builder addEntity ModuleEntity(name = "test", dependencies = emptyList(), entitySource = source)
|
||||
|
||||
builder addEntity FacetEntity("AnotherMockFacet", moduleEntity.symbolicId, "AnotherMockFacetId", source) {
|
||||
builder addEntity FacetEntity("AnotherMockFacet", moduleEntity.symbolicId, FacetEntityTypeId("AnotherMockFacetId"), source) {
|
||||
configurationXmlTag = """
|
||||
<AnotherFacetConfigProperties>
|
||||
<firstElement>
|
||||
@@ -200,9 +203,9 @@ class FacetModelBridgeTest {
|
||||
runWriteActionAndWait {
|
||||
WorkspaceModel.getInstance(projectModel.project).updateProjectModel { builder ->
|
||||
val moduleEntity = builder.entities<ModuleEntity>().first()
|
||||
builder addEntity FacetEntity("myName", moduleEntity.symbolicId, "MockFacetId", moduleEntity.entitySource) {
|
||||
builder addEntity FacetEntity("myName", moduleEntity.symbolicId, MOCK_FACET_TYPE_ID, moduleEntity.entitySource) {
|
||||
this.module = moduleEntity
|
||||
underlyingFacet = FacetEntity("anotherName", moduleEntity.symbolicId, "MockFacetId", moduleEntity.entitySource) {
|
||||
underlyingFacet = FacetEntity("anotherName", moduleEntity.symbolicId, MOCK_FACET_TYPE_ID, moduleEntity.entitySource) {
|
||||
this.module = moduleEntity
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ class FacetWorkspaceModelTest {
|
||||
runWriteActionAndWait {
|
||||
projectModel.project.workspaceModel.updateProjectModel { builder ->
|
||||
val moduleEntity = builder.entities(ModuleEntity::class.java).first()
|
||||
builder addEntity FacetEntity("myName", moduleEntity.symbolicId, "MockFacetId", moduleEntity.entitySource) {
|
||||
builder addEntity FacetEntity("myName", moduleEntity.symbolicId, MOCK_FACET_TYPE_ID, moduleEntity.entitySource) {
|
||||
this.module = moduleEntity
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class FacetWorkspaceModelTest {
|
||||
val moduleEntity = builder.entities(ModuleEntity::class.java).first()
|
||||
Assert.assertTrue(moduleEntity.facets.isEmpty())
|
||||
builder.modifyEntity(moduleEntity) {
|
||||
this.facets = listOf(FacetEntity("myName", moduleEntity.symbolicId, "MockFacetId", moduleEntity.entitySource))
|
||||
this.facets = listOf(FacetEntity("myName", moduleEntity.symbolicId, MOCK_FACET_TYPE_ID, moduleEntity.entitySource))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ class JpsProjectEntitiesLoaderTest : HeavyPlatformTestCase() {
|
||||
val storage = loadProject(projectDir)
|
||||
val modules = storage.entities(ModuleEntity::class.java).associateBy { it.name }
|
||||
val single = modules.getValue("single").facets.single()
|
||||
assertEquals("foo", single.facetType)
|
||||
assertEquals("foo", single.typeId.name)
|
||||
assertEquals("Foo", single.name)
|
||||
assertEquals("""
|
||||
<configuration>
|
||||
|
||||
+1
-1
@@ -576,7 +576,7 @@ class JpsSplitModuleAndContentRootTest {
|
||||
val mockFacetType = MockFacetType()
|
||||
registerFacetType(mockFacetType, projectModel.disposableRule.disposable)
|
||||
val moduleEntity = builder.entities(ModuleEntity::class.java).single()
|
||||
builder addEntity FacetEntity("MyFacet", moduleEntity.symbolicId, MockFacetType.ID.toString(),
|
||||
builder addEntity FacetEntity("MyFacet", moduleEntity.symbolicId, FacetEntityTypeId(MockFacetType.ID.toString()),
|
||||
getInternalFileSource(moduleEntity.entitySource)!!) {
|
||||
this.module = moduleEntity
|
||||
}
|
||||
|
||||
+3
-3
@@ -99,9 +99,9 @@ internal class KtCompilerPluginsProviderIdeImpl(private val project: Project, cs
|
||||
|
||||
private val EntityChange<FacetEntity>.facetTypes: List<String>
|
||||
get() = when (this) {
|
||||
is EntityChange.Added -> listOf(entity.facetType)
|
||||
is EntityChange.Removed -> listOf(entity.facetType)
|
||||
is EntityChange.Replaced -> listOf(oldEntity.facetType, newEntity.facetType)
|
||||
is EntityChange.Added -> listOf(entity.typeId.name)
|
||||
is EntityChange.Removed -> listOf(entity.typeId.name)
|
||||
is EntityChange.Replaced -> listOf(oldEntity.typeId.name, newEntity.typeId.name)
|
||||
}
|
||||
|
||||
private fun createNewCache(): PluginsCache? {
|
||||
|
||||
Reference in New Issue
Block a user