mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
External project storage — ensure that we remove external system attributes from module options if enabled
This commit is contained in:
+21
-2
@@ -30,14 +30,16 @@ import com.intellij.util.xmlb.annotations.Transient
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
val EMPTY_STATE = ExternalOptionStateComponent()
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@State(name = "ExternalSystem")
|
||||
class ExternalSystemModulePropertyManager(module: Module) : PersistentStateComponent<ExternalOptionStateComponent>, ProjectModelElement {
|
||||
class ExternalSystemModulePropertyManager(private val module: Module) : PersistentStateComponent<ExternalOptionStateComponent>, ProjectModelElement {
|
||||
override fun getExternalSource() = store.externalSystem?.let { ExternalProjectSystemRegistry.getInstance().getSourceById(it) }
|
||||
|
||||
private var store = if (module.project.isExternalStorageEnabled) ExternalOptionStateComponent() else ExternalOptionStateModule(module)
|
||||
|
||||
override fun getState() = store as? ExternalOptionStateComponent
|
||||
override fun getState() = store as? ExternalOptionStateComponent ?: EMPTY_STATE
|
||||
|
||||
override fun loadState(state: ExternalOptionStateComponent) {
|
||||
store = state
|
||||
@@ -77,6 +79,23 @@ class ExternalSystemModulePropertyManager(module: Module) : PersistentStateCompo
|
||||
store.isMavenized = mavenized
|
||||
}
|
||||
|
||||
fun swapStore() {
|
||||
val oldStore = store
|
||||
if (oldStore is ExternalOptionStateModule) {
|
||||
store = ExternalOptionStateComponent()
|
||||
}
|
||||
else {
|
||||
store = ExternalOptionStateModule(module)
|
||||
}
|
||||
|
||||
store.externalSystem = oldStore.externalSystem
|
||||
store.linkedProjectId = oldStore.linkedProjectId
|
||||
store.linkedProjectPath = oldStore.linkedProjectPath
|
||||
store.rootProjectPath = oldStore.rootProjectPath
|
||||
store.externalSystemModuleGroup = oldStore.externalSystemModuleGroup
|
||||
store.externalSystemModuleVersion = oldStore.externalSystemModuleVersion
|
||||
}
|
||||
|
||||
fun unlinkExternalOptions() {
|
||||
store.externalSystem = null
|
||||
store.linkedProjectId = null
|
||||
|
||||
+2
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemModulePropertyManager;
|
||||
import com.intellij.openapi.externalSystem.importing.ImportSpec;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalProjectInfo;
|
||||
@@ -102,6 +103,7 @@ public class ExternalProjectsManagerImpl implements ExternalProjectsManager, Per
|
||||
try {
|
||||
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
|
||||
if (!module.isDisposed()) {
|
||||
ExternalSystemModulePropertyManager.getInstance(module).swapStore();
|
||||
((ModuleRootManagerImpl)ModuleRootManager.getInstance(module)).stateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user