mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-87889: Fix src duplication.
1. `.iml` file has source `src` 2. so does the new `ModuleEntity` 3. `replaceBySource` expected to merge them, but it duplicates them instead. We now explicilty remove duplicates https://jetbrains.slack.com/archives/C017MGPV4S0/p1771886428685089 (cherry picked from commit e7b26125b3e39d1b603310b9c14899bd28aea2fa) IJ-CR-193095 GitOrigin-RevId: af5940fd61994cb535c25a4c94781a6473a7554a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bb9eaa515c
commit
d088aa9e00
+18
@@ -7,6 +7,7 @@ import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.platform.backend.workspace.workspaceModel
|
||||
import com.intellij.platform.workspace.jps.JpsImportedEntitySource
|
||||
import com.intellij.platform.workspace.jps.entities.ContentRootEntity
|
||||
import com.intellij.platform.workspace.jps.entities.ContentRootEntityBuilder
|
||||
import com.intellij.platform.workspace.jps.entities.DependencyScope
|
||||
import com.intellij.platform.workspace.jps.entities.ExcludeUrlEntity
|
||||
import com.intellij.platform.workspace.jps.entities.ExternalSystemModuleOptionsEntity
|
||||
@@ -70,10 +71,27 @@ internal suspend fun rebuildProjectModel(project: Project, files: FSWalkInfoWith
|
||||
renameSameModule(syncStorage, projectStorage)
|
||||
relocateFacetAndSdk(syncStorage, projectStorage)
|
||||
projectStorage.replaceBySource({ it.isPythonEntity }, syncStorage)
|
||||
|
||||
// For some reason, WSM duplicates sources instead of merging them, so we remove duplicates
|
||||
for (moduleEntity in projectStorage.entities(ModuleEntity::class.java).filter { it.entitySource.isPythonEntity }) {
|
||||
for (contentRoot in moduleEntity.contentRoots) {
|
||||
if (contentRoot.sourceRoots.size > 1) {
|
||||
projectStorage.modifyContentRootEntity(contentRoot) {
|
||||
removeSrcDuplicates()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ContentRootEntityBuilder.removeSrcDuplicates() {
|
||||
val newSourceRoots = sourceRoots.distinctBy { it.url }
|
||||
sourceRoots = newSourceRoots
|
||||
}
|
||||
|
||||
private fun renameSameModule(syncStorage: EntityStorage, projectStorage: MutableEntityStorage) {
|
||||
// TODO: fix O(N^2)
|
||||
for (syncModuleEntity in syncStorage.entities<ModuleEntity>()) {
|
||||
|
||||
Reference in New Issue
Block a user