diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/CompoundSaveSession.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/CompoundSaveSession.java deleted file mode 100644 index 71828754cc79..000000000000 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/CompoundSaveSession.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.components.impl.stores; - -import com.intellij.openapi.components.StateStorage; -import com.intellij.openapi.vfs.VirtualFile; -import gnu.trove.THashMap; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Map; - -public class CompoundSaveSession { - private final Map mySaveSessions = new THashMap(); - - public CompoundSaveSession(@NotNull CompoundExternalizationSession compoundExternalizationSession) { - for (StateStorage stateStorage : compoundExternalizationSession.getStateStorages()) { - mySaveSessions.put(stateStorage, stateStorage.startSave(compoundExternalizationSession.getExternalizationSession(stateStorage))); - } - } - - public void save() { - for (StateStorage.SaveSession saveSession : mySaveSessions.values()) { - saveSession.save(); - } - } - - public void finishSave() { - RuntimeException re = null; - for (StateStorage stateStorage : mySaveSessions.keySet()) { - try { - stateStorage.finishSave(mySaveSessions.get(stateStorage)); - } - catch (RuntimeException e) { - re = e; - } - } - - if (re != null) { - throw re; - } - } - - public StateStorage.SaveSession getSaveSession(@NotNull StateStorage storage) { - return mySaveSessions.get(storage); - } - - public void collectAllStorageFiles(@NotNull List files) { - for (StateStorage.SaveSession saveSession : mySaveSessions.values()) { - saveSession.collectAllStorageFiles(files); - } - } -} diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java index 76782cda7d6a..ab0d241a8e50 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.components.impl.stores; +import com.intellij.codeInspection.SmartHashMap; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; @@ -467,29 +468,47 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di protected abstract String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation); protected class MySaveSession implements SaveSession { - CompoundSaveSession myCompoundSaveSession; + private final Map mySaveSessions = new SmartHashMap(); public MySaveSession(@NotNull MyExternalizationSession externalizationSession) { - myCompoundSaveSession = new CompoundSaveSession(externalizationSession.myCompoundExternalizationSession); + for (StateStorage stateStorage : externalizationSession.myCompoundExternalizationSession.getStateStorages()) { + mySaveSessions.put(stateStorage, stateStorage.startSave(externalizationSession.myCompoundExternalizationSession.getExternalizationSession(stateStorage))); + } } @Override public void collectAllStorageFiles(@NotNull List files) { - myCompoundSaveSession.collectAllStorageFiles(files); + for (StateStorage.SaveSession saveSession : mySaveSessions.values()) { + saveSession.collectAllStorageFiles(files); + } } @Override public void save() throws StateStorageException { assert mySession == this; - myCompoundSaveSession.save(); + for (StateStorage.SaveSession saveSession : mySaveSessions.values()) { + saveSession.save(); + } } public void finishSave() { + RuntimeException re = null; try { LOG.assertTrue(mySession == this); } finally { - myCompoundSaveSession.finishSave(); + for (StateStorage stateStorage : mySaveSessions.keySet()) { + try { + stateStorage.finishSave(mySaveSessions.get(stateStorage)); + } + catch (RuntimeException e) { + re = e; + } + } + } + + if (re != null) { + throw re; } } @@ -498,7 +517,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di public Set analyzeExternalChanges(@NotNull Set> changedFiles) { Set result = null; for (Pair pair : changedFiles) { - StateStorage.SaveSession saveSession = myCompoundSaveSession.getSaveSession(pair.second); + StateStorage.SaveSession saveSession = mySaveSessions.get(pair.second); if (saveSession == null) { continue; }