mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Extensible ExternalModuleListStorage
IDEA-CR-37148 IDEA-199211 Refactor code dependent on project model implementation
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
</component>
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.module.impl.ExternalModuleListStorage</interface-class>
|
||||
<implementation-class>com.intellij.openapi.module.impl.ExternalModuleListStorage</implementation-class>
|
||||
<implementation-class>com.intellij.openapi.module.impl.ExternalModuleListStorageImpl</implementation-class>
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
|
||||
|
||||
+9
-1
@@ -13,14 +13,22 @@ import com.intellij.openapi.roots.ProjectModelElement
|
||||
import com.intellij.openapi.roots.ProjectModelExternalSource
|
||||
import org.jdom.Element
|
||||
|
||||
interface ExternalModuleListStorage {
|
||||
fun getExternalModules(): Set<ModulePath>?
|
||||
}
|
||||
|
||||
/**
|
||||
* todo rename component state name to "ExternalProjectModuleManager" for consistency (2018.1 release)
|
||||
*/
|
||||
@State(name = "ExternalModuleListStorage", storages = [(Storage("modules.xml"))], externalStorageOnly = true)
|
||||
internal class ExternalModuleListStorage(private val project: Project) : PersistentStateComponent<Element>, ProjectModelElement {
|
||||
internal class ExternalModuleListStorageImpl(private val project: Project)
|
||||
: PersistentStateComponent<Element>, ProjectModelElement, ExternalModuleListStorage {
|
||||
|
||||
var loadedState: Set<ModulePath>? = null
|
||||
private set
|
||||
|
||||
override fun getExternalModules(): Set<ModulePath>? = loadedState
|
||||
|
||||
override fun getState(): Element {
|
||||
val e = Element("state")
|
||||
if (!project.isExternalStorageEnabled) {
|
||||
|
||||
+2
-2
@@ -154,7 +154,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Disposa
|
||||
@Override
|
||||
public void loadState(@NotNull Element state) {
|
||||
Set<ModulePath> files = getPathsToModuleFiles(state);
|
||||
Set<ModulePath> externalModules = myProject.getComponent(ExternalModuleListStorage.class).getLoadedState();
|
||||
Set<ModulePath> externalModules = myProject.getComponent(ExternalModuleListStorage.class).getExternalModules();
|
||||
if (externalModules != null) {
|
||||
files.addAll(externalModules);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Disposa
|
||||
@Override
|
||||
public void noStateLoaded() {
|
||||
// if there are only external modules, loadState will be not called
|
||||
Set<ModulePath> externalModules = myProject.getComponent(ExternalModuleListStorage.class).getLoadedState();
|
||||
Set<ModulePath> externalModules = myProject.getComponent(ExternalModuleListStorage.class).getExternalModules();
|
||||
if (externalModules != null) {
|
||||
loadState(new LinkedHashSet<>(externalModules));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user