diff --git a/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/KotlinSettingsEntityImpl.kt b/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/KotlinSettingsEntityImpl.kt index 2ad994482f3f..8c10c406c8fa 100644 --- a/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/KotlinSettingsEntityImpl.kt +++ b/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/KotlinSettingsEntityImpl.kt @@ -32,7 +32,10 @@ import com.intellij.platform.workspace.storage.instrumentation.EntityStorageInst import com.intellij.platform.workspace.storage.instrumentation.MutableEntityStorageInstrumentation import com.intellij.platform.workspace.storage.metadata.model.EntityMetadata import com.intellij.util.descriptors.ConfigFileItem +import org.jetbrains.kotlin.config.KotlinFacetSettings import org.jetbrains.kotlin.config.KotlinModuleKind +import org.jetbrains.kotlin.idea.facet.KotlinFacetType +import org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsEntity.Builder @GeneratedCodeApiVersion(3) @GeneratedCodeImplVersion(5) @@ -145,19 +148,19 @@ open class KotlinSettingsEntityImpl(private val dataSource: KotlinSettingsEntity return dataSource.kind } - override val compilerArguments: String + override val compilerArguments: String? get() { readField("compilerArguments") return dataSource.compilerArguments } - override val compilerSettings: CompilerSettingsData + override val compilerSettings: CompilerSettingsData? get() { readField("compilerSettings") return dataSource.compilerSettings } - override val targetPlatform: String + override val targetPlatform: String? get() { readField("targetPlatform") return dataSource.targetPlatform @@ -267,15 +270,6 @@ open class KotlinSettingsEntityImpl(private val dataSource: KotlinSettingsEntity if (!getEntityData().isKindInitialized()) { error("Field KotlinSettingsEntity#kind should be initialized") } - if (!getEntityData().isCompilerArgumentsInitialized()) { - error("Field KotlinSettingsEntity#compilerArguments should be initialized") - } - if (!getEntityData().isCompilerSettingsInitialized()) { - error("Field KotlinSettingsEntity#compilerSettings should be initialized") - } - if (!getEntityData().isTargetPlatformInitialized()) { - error("Field KotlinSettingsEntity#targetPlatform should be initialized") - } if (!getEntityData().isExternalSystemRunTasksInitialized()) { error("Field KotlinSettingsEntity#externalSystemRunTasks should be initialized") } @@ -332,17 +326,17 @@ open class KotlinSettingsEntityImpl(private val dataSource: KotlinSettingsEntity if (this.implementedModuleNames != dataSource.implementedModuleNames) this.implementedModuleNames = dataSource.implementedModuleNames.toMutableList() if (this.dependsOnModuleNames != dataSource.dependsOnModuleNames) this.dependsOnModuleNames = dataSource.dependsOnModuleNames.toMutableList() if (this.additionalVisibleModuleNames != dataSource.additionalVisibleModuleNames) this.additionalVisibleModuleNames = dataSource.additionalVisibleModuleNames.toMutableSet() - if (this.productionOutputPath != dataSource.productionOutputPath) this.productionOutputPath = dataSource.productionOutputPath - if (this.testOutputPath != dataSource.testOutputPath) this.testOutputPath = dataSource.testOutputPath + if (this.productionOutputPath != dataSource?.productionOutputPath) this.productionOutputPath = dataSource.productionOutputPath + if (this.testOutputPath != dataSource?.testOutputPath) this.testOutputPath = dataSource.testOutputPath if (this.sourceSetNames != dataSource.sourceSetNames) this.sourceSetNames = dataSource.sourceSetNames.toMutableList() if (this.isTestModule != dataSource.isTestModule) this.isTestModule = dataSource.isTestModule if (this.externalProjectId != dataSource.externalProjectId) this.externalProjectId = dataSource.externalProjectId if (this.isHmppEnabled != dataSource.isHmppEnabled) this.isHmppEnabled = dataSource.isHmppEnabled if (this.pureKotlinSourceFolders != dataSource.pureKotlinSourceFolders) this.pureKotlinSourceFolders = dataSource.pureKotlinSourceFolders.toMutableList() if (this.kind != dataSource.kind) this.kind = dataSource.kind - if (this.compilerArguments != dataSource.compilerArguments) this.compilerArguments = dataSource.compilerArguments - if (this.compilerSettings != dataSource.compilerSettings) this.compilerSettings = dataSource.compilerSettings - if (this.targetPlatform != dataSource.targetPlatform) this.targetPlatform = dataSource.targetPlatform + if (this.compilerArguments != dataSource?.compilerArguments) this.compilerArguments = dataSource.compilerArguments + if (this.compilerSettings != dataSource?.compilerSettings) this.compilerSettings = dataSource.compilerSettings + if (this.targetPlatform != dataSource?.targetPlatform) this.targetPlatform = dataSource.targetPlatform if (this.externalSystemRunTasks != dataSource.externalSystemRunTasks) this.externalSystemRunTasks = dataSource.externalSystemRunTasks.toMutableList() if (this.version != dataSource.version) this.version = dataSource.version if (this.flushNeeded != dataSource.flushNeeded) this.flushNeeded = dataSource.flushNeeded @@ -627,7 +621,7 @@ open class KotlinSettingsEntityImpl(private val dataSource: KotlinSettingsEntity } - override var compilerArguments: String + override var compilerArguments: String? get() = getEntityData().compilerArguments set(value) { checkModificationAllowed() @@ -635,7 +629,7 @@ open class KotlinSettingsEntityImpl(private val dataSource: KotlinSettingsEntity changedProperty.add("compilerArguments") } - override var compilerSettings: CompilerSettingsData + override var compilerSettings: CompilerSettingsData? get() = getEntityData().compilerSettings set(value) { checkModificationAllowed() @@ -644,7 +638,7 @@ open class KotlinSettingsEntityImpl(private val dataSource: KotlinSettingsEntity } - override var targetPlatform: String + override var targetPlatform: String? get() = getEntityData().targetPlatform set(value) { checkModificationAllowed() @@ -703,20 +697,20 @@ class KotlinSettingsEntityData : WorkspaceEntityData.WithCalculableSymbolicId lateinit var dependsOnModuleNames: MutableList lateinit var additionalVisibleModuleNames: MutableSet + var productionOutputPath: String? = null + var testOutputPath: String? = null lateinit var sourceSetNames: MutableList var isTestModule: Boolean = false lateinit var externalProjectId: String var isHmppEnabled: Boolean = false lateinit var pureKotlinSourceFolders: MutableList lateinit var kind: KotlinModuleKind - lateinit var compilerArguments: String - lateinit var compilerSettings: CompilerSettingsData - lateinit var targetPlatform: String + var compilerArguments: String? = null + var compilerSettings: CompilerSettingsData? = null + var targetPlatform: String? = null lateinit var externalSystemRunTasks: MutableList var version: Int = 0 var flushNeeded: Boolean = false - var productionOutputPath: String? = null - var testOutputPath: String? = null internal fun isNameInitialized(): Boolean = ::name.isInitialized internal fun isModuleIdInitialized(): Boolean = ::moduleId.isInitialized @@ -732,9 +726,6 @@ class KotlinSettingsEntityData : WorkspaceEntityData.WithCalculableSymbolicId>): WorkspaceEntity.Builder<*> { return KotlinSettingsEntity(name, moduleId, sourceRoots, configFileItems, useProjectSettings, implementedModuleNames, - dependsOnModuleNames, additionalVisibleModuleNames, productionOutputPath, testOutputPath, sourceSetNames, - isTestModule, externalProjectId, isHmppEnabled, pureKotlinSourceFolders, kind, compilerArguments, - compilerSettings, targetPlatform, externalSystemRunTasks, version, flushNeeded, entitySource) { + dependsOnModuleNames, additionalVisibleModuleNames, sourceSetNames, isTestModule, externalProjectId, + isHmppEnabled, pureKotlinSourceFolders, kind, externalSystemRunTasks, version, flushNeeded, entitySource) { + this.productionOutputPath = this@KotlinSettingsEntityData.productionOutputPath + this.testOutputPath = this@KotlinSettingsEntityData.testOutputPath + this.compilerArguments = this@KotlinSettingsEntityData.compilerArguments + this.compilerSettings = this@KotlinSettingsEntityData.compilerSettings + this.targetPlatform = this@KotlinSettingsEntityData.targetPlatform parents.filterIsInstance().singleOrNull()?.let { this.module = it } } } diff --git a/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/MetadataStorageImpl.kt b/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/MetadataStorageImpl.kt index 22c4274bacd3..7b8867132303 100644 --- a/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/MetadataStorageImpl.kt +++ b/plugins/kotlin/base/facet/gen/org/jetbrains/kotlin/idea/workspaceModel/MetadataStorageImpl.kt @@ -16,14 +16,15 @@ object MetadataStorageImpl: MetadataStorageBase() { val primitiveTypeListNotNullable = ValueTypeMetadata.SimpleType.PrimitiveType(isNullable = false, type = "List") val primitiveTypeBooleanNotNullable = ValueTypeMetadata.SimpleType.PrimitiveType(isNullable = false, type = "Boolean") val primitiveTypeSetNotNullable = ValueTypeMetadata.SimpleType.PrimitiveType(isNullable = false, type = "Set") + val primitiveTypeStringNullable = ValueTypeMetadata.SimpleType.PrimitiveType(isNullable = true, type = "String") val primitiveTypeIntNotNullable = ValueTypeMetadata.SimpleType.PrimitiveType(isNullable = false, type = "Int") var typeMetadata: StorageTypeMetadata - typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsId", 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 = "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")) + typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsId", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "name", valueType = primitiveTypeStringNotNullable, 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 = "name", valueType = primitiveTypeStringNotNullable, withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId"))), withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "presentableName", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf("com.intellij.platform.workspace.storage.SymbolicEntityId")) addMetadata(typeMetadata) @@ -41,8 +42,8 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "implementedModuleNames", valueType = ValueTypeMetadata.ParameterizedType(generics = listOf(primitiveTypeStringNotNullable), primitive = primitiveTypeListNotNullable), withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "dependsOnModuleNames", valueType = ValueTypeMetadata.ParameterizedType(generics = listOf(primitiveTypeStringNotNullable), primitive = primitiveTypeListNotNullable), withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "additionalVisibleModuleNames", valueType = ValueTypeMetadata.ParameterizedType(generics = listOf(primitiveTypeStringNotNullable), primitive = primitiveTypeSetNotNullable), withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "productionOutputPath", valueType = primitiveTypeStringNotNullable, withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "testOutputPath", valueType = primitiveTypeStringNotNullable, withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "productionOutputPath", valueType = primitiveTypeStringNullable, withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "testOutputPath", valueType = primitiveTypeStringNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "sourceSetNames", valueType = ValueTypeMetadata.ParameterizedType(generics = listOf(primitiveTypeStringNotNullable), primitive = primitiveTypeListNotNullable), withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "isTestModule", valueType = primitiveTypeBooleanNotNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "externalProjectId", valueType = primitiveTypeStringNotNullable, withDefault = false), @@ -53,14 +54,13 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "java.io.Serializable"), values = listOf("DEFAULT", "SOURCE_SET_HOLDER", "COMPILATION_AND_SOURCE_SET_HOLDER"))), withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "compilerArguments", valueType = primitiveTypeStringNotNullable, withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "compilerSettings", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = false, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "org.jetbrains.kotlin.idea.workspaceModel.CompilerSettingsData", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "additionalArguments", valueType = primitiveTypeStringNotNullable, withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "compilerArguments", valueType = primitiveTypeStringNullable, withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "compilerSettings", valueType = ValueTypeMetadata.SimpleType.CustomType(isNullable = true, typeMetadata = FinalClassMetadata.ClassMetadata(fqName = "org.jetbrains.kotlin.idea.workspaceModel.CompilerSettingsData", properties = listOf(OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "additionalArguments", valueType = primitiveTypeStringNotNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "scriptTemplates", valueType = primitiveTypeStringNotNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "scriptTemplatesClasspath", valueType = primitiveTypeStringNotNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "copyJsLibraryFiles", valueType = primitiveTypeBooleanNotNullable, withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "outputDirectoryForJsLibraryFiles", valueType = primitiveTypeStringNotNullable, withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "isInitialized", valueType = primitiveTypeBooleanNotNullable, withDefault = false)), supertypes = listOf())), withDefault = false), -OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "targetPlatform", valueType = primitiveTypeStringNotNullable, withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "outputDirectoryForJsLibraryFiles", valueType = primitiveTypeStringNotNullable, withDefault = false)), supertypes = listOf())), withDefault = false), +OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "targetPlatform", valueType = primitiveTypeStringNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "externalSystemRunTasks", valueType = ValueTypeMetadata.ParameterizedType(generics = listOf(primitiveTypeStringNotNullable), primitive = primitiveTypeListNotNullable), withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "version", valueType = primitiveTypeIntNotNullable, withDefault = false), OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = "flushNeeded", valueType = primitiveTypeBooleanNotNullable, withDefault = false), @@ -73,13 +73,13 @@ OwnPropertyMetadata(isComputable = false, isKey = false, isOpen = false, name = } override fun initializeMetadataHash() { - addMetadataHash(typeFqn = "org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsEntity", metadataHash = -1478960381) - addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.ModuleId", metadataHash = -684863835) + addMetadataHash(typeFqn = "org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsEntity", metadataHash = 1261471986) + addMetadataHash(typeFqn = "com.intellij.platform.workspace.jps.entities.ModuleId", metadataHash = -575206713) addMetadataHash(typeFqn = "com.intellij.util.descriptors.ConfigFileItem", metadataHash = -445249281) addMetadataHash(typeFqn = "org.jetbrains.kotlin.config.KotlinModuleKind", metadataHash = -848779934) - addMetadataHash(typeFqn = "org.jetbrains.kotlin.idea.workspaceModel.CompilerSettingsData", metadataHash = 26052836) - addMetadataHash(typeFqn = "org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsId", metadataHash = -1378190363) - addMetadataHash(typeFqn = "com.intellij.platform.workspace.storage.SymbolicEntityId", metadataHash = -592653735) + addMetadataHash(typeFqn = "org.jetbrains.kotlin.idea.workspaceModel.CompilerSettingsData", metadataHash = -2034595788) + addMetadataHash(typeFqn = "org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsId", metadataHash = 236435207) + addMetadataHash(typeFqn = "com.intellij.platform.workspace.storage.SymbolicEntityId", metadataHash = -1609236105) } } diff --git a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/serialization/KotlinFacetSettingsWorkspaceModel.kt b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/serialization/KotlinFacetSettingsWorkspaceModel.kt index 2d3573d8f8dd..a00d1e7bb4d3 100644 --- a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/serialization/KotlinFacetSettingsWorkspaceModel.kt +++ b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/serialization/KotlinFacetSettingsWorkspaceModel.kt @@ -56,10 +56,8 @@ class KotlinFacetSettingsWorkspaceModel(val entity: KotlinSettingsEntity.Builder } val serializedArguments = entity.compilerArguments - _compilerArguments = if (serializedArguments.isNotEmpty()) { - CompilerArgumentsSerializer.deserializeFromString(serializedArguments) - } else { - null + _compilerArguments = serializedArguments?.let { + CompilerArgumentsSerializer.deserializeFromString(it) } return _compilerArguments @@ -91,9 +89,7 @@ class KotlinFacetSettingsWorkspaceModel(val entity: KotlinSettingsEntity.Builder } val compilerSettingsData = entity.compilerSettings - if (!compilerSettingsData.isInitialized) return null - - _compilerSettings = compilerSettingsData.toCompilerSettings { newSettings -> + _compilerSettings = compilerSettingsData?.toCompilerSettings { newSettings -> entity.compilerSettings = newSettings.toCompilerSettingsData() updateMergedArguments() } @@ -183,7 +179,7 @@ class KotlinFacetSettingsWorkspaceModel(val entity: KotlinSettingsEntity.Builder get() = _productionOutputPath set(value) { _productionOutputPath = value - entity.productionOutputPath = value ?: "" + entity.productionOutputPath = value } private var _pureKotlinSourceFolders: List = entity.pureKotlinSourceFolders @@ -204,24 +200,24 @@ class KotlinFacetSettingsWorkspaceModel(val entity: KotlinSettingsEntity.Builder override var targetPlatform: TargetPlatform? get() { - val args = compilerArguments val deserializedTargetPlatform = - entity.targetPlatform.takeIf { it.isNotEmpty() }.deserializeTargetPlatformByComponentPlatforms() - val singleSimplePlatform = deserializedTargetPlatform?.componentPlatforms?.singleOrNull() + entity.targetPlatform?.deserializeTargetPlatformByComponentPlatforms() ?: return null + val args = compilerArguments + val singleSimplePlatform = deserializedTargetPlatform.componentPlatforms.singleOrNull() if (args != null && singleSimplePlatform == JvmPlatforms.defaultJvmPlatform.singleOrNull()) { return IdePlatformKind.platformByCompilerArguments(args) } return deserializedTargetPlatform } set(value) { - entity.targetPlatform = value?.serializeComponentPlatforms() ?: "" + entity.targetPlatform = value?.serializeComponentPlatforms() } private var _testOutputPath: String? = entity.testOutputPath override var testOutputPath: String? get() = _testOutputPath set(value) { - entity.testOutputPath = value ?: "" + entity.testOutputPath = value _testOutputPath = value } } diff --git a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinFacetConfigurationBridge.kt b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinFacetConfigurationBridge.kt index fe79e4de4925..634bdd436935 100644 --- a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinFacetConfigurationBridge.kt +++ b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinFacetConfigurationBridge.kt @@ -31,17 +31,12 @@ class KotlinFacetConfigurationBridge : KotlinFacetConfiguration, FacetConfigurat implementedModuleNames = emptyList(), dependsOnModuleNames = emptyList(), additionalVisibleModuleNames = emptySet(), - productionOutputPath = "", - testOutputPath = "", sourceSetNames = emptyList(), isTestModule = false, externalProjectId = "", isHmppEnabled = false, pureKotlinSourceFolders = emptyList(), kind = KotlinModuleKind.DEFAULT, - compilerArguments = "", - compilerSettings = CompilerSettingsData("", "", "", true, "lib", false), - targetPlatform = "", externalSystemRunTasks = emptyList(), version = KotlinFacetSettings.CURRENT_VERSION, flushNeeded = false, @@ -58,24 +53,23 @@ class KotlinFacetConfigurationBridge : KotlinFacetConfiguration, FacetConfigurat originKotlinSettingsEntity.implementedModuleNames, originKotlinSettingsEntity.dependsOnModuleNames, originKotlinSettingsEntity.additionalVisibleModuleNames, - originKotlinSettingsEntity.productionOutputPath, - originKotlinSettingsEntity.testOutputPath, originKotlinSettingsEntity.sourceSetNames, originKotlinSettingsEntity.isTestModule, originKotlinSettingsEntity.externalProjectId, originKotlinSettingsEntity.isHmppEnabled, originKotlinSettingsEntity.pureKotlinSourceFolders, originKotlinSettingsEntity.kind, - originKotlinSettingsEntity.compilerArguments, - originKotlinSettingsEntity.compilerSettings, - originKotlinSettingsEntity.targetPlatform, originKotlinSettingsEntity.externalSystemRunTasks, originKotlinSettingsEntity.version, originKotlinSettingsEntity.flushNeeded, originKotlinSettingsEntity.entitySource ) { - }) { - } + productionOutputPath = originKotlinSettingsEntity.productionOutputPath + testOutputPath = originKotlinSettingsEntity.testOutputPath + compilerArguments = originKotlinSettingsEntity.compilerArguments + compilerSettings = originKotlinSettingsEntity.compilerSettings + targetPlatform = originKotlinSettingsEntity.targetPlatform + }) override fun init(moduleEntity: ModuleEntity, entitySource: EntitySource) { kotlinSettingsEntity.moduleId = moduleEntity.symbolicId @@ -96,23 +90,23 @@ class KotlinFacetConfigurationBridge : KotlinFacetConfiguration, FacetConfigurat kotlinSettingsEntity.implementedModuleNames, kotlinSettingsEntity.dependsOnModuleNames, kotlinSettingsEntity.additionalVisibleModuleNames, - kotlinSettingsEntity.productionOutputPath, - kotlinSettingsEntity.testOutputPath, kotlinSettingsEntity.sourceSetNames, kotlinSettingsEntity.isTestModule, kotlinSettingsEntity.externalProjectId, kotlinSettingsEntity.isHmppEnabled, kotlinSettingsEntity.pureKotlinSourceFolders, kotlinSettingsEntity.kind, - kotlinSettingsEntity.compilerArguments, - kotlinSettingsEntity.compilerSettings, - kotlinSettingsEntity.targetPlatform, kotlinSettingsEntity.externalSystemRunTasks, kotlinSettingsEntity.version, kotlinSettingsEntity.flushNeeded, kotlinSettingsEntity.entitySource, ) { module = moduleEntity + productionOutputPath = kotlinSettingsEntity.productionOutputPath + testOutputPath = kotlinSettingsEntity.testOutputPath + compilerArguments = kotlinSettingsEntity.compilerArguments + compilerSettings = kotlinSettingsEntity.compilerSettings + targetPlatform = kotlinSettingsEntity.targetPlatform } } diff --git a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinModuleSettingsSerializer.kt b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinModuleSettingsSerializer.kt index 1d300b550e32..9174297eced0 100644 --- a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinModuleSettingsSerializer.kt +++ b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/KotlinModuleSettingsSerializer.kt @@ -34,28 +34,23 @@ class KotlinModuleSettingsSerializer : CustomFacetRelatedEntitySerializer @@ -42,25 +45,115 @@ interface KotlinSettingsEntity : ModuleSettingsBase { val kind: KotlinModuleKind //non-trivial parameters - val compilerArguments: String - val compilerSettings: CompilerSettingsData + val compilerArguments: String? + val compilerSettings: CompilerSettingsData? - val targetPlatform: String + val targetPlatform: String? val externalSystemRunTasks: List val version: Int val flushNeeded: Boolean override val symbolicId: KotlinSettingsId get() = KotlinSettingsId(name, moduleId) + + //region generated code + @GeneratedCodeApiVersion(3) + interface Builder : WorkspaceEntity.Builder, ModuleSettingsBase.Builder { + override var entitySource: EntitySource + override var name: String + override var moduleId: ModuleId + var sourceRoots: MutableList + var configFileItems: MutableList + var module: ModuleEntity.Builder + var useProjectSettings: Boolean + var implementedModuleNames: MutableList + var dependsOnModuleNames: MutableList + var additionalVisibleModuleNames: MutableSet + var productionOutputPath: String? + var testOutputPath: String? + var sourceSetNames: MutableList + var isTestModule: Boolean + var externalProjectId: String + var isHmppEnabled: Boolean + var pureKotlinSourceFolders: MutableList + var kind: KotlinModuleKind + var compilerArguments: String? + var compilerSettings: CompilerSettingsData? + var targetPlatform: String? + var externalSystemRunTasks: MutableList + var version: Int + var flushNeeded: Boolean + } + + companion object : EntityType(ModuleSettingsBase) { + @JvmOverloads + @JvmStatic + @JvmName("create") + operator fun invoke( + name: String, + moduleId: ModuleId, + sourceRoots: List, + configFileItems: List, + useProjectSettings: Boolean, + implementedModuleNames: List, + dependsOnModuleNames: List, + additionalVisibleModuleNames: Set, + sourceSetNames: List, + isTestModule: Boolean, + externalProjectId: String, + isHmppEnabled: Boolean, + pureKotlinSourceFolders: List, + kind: KotlinModuleKind, + externalSystemRunTasks: List, + version: Int, + flushNeeded: Boolean, + entitySource: EntitySource, + init: (Builder.() -> Unit)? = null, + ): Builder { + val builder = builder() + builder.name = name + builder.moduleId = moduleId + builder.sourceRoots = sourceRoots.toMutableWorkspaceList() + builder.configFileItems = configFileItems.toMutableWorkspaceList() + builder.useProjectSettings = useProjectSettings + builder.implementedModuleNames = implementedModuleNames.toMutableWorkspaceList() + builder.dependsOnModuleNames = dependsOnModuleNames.toMutableWorkspaceList() + builder.additionalVisibleModuleNames = additionalVisibleModuleNames.toMutableWorkspaceSet() + builder.sourceSetNames = sourceSetNames.toMutableWorkspaceList() + builder.isTestModule = isTestModule + builder.externalProjectId = externalProjectId + builder.isHmppEnabled = isHmppEnabled + builder.pureKotlinSourceFolders = pureKotlinSourceFolders.toMutableWorkspaceList() + builder.kind = kind + builder.externalSystemRunTasks = externalSystemRunTasks.toMutableWorkspaceList() + builder.version = version + builder.flushNeeded = flushNeeded + builder.entitySource = entitySource + init?.invoke(builder) + return builder + } + } + //endregion } +//region generated code +fun MutableEntityStorage.modifyEntity( + entity: KotlinSettingsEntity, + modification: KotlinSettingsEntity.Builder.() -> Unit, +): KotlinSettingsEntity { + return modifyEntity(KotlinSettingsEntity.Builder::class.java, entity, modification) +} + +var ModuleEntity.Builder.kotlinSettings: @Child List + by WorkspaceEntity.extensionBuilder(KotlinSettingsEntity::class.java) +//endregion + data class CompilerSettingsData( val additionalArguments: String, val scriptTemplates: String, val scriptTemplatesClasspath: String, val copyJsLibraryFiles: Boolean, - val outputDirectoryForJsLibraryFiles: String, - val isInitialized: Boolean + val outputDirectoryForJsLibraryFiles: String ) val ModuleEntity.kotlinSettings: List<@Child KotlinSettingsEntity> diff --git a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/Utils.kt b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/Utils.kt index d65b6cd63030..62b25491f5fd 100644 --- a/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/Utils.kt +++ b/plugins/kotlin/base/facet/src/org/jetbrains/kotlin/idea/workspaceModel/Utils.kt @@ -51,15 +51,15 @@ fun CompilerSettingsData.toCompilerSettings(notifier: (CompilerSettings) -> Unit it.outputDirectoryForJsLibraryFiles = this.outputDirectoryForJsLibraryFiles } -fun CompilerSettings?.toCompilerSettingsData(): CompilerSettingsData = +fun CompilerSettings?.toCompilerSettingsData(): CompilerSettingsData? = this?.let { CompilerSettingsData( - this?.additionalArguments ?: "", - this?.scriptTemplates ?: "", - this?.scriptTemplatesClasspath ?: "", - this?.copyJsLibraryFiles ?: true, - this?.outputDirectoryForJsLibraryFiles ?: "lib", - true + additionalArguments, + scriptTemplates, + scriptTemplatesClasspath, + copyJsLibraryFiles, + outputDirectoryForJsLibraryFiles ) +} fun ExternalSystemRunTask.serializeExternalSystemTestRunTask(): String { return when(this) { @@ -96,17 +96,15 @@ object CompilerArgumentsSerializer { "D" to CommonCompilerArguments.DummyImpl::class.java ) - fun serializeToString(commonCompilerArguments: CommonCompilerArguments?): String { - return commonCompilerArguments?.let { - val classIdentifier = argumentsTypeMap.entries.firstOrNull { it.value == commonCompilerArguments.javaClass }?.key - ?: error("Class not found: ${commonCompilerArguments.javaClass}") + fun serializeToString(commonCompilerArguments: CommonCompilerArguments?): String? = commonCompilerArguments?.let { + val classIdentifier = argumentsTypeMap.entries.firstOrNull { it.value == commonCompilerArguments.javaClass }?.key + ?: error("Class not found: ${commonCompilerArguments.javaClass}") - classIdentifier + gson.toJson(commonCompilerArguments) - } ?: "" + classIdentifier + gson.toJson(commonCompilerArguments) } - fun deserializeFromString(serializedArguments: String): CommonCompilerArguments? { - return when { + fun deserializeFromString(serializedArguments: String?): CommonCompilerArguments? = serializedArguments?.let { + when { serializedArguments.isEmpty() -> null serializedArguments.isNotBlank() && serializedArguments[0].isLetter() -> { val classIdentifier = serializedArguments.substring(0, 1) diff --git a/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt index 39e2732e1111..552d762cfc26 100644 --- a/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetBridgeTest.kt @@ -95,6 +95,19 @@ class KotlinFacetBridgeTest : KotlinFacetTestCase() { fireFacetChangedAndValidateKotlinFacet(mainFacet) } + fun testCreateFacetAndCheckNullableTypes() { + val mainFacet = getKotlinFacet() + checkStorageForEntityAndFacet() + + mainFacet.configuration.settings.compilerArguments = null + mainFacet.configuration.settings.compilerSettings = null + mainFacet.configuration.settings.targetPlatform = null + mainFacet.configuration.settings.productionOutputPath = null + mainFacet.configuration.settings.testOutputPath = null + + fireFacetChangedAndValidateKotlinFacet(mainFacet) + } + private fun fireFacetChangedAndValidateKotlinFacet(mainFacet: KotlinFacet) { val allFacets = FacetManager.getInstance(myModule).allFacets assertSize(1, allFacets) @@ -135,5 +148,25 @@ class KotlinFacetBridgeTest : KotlinFacetTestCase() { "externalSystemRunTasks differs. Entity: ${entity.externalSystemRunTasks}, facet: ${facet.configuration.settings.externalSystemRunTasks}", entity.externalSystemRunTasks.map { deserializeExternalSystemTestRunTask(it) } == facet.configuration.settings.externalSystemRunTasks ) + assertTrue( + "compilerArguments is not null", + entity.compilerArguments == null + ) + assertTrue( + "compilerSettings is not null", + entity.compilerSettings == null + ) + assertTrue( + "targetPlatform differs. Entity: ${entity.targetPlatform}, facet: ${facet.configuration.settings.targetPlatform}", + entity.targetPlatform == null + ) + assertTrue( + "productionOutputPath differs. Entity: ${entity.productionOutputPath}, facet: ${facet.configuration.settings.productionOutputPath}", + entity.productionOutputPath == facet.configuration.settings.productionOutputPath + ) + assertTrue( + "testOutputPath differs. Entity: ${entity.testOutputPath}, facet: ${facet.configuration.settings.testOutputPath}", + entity.testOutputPath == facet.configuration.settings.testOutputPath + ) } } \ No newline at end of file diff --git a/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt index 1cd3d07769f6..22953adeb64f 100644 --- a/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt +++ b/plugins/kotlin/base/facet/tests/test/org/jetbrains/kotlin/idea/KotlinFacetEventListenerTest.kt @@ -251,17 +251,12 @@ class KotlinFacetEventListenerTest { implementedModuleNames = emptyList(), dependsOnModuleNames = emptyList(), additionalVisibleModuleNames = emptySet(), - productionOutputPath = "", - testOutputPath = "", sourceSetNames = emptyList(), isTestModule = false, externalProjectId = "", isHmppEnabled = false, pureKotlinSourceFolders = emptyList(), kind = KotlinModuleKind.DEFAULT, - compilerArguments = "", - compilerSettings = CompilerSettingsData("", "", "", true, "lib", false), - targetPlatform = "", externalSystemRunTasks = emptyList(), version = KotlinFacetSettings.CURRENT_VERSION, flushNeeded = false, diff --git a/plugins/kotlin/maven/src/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterEx.kt b/plugins/kotlin/maven/src/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterEx.kt index 14d60bb216dd..9b9912d5e227 100644 --- a/plugins/kotlin/maven/src/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterEx.kt +++ b/plugins/kotlin/maven/src/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterEx.kt @@ -56,17 +56,12 @@ class KotlinMavenImporterEx : KotlinMavenImporter(), MavenWorkspaceFacetConfigur emptyList(), emptyList(), emptySet(), - "", - "", emptyList(), false, "", false, emptyList(), KotlinModuleKind.DEFAULT, - "", - CompilerSettingsData("", "", "", true, "lib", true), - "", emptyList(), KotlinFacetSettings.CURRENT_VERSION, false, @@ -233,8 +228,8 @@ class KotlinMavenImporterEx : KotlinMavenImporter(), MavenWorkspaceFacetConfigur this.implementedModuleNames = kotlinFacetSettings.implementedModuleNames.toMutableList() this.dependsOnModuleNames = kotlinFacetSettings.dependsOnModuleNames.toMutableList() this.additionalVisibleModuleNames = kotlinFacetSettings.additionalVisibleModuleNames.toMutableSet() - this.productionOutputPath = kotlinFacetSettings.productionOutputPath ?: "" - this.testOutputPath = kotlinFacetSettings.testOutputPath ?: "" + this.productionOutputPath = kotlinFacetSettings.productionOutputPath + this.testOutputPath = kotlinFacetSettings.testOutputPath this.sourceSetNames = kotlinFacetSettings.sourceSetNames.toMutableList() this.isTestModule = kotlinFacetSettings.isTestModule this.externalProjectId = "Maven" @@ -242,18 +237,16 @@ class KotlinMavenImporterEx : KotlinMavenImporter(), MavenWorkspaceFacetConfigur this.pureKotlinSourceFolders = kotlinFacetSettings.pureKotlinSourceFolders.toMutableList() this.kind = kotlinFacetSettings.kind this.compilerArguments = CompilerArgumentsSerializer.serializeToString(kotlinFacetSettings.compilerArguments) - val compilerSettings = kotlinFacetSettings.compilerSettings - this.compilerSettings = - if (compilerSettings == null) CompilerSettingsData("", "", "", true, "lib", false) - else CompilerSettingsData( - compilerSettings.additionalArguments, - compilerSettings.scriptTemplates, - compilerSettings.scriptTemplatesClasspath, - compilerSettings.copyJsLibraryFiles, - compilerSettings.outputDirectoryForJsLibraryFiles, - true + this.compilerSettings = kotlinFacetSettings.compilerSettings?.let { + CompilerSettingsData( + it.additionalArguments, + it.scriptTemplates, + it.scriptTemplatesClasspath, + it.copyJsLibraryFiles, + it.outputDirectoryForJsLibraryFiles ) - this.targetPlatform = kotlinFacetSettings.targetPlatform?.serializeComponentPlatforms() ?: "" + } + this.targetPlatform = kotlinFacetSettings.targetPlatform?.serializeComponentPlatforms() } }