mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Workspace Model] Fix some warnings
GitOrigin-RevId: c8fc85c61a45d4fef783e2099fdcc05da415d83c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
20a055b777
commit
d8245e865f
+10
-9
@@ -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())
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
+3
-3
@@ -53,7 +53,7 @@ class JpsProjectSerializersImpl(directorySerializersFactories: List<JpsDirectory
|
||||
for (moduleFile in moduleFiles) {
|
||||
val internalSource = createFileInDirectorySource(moduleFile.parent!!, moduleFile.file!!.name)
|
||||
for (moduleListSerializer in enabledModuleListSerializers) {
|
||||
val moduleSerializer = moduleListSerializer.createSerializer(internalSource, moduleFile) ?: continue
|
||||
val moduleSerializer = moduleListSerializer.createSerializer(internalSource, moduleFile)
|
||||
moduleSerializers[moduleSerializer] = moduleListSerializer
|
||||
}
|
||||
}
|
||||
@@ -153,10 +153,10 @@ class JpsProjectSerializersImpl(directorySerializersFactories: List<JpsDirectory
|
||||
override fun loadAll(reader: JpsFileContentReader, builder: WorkspaceEntityStorageBuilder) {
|
||||
val service = AppExecutorUtil.createBoundedApplicationPoolExecutor("ModuleManager Loader", 1)
|
||||
try {
|
||||
val tasks = fileSerializersByUrl.values().map { serilizer ->
|
||||
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)
|
||||
}
|
||||
|
||||
+8
-15
@@ -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<ModuleOrderEntry>()
|
||||
.firstOrNull { module == it.module }
|
||||
return orderEntries.filterIsInstance<ModuleOrderEntry>().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<LibraryOrderEntry>()
|
||||
.firstOrNull { libraryIdToFind == (it.library as? LibraryBridge)?.libraryId }
|
||||
|
||||
+3
-3
@@ -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)
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ class TestModuleExtension : ModuleExtension, PersistentStateComponentWithModific
|
||||
private var myState: State? = State()
|
||||
|
||||
override fun getStateModificationCount(): Long {
|
||||
return myState!!.getModificationCount()
|
||||
return myState!!.modificationCount
|
||||
}
|
||||
|
||||
constructor() {
|
||||
|
||||
+2
-2
@@ -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<Module>, antLibName: String) {
|
||||
private fun addModuleLibraryToHundredModules(modules: MutableList<Module>, antLibName: String) {
|
||||
modules.forEach { module -> ModuleRootModificationUtil.addModuleLibrary(module, antLibName, listOf(), emptyList()) }
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
+3
-3
@@ -267,9 +267,9 @@ class ModifiableArtifactPropertiesEntity : ModifiableWorkspaceEntityBase<Artifac
|
||||
var propertiesXmlTag: String? by EntityDataDelegation()
|
||||
}
|
||||
|
||||
fun WorkspaceEntityStorageDiffBuilder.addArtifactPropertisEntity(artifact: ArtifactEntity,
|
||||
providerType: String,
|
||||
propertiesXmlTag: String?, source: EntitySource) = addEntity(
|
||||
fun WorkspaceEntityStorageDiffBuilder.addArtifactPropertiesEntity(artifact: ArtifactEntity,
|
||||
providerType: String,
|
||||
propertiesXmlTag: String?, source: EntitySource) = addEntity(
|
||||
ModifiableArtifactPropertiesEntity::class.java, source) {
|
||||
this.artifact = artifact
|
||||
this.providerType = providerType
|
||||
|
||||
+1
-2
@@ -167,8 +167,7 @@ abstract class WorkspaceEntityData<E : WorkspaceEntity> : Cloneable {
|
||||
abstract fun persistentId(): PersistentEntityId<*>
|
||||
}
|
||||
|
||||
abstract class WithPersistentId<E : WorkspaceEntity> : WorkspaceEntityData<E>() {
|
||||
}
|
||||
abstract class WithPersistentId<E : WorkspaceEntity> : WorkspaceEntityData<E>()
|
||||
}
|
||||
|
||||
fun WorkspaceEntityData<*>.persistentId(snapshot: WorkspaceEntityStorage): PersistentEntityId<*>? = when (this) {
|
||||
|
||||
+1
@@ -130,6 +130,7 @@ sealed class IntIntUniqueBiMap {
|
||||
return result
|
||||
}
|
||||
|
||||
@Suppress("PropertyName")
|
||||
@PublishedApi
|
||||
internal val `access$key2Value`: Int2IntMap
|
||||
get() = key2Value
|
||||
|
||||
+1
@@ -113,6 +113,7 @@ sealed class PositiveIntIntBiMap {
|
||||
return result
|
||||
}
|
||||
|
||||
@Suppress("PropertyName")
|
||||
@PublishedApi
|
||||
internal val `access$key2Value`: Int2IntMap
|
||||
get() = key2Value
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ class ExternalEntityIndexTest {
|
||||
val newIndex = storage.getExternalIndex<Int>(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
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ object SerializationRoundTripChecker {
|
||||
|
||||
// Use UsefulTestCase.assertOrderedEquals in case it'd be used in this module
|
||||
private fun <T> assertOrderedEquals(actual: Iterable<T?>, expected: Iterable<T?>) {
|
||||
if (!equals<T>(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)
|
||||
|
||||
Reference in New Issue
Block a user