sdkcompat/v251/org/jetbrains/bazel/sdkcompat/workspacemodel/entities/impl/PackageMarkerEntityImpl.kt [27:284]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @OptIn(WorkspaceEntityInternalApi::class) internal class PackageMarkerEntityImpl(private val dataSource: PackageMarkerEntityData) : PackageMarkerEntity, WorkspaceEntityBase( dataSource) { private companion object { internal val MODULE_CONNECTION_ID: ConnectionId = ConnectionId.create(ModuleEntity::class.java, PackageMarkerEntity::class.java, ConnectionId.ConnectionType.ONE_TO_MANY, false) private val connections = listOf( MODULE_CONNECTION_ID, ) } override val root: VirtualFileUrl get() { readField("root") return dataSource.root } override val packagePrefix: String get() { readField("packagePrefix") return dataSource.packagePrefix } override val module: ModuleEntity get() = snapshot.extractOneToManyParent(MODULE_CONNECTION_ID, this)!! override val entitySource: EntitySource get() { readField("entitySource") return dataSource.entitySource } override fun connectionIdList(): List { return connections } internal class Builder(result: PackageMarkerEntityData?) : ModifiableWorkspaceEntityBase( result), PackageMarkerEntity.Builder { internal constructor() : this(PackageMarkerEntityData()) override fun applyToBuilder(builder: MutableEntityStorage) { if (this.diff != null) { if (existsInBuilder(builder)) { this.diff = builder return } else { error("Entity PackageMarkerEntity is already created in a different builder") } } this.diff = builder addToBuilder() this.id = getEntityData().createEntityId() // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder // Builder may switch to snapshot at any moment and lock entity data to modification this.currentEntityData = null index(this, "root", this.root) // Process linked entities that are connected without a builder processLinkedEntities(builder) checkInitialization() // TODO uncomment and check failed tests } private fun checkInitialization() { val _diff = diff if (!getEntityData().isEntitySourceInitialized()) { error("Field WorkspaceEntity#entitySource should be initialized") } if (!getEntityData().isRootInitialized()) { error("Field PackageMarkerEntity#root should be initialized") } if (!getEntityData().isPackagePrefixInitialized()) { error("Field PackageMarkerEntity#packagePrefix should be initialized") } if (_diff != null) { if (_diff.extractOneToManyParent(MODULE_CONNECTION_ID, this) == null) { error("Field PackageMarkerEntity#module should be initialized") } } else { if (this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)] == null) { error("Field PackageMarkerEntity#module should be initialized") } } } override fun connectionIdList(): List { return connections } // Relabeling code, move information from dataSource to this builder override fun relabel(dataSource: WorkspaceEntity, parents: Set?) { dataSource as PackageMarkerEntity if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource if (this.root != dataSource.root) this.root = dataSource.root if (this.packagePrefix != dataSource.packagePrefix) this.packagePrefix = dataSource.packagePrefix updateChildToParentReferences(parents) } override var entitySource: EntitySource get() = getEntityData().entitySource set(value) { checkModificationAllowed() getEntityData(true).entitySource = value changedProperty.add("entitySource") } override var root: VirtualFileUrl get() = getEntityData().root set(value) { checkModificationAllowed() getEntityData(true).root = value changedProperty.add("root") val _diff = diff if (_diff != null) index(this, "root", value) } override var packagePrefix: String get() = getEntityData().packagePrefix set(value) { checkModificationAllowed() getEntityData(true).packagePrefix = value changedProperty.add("packagePrefix") } override var module: ModuleEntity.Builder get() { val _diff = diff return if (_diff != null) { @OptIn(EntityStorageInstrumentationApi::class) ((_diff as MutableEntityStorageInstrumentation).getParentBuilder(MODULE_CONNECTION_ID, this) as? ModuleEntity.Builder) ?: (this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)]!! as ModuleEntity.Builder) } else { this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)]!! as ModuleEntity.Builder } } set(value) { checkModificationAllowed() val _diff = diff if (_diff != null && value is ModifiableWorkspaceEntityBase<*, *> && value.diff == null) { // Setting backref of the list if (value is ModifiableWorkspaceEntityBase<*, *>) { val data = (value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] as? List ?: arrayListOf()) + this value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] = data } // else you're attaching a new entity to an existing entity that is not modifiable _diff.addEntity(value as ModifiableWorkspaceEntityBase) } if (_diff != null && (value !is ModifiableWorkspaceEntityBase<*, *> || value.diff != null)) { _diff.updateOneToManyParentOfChild(MODULE_CONNECTION_ID, this, value) } else { // Setting backref of the list if (value is ModifiableWorkspaceEntityBase<*, *>) { val data = (value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] as? List ?: arrayListOf()) + this value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] = data } // else you're attaching a new entity to an existing entity that is not modifiable this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)] = value } changedProperty.add("module") } override fun getEntityClass(): Class = PackageMarkerEntity::class.java } } @OptIn(WorkspaceEntityInternalApi::class) internal class PackageMarkerEntityData : WorkspaceEntityData() { lateinit var root: VirtualFileUrl lateinit var packagePrefix: String internal fun isRootInitialized(): Boolean = ::root.isInitialized internal fun isPackagePrefixInitialized(): Boolean = ::packagePrefix.isInitialized override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder { val modifiable = PackageMarkerEntityImpl.Builder(null) modifiable.diff = diff modifiable.id = createEntityId() return modifiable } @OptIn(EntityStorageInstrumentationApi::class) override fun createEntity(snapshot: EntityStorageInstrumentation): PackageMarkerEntity { val entityId = createEntityId() return snapshot.initializeEntity(entityId) { val entity = PackageMarkerEntityImpl(this) entity.snapshot = snapshot entity.id = entityId entity } } override fun getMetadata(): EntityMetadata { return MetadataStorageImpl.getMetadataByTypeFqn( "org.jetbrains.bazel.sdkcompat.workspacemodel.entities.PackageMarkerEntity") as EntityMetadata } override fun getEntityInterface(): Class { return PackageMarkerEntity::class.java } override fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { return PackageMarkerEntity(root, packagePrefix, entitySource) { parents.filterIsInstance().singleOrNull()?.let { this.module = it } } } override fun getRequiredParents(): List> { val res = mutableListOf>() res.add(ModuleEntity::class.java) return res } override fun equals(other: Any?): Boolean { if (other == null) return false if (this.javaClass != other.javaClass) return false other as PackageMarkerEntityData if (this.entitySource != other.entitySource) return false if (this.root != other.root) return false if (this.packagePrefix != other.packagePrefix) return false return true } override fun equalsIgnoringEntitySource(other: Any?): Boolean { if (other == null) return false if (this.javaClass != other.javaClass) return false other as PackageMarkerEntityData if (this.root != other.root) return false if (this.packagePrefix != other.packagePrefix) return false return true } override fun hashCode(): Int { var result = entitySource.hashCode() result = 31 * result + root.hashCode() result = 31 * result + packagePrefix.hashCode() return result } override fun hashCodeIgnoringEntitySource(): Int { var result = javaClass.hashCode() result = 31 * result + root.hashCode() result = 31 * result + packagePrefix.hashCode() return result - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sdkcompat/v252/org/jetbrains/bazel/sdkcompat/workspacemodel/entities/impl/PackageMarkerEntityImpl.kt [28:285]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @OptIn(WorkspaceEntityInternalApi::class) internal class PackageMarkerEntityImpl(private val dataSource: PackageMarkerEntityData) : PackageMarkerEntity, WorkspaceEntityBase( dataSource) { private companion object { internal val MODULE_CONNECTION_ID: ConnectionId = ConnectionId.create(ModuleEntity::class.java, PackageMarkerEntity::class.java, ConnectionId.ConnectionType.ONE_TO_MANY, false) private val connections = listOf( MODULE_CONNECTION_ID, ) } override val root: VirtualFileUrl get() { readField("root") return dataSource.root } override val packagePrefix: String get() { readField("packagePrefix") return dataSource.packagePrefix } override val module: ModuleEntity get() = snapshot.extractOneToManyParent(MODULE_CONNECTION_ID, this)!! override val entitySource: EntitySource get() { readField("entitySource") return dataSource.entitySource } override fun connectionIdList(): List { return connections } internal class Builder(result: PackageMarkerEntityData?) : ModifiableWorkspaceEntityBase( result), PackageMarkerEntity.Builder { internal constructor() : this(PackageMarkerEntityData()) override fun applyToBuilder(builder: MutableEntityStorage) { if (this.diff != null) { if (existsInBuilder(builder)) { this.diff = builder return } else { error("Entity PackageMarkerEntity is already created in a different builder") } } this.diff = builder addToBuilder() this.id = getEntityData().createEntityId() // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder // Builder may switch to snapshot at any moment and lock entity data to modification this.currentEntityData = null index(this, "root", this.root) // Process linked entities that are connected without a builder processLinkedEntities(builder) checkInitialization() // TODO uncomment and check failed tests } private fun checkInitialization() { val _diff = diff if (!getEntityData().isEntitySourceInitialized()) { error("Field WorkspaceEntity#entitySource should be initialized") } if (!getEntityData().isRootInitialized()) { error("Field PackageMarkerEntity#root should be initialized") } if (!getEntityData().isPackagePrefixInitialized()) { error("Field PackageMarkerEntity#packagePrefix should be initialized") } if (_diff != null) { if (_diff.extractOneToManyParent(MODULE_CONNECTION_ID, this) == null) { error("Field PackageMarkerEntity#module should be initialized") } } else { if (this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)] == null) { error("Field PackageMarkerEntity#module should be initialized") } } } override fun connectionIdList(): List { return connections } // Relabeling code, move information from dataSource to this builder override fun relabel(dataSource: WorkspaceEntity, parents: Set?) { dataSource as PackageMarkerEntity if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource if (this.root != dataSource.root) this.root = dataSource.root if (this.packagePrefix != dataSource.packagePrefix) this.packagePrefix = dataSource.packagePrefix updateChildToParentReferences(parents) } override var entitySource: EntitySource get() = getEntityData().entitySource set(value) { checkModificationAllowed() getEntityData(true).entitySource = value changedProperty.add("entitySource") } override var root: VirtualFileUrl get() = getEntityData().root set(value) { checkModificationAllowed() getEntityData(true).root = value changedProperty.add("root") val _diff = diff if (_diff != null) index(this, "root", value) } override var packagePrefix: String get() = getEntityData().packagePrefix set(value) { checkModificationAllowed() getEntityData(true).packagePrefix = value changedProperty.add("packagePrefix") } override var module: ModuleEntity.Builder get() { val _diff = diff return if (_diff != null) { @OptIn(EntityStorageInstrumentationApi::class) ((_diff as MutableEntityStorageInstrumentation).getParentBuilder(MODULE_CONNECTION_ID, this) as? ModuleEntity.Builder) ?: (this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)]!! as ModuleEntity.Builder) } else { this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)]!! as ModuleEntity.Builder } } set(value) { checkModificationAllowed() val _diff = diff if (_diff != null && value is ModifiableWorkspaceEntityBase<*, *> && value.diff == null) { // Setting backref of the list if (value is ModifiableWorkspaceEntityBase<*, *>) { val data = (value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] as? List ?: arrayListOf()) + this value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] = data } // else you're attaching a new entity to an existing entity that is not modifiable _diff.addEntity(value as ModifiableWorkspaceEntityBase) } if (_diff != null && (value !is ModifiableWorkspaceEntityBase<*, *> || value.diff != null)) { _diff.updateOneToManyParentOfChild(MODULE_CONNECTION_ID, this, value) } else { // Setting backref of the list if (value is ModifiableWorkspaceEntityBase<*, *>) { val data = (value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] as? List ?: arrayListOf()) + this value.entityLinks[EntityLink(true, MODULE_CONNECTION_ID)] = data } // else you're attaching a new entity to an existing entity that is not modifiable this.entityLinks[EntityLink(false, MODULE_CONNECTION_ID)] = value } changedProperty.add("module") } override fun getEntityClass(): Class = PackageMarkerEntity::class.java } } @OptIn(WorkspaceEntityInternalApi::class) internal class PackageMarkerEntityData : WorkspaceEntityData() { lateinit var root: VirtualFileUrl lateinit var packagePrefix: String internal fun isRootInitialized(): Boolean = ::root.isInitialized internal fun isPackagePrefixInitialized(): Boolean = ::packagePrefix.isInitialized override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder { val modifiable = PackageMarkerEntityImpl.Builder(null) modifiable.diff = diff modifiable.id = createEntityId() return modifiable } @OptIn(EntityStorageInstrumentationApi::class) override fun createEntity(snapshot: EntityStorageInstrumentation): PackageMarkerEntity { val entityId = createEntityId() return snapshot.initializeEntity(entityId) { val entity = PackageMarkerEntityImpl(this) entity.snapshot = snapshot entity.id = entityId entity } } override fun getMetadata(): EntityMetadata { return MetadataStorageImpl.getMetadataByTypeFqn( "org.jetbrains.bazel.sdkcompat.workspacemodel.entities.PackageMarkerEntity") as EntityMetadata } override fun getEntityInterface(): Class { return PackageMarkerEntity::class.java } override fun createDetachedEntity(parents: List>): WorkspaceEntity.Builder<*> { return PackageMarkerEntity(root, packagePrefix, entitySource) { parents.filterIsInstance().singleOrNull()?.let { this.module = it } } } override fun getRequiredParents(): List> { val res = mutableListOf>() res.add(ModuleEntity::class.java) return res } override fun equals(other: Any?): Boolean { if (other == null) return false if (this.javaClass != other.javaClass) return false other as PackageMarkerEntityData if (this.entitySource != other.entitySource) return false if (this.root != other.root) return false if (this.packagePrefix != other.packagePrefix) return false return true } override fun equalsIgnoringEntitySource(other: Any?): Boolean { if (other == null) return false if (this.javaClass != other.javaClass) return false other as PackageMarkerEntityData if (this.root != other.root) return false if (this.packagePrefix != other.packagePrefix) return false return true } override fun hashCode(): Int { var result = entitySource.hashCode() result = 31 * result + root.hashCode() result = 31 * result + packagePrefix.hashCode() return result } override fun hashCodeIgnoringEntitySource(): Int { var result = javaClass.hashCode() result = 31 * result + root.hashCode() result = 31 * result + packagePrefix.hashCode() return result - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -