mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
KTIJ-31273 [kotlin] Properly handle Kotlin facet changes in both KtCompilerPluginsProviderIdeImpl and FirIdeModuleStateModificationService
At some point, `FacetEntity` events were replaced by `KotlinSettingsEntity` for Kotlin facets. In theory, they should not overlap with each other. We keep the code for handling `FacetEntity` for compatibility just in case; it should be removed some time in the future. Now both `KtCompilerPluginsProviderIdeImpl` and `FirIdeModuleStateModificationService` should properly react to changes in Kotlin facets, like changing compiler arguments, for example. ^KTIJ-31273 Fixed GitOrigin-RevId: 0a2de370a09f021612af21e30db9bdd24e9c866c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
43007f90f2
commit
04483f7b9e
+10
@@ -60,6 +60,7 @@ import org.jetbrains.kotlin.idea.base.util.caching.newEntity
|
||||
import org.jetbrains.kotlin.idea.facet.isKotlinFacet
|
||||
import org.jetbrains.kotlin.idea.util.AbstractSingleFileModuleBeforeFileEventListener
|
||||
import org.jetbrains.kotlin.idea.util.toKaModulesForModificationEvents
|
||||
import org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsEntity
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.alwaysTrue
|
||||
import java.io.File
|
||||
@@ -277,6 +278,15 @@ class FirIdeModuleStateModificationService(val project: Project) : Disposable {
|
||||
moduleSelector = FacetEntity::module,
|
||||
)
|
||||
}
|
||||
|
||||
getChanges<KotlinSettingsEntity>().mapNotNullTo(modules) {
|
||||
getChangedModule(
|
||||
oldEntity = it.oldEntity,
|
||||
newEntity = it.newEntity,
|
||||
entityFilter = KotlinSettingsEntity::isKotlinFacet,
|
||||
moduleSelector = KotlinSettingsEntity::module,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T : WorkspaceEntity> VersionedStorageChange.getChangedModule(
|
||||
|
||||
+4
-2
@@ -17,7 +17,6 @@ import com.intellij.openapi.util.registry.RegistryValue
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener
|
||||
import com.intellij.platform.backend.workspace.WorkspaceModel
|
||||
import com.intellij.platform.workspace.jps.entities.FacetEntity
|
||||
import com.intellij.platform.workspace.storage.EntityChange
|
||||
import com.intellij.util.concurrency.SynchronizedClearableLazy
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.containers.orNull
|
||||
@@ -49,6 +48,7 @@ import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgu
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettingsListener
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.facet.isKotlinFacet
|
||||
import org.jetbrains.kotlin.idea.workspaceModel.KotlinSettingsEntity
|
||||
import org.jetbrains.kotlin.util.ServiceLoaderLite
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
@@ -73,7 +73,9 @@ internal class KtCompilerPluginsProviderIdeImpl(
|
||||
init {
|
||||
cs.launch {
|
||||
WorkspaceModel.getInstance(project).eventLog.collect { event ->
|
||||
val hasChanges = event.getChanges<FacetEntity>().any { change ->
|
||||
val facetChanges = event.getChanges<FacetEntity>() + event.getChanges<KotlinSettingsEntity>()
|
||||
|
||||
val hasChanges = facetChanges.any { change ->
|
||||
val entities = listOfNotNull(change.oldEntity, change.newEntity)
|
||||
entities.any { it.isKotlinFacet() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user