diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/WorkspaceModelImpl.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/WorkspaceModelImpl.kt index 339654770420..3fc16bc22992 100644 --- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/WorkspaceModelImpl.kt +++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/WorkspaceModelImpl.kt @@ -25,15 +25,16 @@ class WorkspaceModelImpl(project: Project): WorkspaceModel, Disposable { // Like in ProjectLifecycleListener or something val initialContent = WorkspaceModelInitialTestContent.pop() - if (initialContent != null) { - projectEntities = WorkspaceEntityStorageBuilder.from(initialContent) - } else if (cache != null) { - val activity = StartUpMeasurer.startActivity("(wm) Loading cache") - val previousStorage = cache.loadCache() - projectEntities = if (previousStorage != null) WorkspaceEntityStorageBuilder.from(previousStorage) else WorkspaceEntityStorageBuilder.create() - activity.end() - } else { - projectEntities = WorkspaceEntityStorageBuilder.create() + when { + initialContent != null -> projectEntities = WorkspaceEntityStorageBuilder.from(initialContent) + cache != null -> { + val activity = StartUpMeasurer.startActivity("(wm) Loading cache") + val previousStorage = cache.loadCache() + projectEntities = if (previousStorage != null) WorkspaceEntityStorageBuilder.from(previousStorage) + else WorkspaceEntityStorageBuilder.create() + activity.end() + } + else -> projectEntities = WorkspaceEntityStorageBuilder.create() } entityStorage = ProjectModelEntityStorage(project, projectEntities.toStorage()) diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsArtifactEntitiesSerializer.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsArtifactEntitiesSerializer.kt index 3a6b506d9131..f9f935114267 100644 --- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsArtifactEntitiesSerializer.kt +++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsArtifactEntitiesSerializer.kt @@ -85,7 +85,7 @@ internal open class JpsArtifactEntitiesSerializer(override val fileUrl: VirtualF val artifactEntity = builder.addArtifactEntity(state.name, state.artifactType, state.isBuildOnMake, outputUrl, rootElement as CompositePackagingElementEntity, source) for (propertiesState in state.propertiesList) { - builder.addArtifactPropertisEntity(artifactEntity, propertiesState.id, JDOMUtil.write(propertiesState.options), source) + builder.addArtifactPropertiesEntity(artifactEntity, propertiesState.id, JDOMUtil.write(propertiesState.options), source) } orderOfItems += state.name } diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsProjectSerializersImpl.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsProjectSerializersImpl.kt index 23ef538f547d..de58da3423e8 100644 --- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsProjectSerializersImpl.kt +++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/jps/serialization/JpsProjectSerializersImpl.kt @@ -53,7 +53,7 @@ class JpsProjectSerializersImpl(directorySerializersFactories: List + val tasks = fileSerializersByUrl.values().map { serializer -> Callable { val myBuilder = WorkspaceEntityStorageBuilder.create() - serilizer.loadEntities(myBuilder, reader, virtualFileManager) + serializer.loadEntities(myBuilder, reader, virtualFileManager) synchronized(lock) { builder.addDiff(myBuilder) } diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/ModifiableRootModelBridge.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/ModifiableRootModelBridge.kt index 7c79149a74a1..8ffa723a684a 100644 --- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/ModifiableRootModelBridge.kt +++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/ModifiableRootModelBridge.kt @@ -19,11 +19,11 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.util.isEmpty import com.intellij.workspaceModel.ide.WorkspaceModel import com.intellij.workspaceModel.ide.getInstance -import com.intellij.workspaceModel.ide.legacyBridge.ModuleBridge +import com.intellij.workspaceModel.ide.impl.legacyBridge.LegacyBridgeModifiableBase import com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridge import com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridgeImpl -import com.intellij.workspaceModel.ide.impl.legacyBridge.LegacyBridgeModifiableBase import com.intellij.workspaceModel.ide.impl.legacyBridge.module.CompilerModuleExtensionBridge +import com.intellij.workspaceModel.ide.legacyBridge.ModuleBridge import com.intellij.workspaceModel.storage.* import com.intellij.workspaceModel.storage.bridgeEntities.* import org.jdom.Element @@ -171,9 +171,7 @@ class ModifiableRootModelBridge( updateDependencies { it + libraryDependency } - val libraryOrderEntry = (orderEntriesImpl.lastOrNull() as? LibraryOrderEntry - ?: error("Unable to find library orderEntry after adding")) - return libraryOrderEntry + return (orderEntriesImpl.lastOrNull() as? LibraryOrderEntry ?: error("Unable to find library orderEntry after adding")) } override fun addInvalidLibrary(name: String, level: String): LibraryOrderEntry { @@ -185,8 +183,7 @@ class ModifiableRootModelBridge( updateDependencies { it + libraryDependency } - return (orderEntriesImpl.lastOrNull() as? LibraryOrderEntry - ?: error("Unable to find library orderEntry after adding")) + return (orderEntriesImpl.lastOrNull() as? LibraryOrderEntry ?: error("Unable to find library orderEntry after adding")) } override fun addModuleOrderEntry(module: Module): ModuleOrderEntry { @@ -199,8 +196,7 @@ class ModifiableRootModelBridge( updateDependencies { it + moduleDependency } - return orderEntriesImpl.lastOrNull() as? ModuleOrderEntry - ?: error("Unable to find module orderEntry after adding") + return orderEntriesImpl.lastOrNull() as? ModuleOrderEntry ?: error("Unable to find module orderEntry after adding") } override fun addInvalidModuleEntry(name: String): ModuleOrderEntry { @@ -213,19 +209,16 @@ class ModifiableRootModelBridge( updateDependencies { it + moduleDependency } - return orderEntriesImpl.lastOrNull() as? ModuleOrderEntry - ?: error("Unable to find module orderEntry after adding") + return orderEntriesImpl.lastOrNull() as? ModuleOrderEntry ?: error("Unable to find module orderEntry after adding") } override fun findModuleOrderEntry(module: Module): ModuleOrderEntry? { - return orderEntries - .filterIsInstance() - .firstOrNull { module == it.module } + return orderEntries.filterIsInstance().firstOrNull { module == it.module } } override fun findLibraryOrderEntry(library: Library): LibraryOrderEntry? { if (library is LibraryBridge) { - val libraryIdToFind = (library as LibraryBridge).libraryId + val libraryIdToFind = library.libraryId return orderEntries .filterIsInstance() .firstOrNull { libraryIdToFind == (it.library as? LibraryBridge)?.libraryId } diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/RootModelBridgeImpl.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/RootModelBridgeImpl.kt index 863ef874411e..228d146f859e 100644 --- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/RootModelBridgeImpl.kt +++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/roots/RootModelBridgeImpl.kt @@ -172,9 +172,9 @@ internal class RootModelBridgeImpl(internal val moduleEntityId: PersistentEntity return result } - internal fun loadExtension(extension: ModuleExtension, - parentDisposable: Disposable, - rootManagerElement: @NotNull Element?): @NotNull ModuleExtension { + private fun loadExtension(extension: ModuleExtension, + parentDisposable: Disposable, + rootManagerElement: @NotNull Element?): @NotNull ModuleExtension { val readOnlyExtension = extension.getModifiableModel(false).also { Disposer.register(parentDisposable, it) } diff --git a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/project/ProjectRootManagerBridge.kt b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/project/ProjectRootManagerBridge.kt index 2f311a8cab7b..45304014d259 100644 --- a/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/project/ProjectRootManagerBridge.kt +++ b/platform/workspaceModel/ide/src/com/intellij/workspaceModel/ide/impl/legacyBridge/project/ProjectRootManagerBridge.kt @@ -81,8 +81,8 @@ class ProjectRootManagerBridge(project: Project) : ProjectRootManagerComponent(p WorkspaceModel.getInstance(myProject).updateProjectModel { builder -> for (module in affectedModules) { val updated = module.dependencies.map { - when { - it is ModuleDependencyItem.SdkDependency -> ModuleDependencyItem.SdkDependency(jdk.name, jdk.sdkType.name) + when (it) { + is ModuleDependencyItem.SdkDependency -> ModuleDependencyItem.SdkDependency(jdk.name, jdk.sdkType.name) else -> it } } diff --git a/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/TestModuleExtension.kt b/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/TestModuleExtension.kt index b106edf72fd7..12775d55553b 100644 --- a/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/TestModuleExtension.kt +++ b/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/TestModuleExtension.kt @@ -15,7 +15,7 @@ class TestModuleExtension : ModuleExtension, PersistentStateComponentWithModific private var myState: State? = State() override fun getStateModificationCount(): Long { - return myState!!.getModificationCount() + return myState!!.modificationCount } constructor() { diff --git a/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelPerformanceTest.kt b/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelPerformanceTest.kt index 1f7150c688e4..15b4fc16c45c 100644 --- a/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelPerformanceTest.kt +++ b/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelPerformanceTest.kt @@ -107,7 +107,7 @@ class WorkspaceModelPerformanceTest(private val modulesCount: Int) { logExecutionTimeInMillis("Add project library at hundred modules") { addProjectLibraryToHundredModules(modules, library) } logExecutionTimeInMillis("Add module library at hundred modules") { - addModuleLibraryToHunredModules(modules, antLibName) + addModuleLibraryToHundredModules(modules, antLibName) } logExecutionTimeInMillis("Loop through the contentRoots of all modules") { @@ -169,7 +169,7 @@ class WorkspaceModelPerformanceTest(private val modulesCount: Int) { moduleManager.modules.forEach { ModuleRootManager.getInstance(it).contentRoots.forEach { entry -> entry.canonicalFile } } } - private fun addModuleLibraryToHunredModules(modules: MutableList, antLibName: String) { + private fun addModuleLibraryToHundredModules(modules: MutableList, antLibName: String) { modules.forEach { module -> ModuleRootModificationUtil.addModuleLibrary(module, antLibName, listOf(), emptyList()) } } diff --git a/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelTest.kt b/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelTest.kt index a1a599e8d9c5..a47c59264d4e 100644 --- a/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelTest.kt +++ b/platform/workspaceModel/ide/tests/testSrc/com/intellij/workspaceModel/ide/WorkspaceModelTest.kt @@ -9,7 +9,6 @@ import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.use import com.intellij.testFramework.ApplicationRule import com.intellij.testFramework.rules.ProjectModelRule -import com.intellij.workspaceModel.ide.WorkspaceModel import org.junit.Assert import org.junit.ClassRule import org.junit.Rule diff --git a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/VersionedEntityStorage.kt b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/VersionedEntityStorage.kt index d6ff65acfea1..44df0366aed1 100644 --- a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/VersionedEntityStorage.kt +++ b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/VersionedEntityStorage.kt @@ -173,7 +173,7 @@ open class VersionedEntityStorageImpl(initialStorage: WorkspaceEntityStorage) : } } -abstract class VersionedStorageChanged(val versionedStorage: VersionedEntityStorage) : EventObject(versionedStorage) { +abstract class VersionedStorageChanged(versionedStorage: VersionedEntityStorage) : EventObject(versionedStorage) { abstract val storageBefore: WorkspaceEntityStorage abstract val storageAfter: WorkspaceEntityStorage diff --git a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/bridgeEntities/bridgeModelModifiableEntities.kt b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/bridgeEntities/bridgeModelModifiableEntities.kt index 09e5cd0d4e6c..fc5ae03a4ee0 100644 --- a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/bridgeEntities/bridgeModelModifiableEntities.kt +++ b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/bridgeEntities/bridgeModelModifiableEntities.kt @@ -267,9 +267,9 @@ class ModifiableArtifactPropertiesEntity : ModifiableWorkspaceEntityBase : Cloneable { abstract fun persistentId(): PersistentEntityId<*> } - abstract class WithPersistentId : WorkspaceEntityData() { - } + abstract class WithPersistentId : WorkspaceEntityData() } fun WorkspaceEntityData<*>.persistentId(snapshot: WorkspaceEntityStorage): PersistentEntityId<*>? = when (this) { diff --git a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/IntIntUniqueBiMap.kt b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/IntIntUniqueBiMap.kt index d695b5686670..2454146af008 100644 --- a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/IntIntUniqueBiMap.kt +++ b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/IntIntUniqueBiMap.kt @@ -130,6 +130,7 @@ sealed class IntIntUniqueBiMap { return result } + @Suppress("PropertyName") @PublishedApi internal val `access$key2Value`: Int2IntMap get() = key2Value diff --git a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/PositiveIntIntBiMap.kt b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/PositiveIntIntBiMap.kt index cd2a103b2809..04c770b2a061 100644 --- a/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/PositiveIntIntBiMap.kt +++ b/platform/workspaceModel/storage/src/com/intellij/workspaceModel/storage/impl/containers/PositiveIntIntBiMap.kt @@ -113,6 +113,7 @@ sealed class PositiveIntIntBiMap { return result } + @Suppress("PropertyName") @PublishedApi internal val `access$key2Value`: Int2IntMap get() = key2Value diff --git a/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/ExternalEntityIndexTest.kt b/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/ExternalEntityIndexTest.kt index fe6896c5a34f..030d7cf9b83a 100644 --- a/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/ExternalEntityIndexTest.kt +++ b/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/ExternalEntityIndexTest.kt @@ -31,7 +31,7 @@ class ExternalEntityIndexTest { val newIndex = storage.getExternalIndex(INDEX_ID) assertNotNull(newIndex) assertEquals(3, newIndex!!.getDataByEntity(entity)) - assertEquals(entity, newIndex.getEntities(3)?.get(0)) + assertEquals(entity, newIndex.getEntities(3).get(0)) } @Test @@ -120,8 +120,8 @@ class ExternalEntityIndexTest { assertNotEquals(index, newIndex) assertEquals(1, newIndex!!.getDataByEntity(entity)) assertEquals(2, newIndex.getDataByEntity(newEntity)) - assertEquals(entity, newIndex.getEntities(1)?.get(0)) - assertEquals(newEntity, newIndex.getEntities(2)?.get(0)) + assertEquals(entity, newIndex.getEntities(1).get(0)) + assertEquals(newEntity, newIndex.getEntities(2).get(0)) } @Test diff --git a/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/testUtils.kt b/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/testUtils.kt index da656b8638a9..a7c675b228ae 100644 --- a/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/testUtils.kt +++ b/platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/testUtils.kt @@ -83,7 +83,7 @@ object SerializationRoundTripChecker { // Use UsefulTestCase.assertOrderedEquals in case it'd be used in this module private fun assertOrderedEquals(actual: Iterable, expected: Iterable) { - if (!equals(actual, expected, BiPredicate { a: T?, b: T? -> a == b })) { + if (!equals(actual, expected, BiPredicate { a: T?, b: T? -> a == b })) { val expectedString: String = expected.toString() val actualString: String = actual.toString() Assert.assertEquals("", expectedString, actualString)