mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+13
-17
@@ -17,33 +17,30 @@ package com.intellij.openapi.components.impl.stores;
|
||||
|
||||
import com.intellij.openapi.components.StateStorage;
|
||||
import com.intellij.openapi.components.StateStorageException;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.io.fs.IFile;
|
||||
import gnu.trove.THashMap;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
*/
|
||||
public class CompoundSaveSession {
|
||||
private final Map<StateStorage, StateStorage.SaveSession> mySaveSessions = new HashMap<StateStorage, StateStorage.SaveSession>();
|
||||
private final Map<StateStorage, StateStorage.SaveSession> mySaveSessions = new THashMap<StateStorage, StateStorage.SaveSession>();
|
||||
|
||||
public CompoundSaveSession(final CompoundExternalizationSession compoundExternalizationSession) {
|
||||
final Collection<StateStorage> stateStorages = compoundExternalizationSession.getStateStorages();
|
||||
|
||||
for (StateStorage stateStorage : stateStorages) {
|
||||
for (StateStorage stateStorage : compoundExternalizationSession.getStateStorages()) {
|
||||
mySaveSessions.put(stateStorage, stateStorage.startSave(compoundExternalizationSession.getExternalizationSession(stateStorage)));
|
||||
}
|
||||
}
|
||||
|
||||
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
|
||||
List<IFile> result = new ArrayList<IFile>();
|
||||
|
||||
for (StateStorage stateStorage : mySaveSessions.keySet()) {
|
||||
final StateStorage.SaveSession saveSession = mySaveSessions.get(stateStorage);
|
||||
|
||||
List<IFile> result = new SmartList<IFile>();
|
||||
for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
|
||||
result.addAll(saveSession.getStorageFilesToSave());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -56,11 +53,11 @@ public class CompoundSaveSession {
|
||||
public void finishSave() {
|
||||
RuntimeException re = null;
|
||||
for (StateStorage stateStorage : mySaveSessions.keySet()) {
|
||||
final StateStorage.SaveSession saveSession = mySaveSessions.get(stateStorage);
|
||||
try {
|
||||
stateStorage.finishSave(saveSession);
|
||||
} catch(RuntimeException t) {
|
||||
re = t;
|
||||
stateStorage.finishSave(mySaveSessions.get(stateStorage));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
re = e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +71,10 @@ public class CompoundSaveSession {
|
||||
}
|
||||
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
List<IFile> result = new ArrayList<IFile>();
|
||||
List<IFile> result = new SmartList<IFile>();
|
||||
for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
|
||||
result.addAll(saveSession.getAllStorageFiles());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -31,6 +31,7 @@ import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.io.fs.IFile;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectLongHashMap;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
@@ -468,19 +469,18 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
Set<String> result = new HashSet<String>();
|
||||
|
||||
nextStorage:
|
||||
Set<String> result = new THashSet<String>();
|
||||
for (Pair<VirtualFile, StateStorage> pair : changedFiles) {
|
||||
final StateStorage stateStorage = pair.second;
|
||||
final StateStorage.SaveSession saveSession = myCompoundSaveSession.getSaveSession(stateStorage);
|
||||
if (saveSession == null) continue nextStorage;
|
||||
final Set<String> s = saveSession.analyzeExternalChanges(changedFiles);
|
||||
|
||||
if (s == null) return null;
|
||||
result.addAll(s);
|
||||
final StateStorage.SaveSession saveSession = myCompoundSaveSession.getSaveSession(pair.second);
|
||||
if (saveSession == null) {
|
||||
continue;
|
||||
}
|
||||
final Set<String> changes = saveSession.analyzeExternalChanges(changedFiles);
|
||||
if (changes == null) {
|
||||
return null;
|
||||
}
|
||||
result.addAll(changes);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user