StateStorageException to upper level and to core-api

This commit is contained in:
Dmitry Jemerov
2011-08-18 18:32:18 +02:00
parent 22dbd0abcd
commit 0668c9d659
27 changed files with 143 additions and 129 deletions
@@ -0,0 +1,33 @@
/*
* Copyright 2000-2011 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;
public class StateStorageException extends RuntimeException {
public StateStorageException() {
}
public StateStorageException(final String message) {
super(message);
}
public StateStorageException(final String message, final Throwable cause) {
super(message, cause);
}
public StateStorageException(final Throwable cause) {
super(cause);
}
}
@@ -17,10 +17,7 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.components.PathMacroSubstitutor;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.components.*;
import com.intellij.openapi.components.impl.ComponentManagerImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
@@ -68,7 +65,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
}
@Override
public void load() throws IOException, StateStorage.StateStorageException {
public void load() throws IOException, StateStorageException {
super.load();
final ModuleFileData storageData = getMainStorageData();
@@ -92,7 +89,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
}
}
public ModuleFileData getMainStorageData() throws StateStorage.StateStorageException {
public ModuleFileData getMainStorageData() throws StateStorageException {
return (ModuleFileData)super.getMainStorageData();
}
@@ -208,7 +205,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
try {
getMainStorageData().setOption(optionName, optionValue);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.error(e);
}
}
@@ -217,7 +214,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
try {
getMainStorageData().clearOption(optionName);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.error(e);
}
}
@@ -226,7 +223,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
try {
return getMainStorageData().getOptionValue(optionName);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.error(e);
return null;
}
@@ -17,6 +17,7 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
@@ -76,21 +77,21 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
return moduleManager.getModules();
}
protected SaveSessionImpl createSaveSession() throws StateStorage.StateStorageException {
protected SaveSessionImpl createSaveSession() throws StateStorageException {
return new ProjectWithModulesSaveSession();
}
private class ProjectWithModulesSaveSession extends ProjectSaveSession {
List<SaveSession> myModuleSaveSessions = new ArrayList<SaveSession>();
public ProjectWithModulesSaveSession() throws StateStorage.StateStorageException {
public ProjectWithModulesSaveSession() throws StateStorageException {
try {
for (Module module : getPersistentModules()) {
myModuleSaveSessions.add(((ModuleImpl)module).getStateStore().startSave());
}
}
catch (IOException e) {
throw new StateStorage.StateStorageException(e.getMessage());
throw new StateStorageException(e.getMessage());
}
}
@@ -261,7 +261,7 @@ public class ModuleManagerImpl extends ModuleManager implements ProjectComponent
catch (final ModuleWithNameAlreadyExists moduleWithNameAlreadyExists) {
errors.add(ModuleLoadingErrorDescription.create(moduleWithNameAlreadyExists.getMessage(), modulePath, ModuleManagerImpl.this));
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
errors.add(ModuleLoadingErrorDescription.create(ProjectBundle.message("module.cannot.load.error", modulePath.getPath(), e.getMessage()),
modulePath, ModuleManagerImpl.this));
}
@@ -723,13 +723,13 @@ public class ModuleManagerImpl extends ModuleManager implements ProjectComponent
try {
return loadModuleInternal(filePath);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw new IOException(ProjectBundle.message("module.corrupted.file.error", FileUtil.toSystemDependentName(filePath), e.getMessage()));
}
}
private Module loadModuleInternal(String filePath) throws ModuleWithNameAlreadyExists,
IOException, StateStorage.StateStorageException {
IOException, StateStorageException {
final File moduleFile = new File(filePath);
filePath = resolveShortWindowsName(filePath);
@@ -19,6 +19,7 @@ package com.intellij.openapi.roots.impl.storage;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
@@ -57,24 +57,7 @@ public interface StateStorage {
List<IFile> getAllStorageFiles();
}
class StateStorageException extends RuntimeException {
public StateStorageException() {
}
public StateStorageException(final String message) {
super(message);
}
public StateStorageException(final String message, final Throwable cause) {
super(message, cause);
}
public StateStorageException(final Throwable cause) {
super(cause);
}
}
interface Listener {
interface Listener {
void storageFileChanged(final VirtualFileEvent event, final StateStorage storage);
}
}
@@ -29,7 +29,7 @@ import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.impl.ApplicationPathMacroManager;
import com.intellij.openapi.components.impl.ComponentManagerImpl;
import com.intellij.openapi.components.impl.stores.*;
@@ -499,7 +499,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
try {
getStateStore().load();
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw new IOException(e.getMessage());
}
finally {
@@ -127,7 +127,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
try {
createComponent(componentInterface);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw e;
}
catch (ProcessCanceledException e) {
@@ -246,7 +246,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
((BaseComponent)component).initComponent();
}
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw e;
}
catch (ProcessCanceledException e) {
@@ -693,7 +693,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
catch (ProcessCanceledException e) {
throw e;
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw e;
}
catch (Throwable t) {
@@ -18,10 +18,7 @@ package com.intellij.openapi.components.impl.stores;
import com.intellij.application.options.PathMacrosImpl;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.impl.ApplicationImpl;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageOperation;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.NamedJDOMExternalizable;
import com.intellij.openapi.util.Pair;
@@ -98,7 +95,8 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
myStateStorageManager.addMacro(CONFIG_MACRO, configPath);
}
public boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles, final Collection<String> notReloadableComponents) throws StateStorage.StateStorageException, IOException {
public boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles, final Collection<String> notReloadableComponents) throws
StateStorageException, IOException {
final SaveSession saveSession = startSave();
final Set<String> componentNames = saveSession.analyzeExternalChanges(changedFiles);
@@ -15,10 +15,7 @@
*/
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.ComponentManager;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.components.PathMacroSubstitutor;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.impl.ProjectManagerImpl;
import org.jdom.Element;
@@ -108,11 +105,11 @@ abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl {
return ourConversionProblemsStorage;
}
public void load() throws IOException, StateStorage.StateStorageException {
public void load() throws IOException, StateStorageException {
getMainStorageData(); //load it
}
public BaseStorageData getMainStorageData() throws StateStorage.StateStorageException {
public BaseStorageData getMainStorageData() throws StateStorageException {
return (BaseStorageData) getMainStorage().getStorageData(false);
}
@@ -50,14 +50,14 @@ abstract class ComponentStoreImpl implements IComponentStore {
@Deprecated
@Nullable
private StateStorage getStateStorage(@NotNull final Storage storageSpec) throws StateStorage.StateStorageException {
private StateStorage getStateStorage(@NotNull final Storage storageSpec) throws StateStorageException {
return getStateStorageManager().getStateStorage(storageSpec);
}
@Deprecated
@Nullable
private StateStorage getOldStorage(final Object component, final String componentName, final StateStorageOperation operation)
throws StateStorage.StateStorageException {
throws StateStorageException {
return getStateStorageManager().getOldStorage(component, componentName, operation);
}
@@ -133,13 +133,13 @@ abstract class ComponentStoreImpl implements IComponentStore {
mySession = session;
return mySession;
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.info(e);
throw new IOException(e.getMessage());
}
}
protected SaveSessionImpl createSaveSession() throws StateStorage.StateStorageException {
protected SaveSessionImpl createSaveSession() throws StateStorageException {
return new SaveSessionImpl();
}
@@ -216,7 +216,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
@Nullable
private static Element getJdomState(final Object component, final String componentName, @NotNull final StateStorage defaultsStorage)
throws StateStorage.StateStorageException {
throws StateStorageException {
ComponentRoamingManager roamingManager = ComponentRoamingManager.getInstance();
if (!roamingManager.typeSpecified(componentName)) {
if (component instanceof RoamingTypeDisabled) {
@@ -354,7 +354,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
@NotNull
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent,
final StateStorageOperation operation) throws StateStorage.StateStorageException {
final StateStorageOperation operation) throws StateStorageException {
final State stateSpec = getStateSpec(persistentStateComponent);
final Storage[] storages = stateSpec.storages();
@@ -382,10 +382,10 @@ abstract class ComponentStoreImpl implements IComponentStore {
return storageChooser.selectStorages(storages, persistentStateComponent, operation);
}
catch (InstantiationException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
catch (IllegalAccessException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
}
}
@@ -410,7 +410,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
try {
return myStorageManagerSaveSession.getAllStorageFilesToSave();
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw new IOException(e.getMessage());
}
}
@@ -424,7 +424,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
try {
settingsSavingComponent.save();
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.info(e);
throw new IOException(e.getMessage());
}
@@ -435,7 +435,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
myStorageManagerSaveSession.save();
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.info(e);
throw new IOException(e.getMessage());
}
@@ -465,7 +465,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
}
}
protected void commit() throws StateStorage.StateStorageException {
protected void commit() throws StateStorageException {
final StateStorageManager storageManager = getStateStorageManager();
final StateStorageManager.ExternalizationSession session = storageManager.startExternalization();
@@ -520,7 +520,7 @@ abstract class ComponentStoreImpl implements IComponentStore {
}
protected void doReload(final Set<Pair<VirtualFile, StateStorage>> changedFiles, @NotNull final Set<String> componentNames)
throws StateStorage.StateStorageException {
throws StateStorageException {
for (Pair<VirtualFile, StateStorage> pair : changedFiles) {
assert pair != null;
final StateStorage storage = pair.second;
@@ -16,6 +16,7 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.util.io.fs.IFile;
import java.util.*;
@@ -34,7 +35,7 @@ public class CompoundSaveSession {
}
}
public List<IFile> getAllStorageFilesToSave() throws StateStorage.StateStorageException {
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
List<IFile> result = new ArrayList<IFile>();
for (StateStorage stateStorage : mySaveSessions.keySet()) {
@@ -46,7 +47,7 @@ public class CompoundSaveSession {
return result;
}
public void save() throws StateStorage.StateStorageException {
public void save() throws StateStorageException {
for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
saveSession.save();
}
@@ -115,7 +115,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
}
@Nullable
public StateStorage getStateStorage(@NotNull Storage storageSpec) throws StateStorage.StateStorageException {
public StateStorage getStateStorage(@NotNull Storage storageSpec) throws StateStorageException {
return storage;
}
@@ -145,7 +145,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
@Nullable
public StateStorage getOldStorage(Object component, final String componentName, final StateStorageOperation operation)
throws StateStorage.StateStorageException {
throws StateStorageException {
return storage;
}
@@ -174,7 +174,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
throw new UnsupportedOperationException("Method getLocation not implemented in " + getClass());
}
public void load() throws IOException, StateStorage.StateStorageException {
public void load() throws IOException, StateStorageException {
if (myElement == null) return;
super.load();
}
@@ -187,11 +187,11 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
}
public void setState(@NotNull final Storage[] storageSpecs, final Object component, final String componentName, final Object state)
throws StateStorage.StateStorageException {
throws StateStorageException {
externalizationSession.setState(component, componentName, state, null);
}
public void setStateInOldStorage(final Object component, final String componentName, final Object state) throws StateStorage.StateStorageException {
public void setStateInOldStorage(final Object component, final String componentName, final Object state) throws StateStorageException {
externalizationSession.setState(component, componentName, state, null);
}
}
@@ -209,7 +209,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
throw new UnsupportedOperationException("Method analyzeExternalChanges not implemented in " + getClass());
}
public List<IFile> getAllStorageFilesToSave() throws StateStorage.StateStorageException {
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
return Collections.emptyList();
}
@@ -217,7 +217,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
return Collections.emptyList();
}
public void save() throws StateStorage.StateStorageException {
public void save() throws StateStorageException {
saveSession.save();
}
}
@@ -15,7 +15,7 @@
*/
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StorageId;
import com.intellij.openapi.diagnostic.Logger;
@@ -85,7 +85,7 @@ class DefaultStateSerializer {
@SuppressWarnings({"unchecked"})
@Nullable
static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass, @Nullable T mergeInto) throws StateStorage.StateStorageException {
static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass, @Nullable T mergeInto) throws StateStorageException {
if (stateElement == null) return mergeInto;
if (stateClass.equals(Element.class)) {
@@ -104,14 +104,14 @@ class DefaultStateSerializer {
return t;
}
catch (InvalidDataException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
}
catch (InstantiationException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
catch (IllegalAccessException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
}
else {
@@ -18,6 +18,7 @@ package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.application.ex.DecodeDefaultsUtil;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.util.xmlb.JDOMXIncluder;
import org.jdom.Document;
@@ -17,10 +17,7 @@ package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.StateSplitter;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.util.Disposer;
@@ -16,7 +16,6 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.Patches;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
@@ -24,6 +23,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.StreamProvider;
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.util.Pair;
@@ -30,5 +31,6 @@ public interface IApplicationStore extends IComponentStore {
void setConfigPath(final String configPath);
boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles, final Collection<String> notReloadableComponents) throws StateStorage.StateStorageException, IOException;
boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles, final Collection<String> notReloadableComponents) throws
StateStorageException, IOException;
}
@@ -16,6 +16,7 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.io.fs.IFile;
@@ -33,7 +34,7 @@ public interface IComponentStore {
boolean isReloadPossible(Set<String> componentNames);
void load() throws IOException, StateStorage.StateStorageException;
void load() throws IOException, StateStorageException;
boolean isSaving();
StateStorageManager getStateStorageManager();
@@ -16,6 +16,7 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.StorageScheme;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.project.impl.ProjectImpl;
@@ -53,10 +54,10 @@ public interface IProjectStore extends IComponentStore {
@Nullable
String getPresentableUrl();
boolean reload(final Set<Pair<VirtualFile,StateStorage>> changedFiles) throws StateStorage.StateStorageException, IOException;
boolean reload(final Set<Pair<VirtualFile,StateStorage>> changedFiles) throws StateStorageException, IOException;
//------ This methods should be got rid of
void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorage.StateStorageException;
void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorageException;
@Nullable
VirtualFile getProjectFile();
@@ -16,10 +16,7 @@
package com.intellij.openapi.components.impl.stores;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ComponentConfig;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageOperation;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.components.*;
import com.intellij.openapi.project.impl.ProjectImpl;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -50,7 +47,7 @@ class ProjectStateStorageManager extends StateStorageManagerImpl {
}
protected String getOldStorageSpec(Object component, final String componentName, final StateStorageOperation operation) throws
StateStorage.StateStorageException {
StateStorageException {
final ComponentConfig config = myProject.getConfig(component.getClass());
assert config != null : "Couldn't find old storage for " + component.getClass().getName();
@@ -341,7 +341,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
}
public void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorage.StateStorageException {
public void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorageException {
//load();
myProject.init();
}
@@ -466,13 +466,13 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
}
protected SaveSessionImpl createSaveSession() throws StateStorage.StateStorageException {
protected SaveSessionImpl createSaveSession() throws StateStorageException {
return new ProjectSaveSession();
}
protected class ProjectSaveSession extends SaveSessionImpl {
ProjectSaveSession() throws StateStorage.StateStorageException {
ProjectSaveSession() throws StateStorageException {
}
public List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
@@ -633,7 +633,8 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
@NotNull
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent, final StateStorageOperation operation) throws StateStorage.StateStorageException {
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent, final StateStorageOperation operation) throws
StateStorageException {
Storage[] result = super.getComponentStorageSpecs(persistentStateComponent, operation);
if (operation == StateStorageOperation.READ) {
@@ -676,7 +677,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
}
}
public boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles) throws IOException, StateStorage.StateStorageException {
public boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles) throws IOException, StateStorageException {
final SaveSession saveSession = startSave();
final Set<String> componentNames;
@@ -36,7 +36,7 @@ public interface StateStorageManager {
TrackingPathMacroSubstitutor getMacroSubstitutor();
@Nullable
StateStorage getStateStorage(@NotNull Storage storageSpec) throws StateStorage.StateStorageException;
StateStorage getStateStorage(@NotNull Storage storageSpec) throws StateStorageException;
@Nullable
StateStorage getFileStateStorage(String fileName);
@@ -50,7 +50,8 @@ public interface StateStorageManager {
void finishSave(SaveSession saveSession);
@Nullable
StateStorage getOldStorage(Object component, final String componentName, final StateStorageOperation operation) throws StateStorage.StateStorageException;
StateStorage getOldStorage(Object component, final String componentName, final StateStorageOperation operation) throws
StateStorageException;
@Nullable
String expandMacroses(String file);
@@ -65,8 +66,8 @@ public interface StateStorageManager {
interface ExternalizationSession {
void setState(@NotNull Storage[] storageSpecs, Object component, final String componentName, Object state) throws StateStorage.StateStorageException;
void setStateInOldStorage(Object component, final String componentName, Object state) throws StateStorage.StateStorageException;
void setState(@NotNull Storage[] storageSpecs, Object component, final String componentName, Object state) throws StateStorageException;
void setStateInOldStorage(Object component, final String componentName, Object state) throws StateStorageException;
}
interface SaveSession {
@@ -74,8 +75,8 @@ public interface StateStorageManager {
@Nullable
Set<String> analyzeExternalChanges(Set<Pair<VirtualFile, StateStorage>> files);
List<IFile> getAllStorageFilesToSave() throws StateStorage.StateStorageException;
List<IFile> getAllStorageFilesToSave() throws StateStorageException;
List<IFile> getAllStorageFiles();
void save() throws StateStorage.StateStorageException;
void save() throws StateStorageException;
}
}
@@ -95,13 +95,13 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
}
@Nullable
public StateStorage getStateStorage(@NotNull final Storage storageSpec) throws StateStorage.StateStorageException {
public StateStorage getStateStorage(@NotNull final Storage storageSpec) throws StateStorageException {
final String key = getStorageSpecId(storageSpec);
return getStateStorage(storageSpec, key);
}
@Nullable
private StateStorage getStateStorage(final Storage storageSpec, final String key) throws StateStorage.StateStorageException {
private StateStorage getStateStorage(final Storage storageSpec, final String key) throws StateStorageException {
if (myStorages.get(key) == null) {
final StateStorage stateStorage = createStateStorage(storageSpec);
putStorageToMap(key, stateStorage);
@@ -213,7 +213,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
}
@Nullable
private StateStorage createStateStorage(final Storage storageSpec) throws StateStorage.StateStorageException {
private StateStorage createStateStorage(final Storage storageSpec) throws StateStorageException {
if (!storageSpec.storageClass().equals(StorageAnnotationsDefaultValues.NullStateStorage.class)) {
final String key = UUID.randomUUID().toString();
((MutablePicoContainer)myPicoContainer).registerComponentImplementation(key, storageSpec.storageClass());
@@ -243,7 +243,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
@Nullable
private StateStorage createDirectoryStateStorage(final String file, final Class<? extends StateSplitter> splitterClass)
throws StateStorage.StateStorageException {
throws StateStorageException {
final String expandedFile = expandMacroses(file);
if (expandedFile == null) {
myStorages.put(file, null);
@@ -256,10 +256,10 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
splitter = splitterClass.newInstance();
}
catch (InstantiationException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
catch (IllegalAccessException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
return new DirectoryBasedStorage(myPathMacroSubstitutor, expandedFile, splitter, this, myPicoContainer);
@@ -450,7 +450,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
CompoundExternalizationSession myCompoundExternalizationSession = new CompoundExternalizationSession();
public void setState(@NotNull final Storage[] storageSpecs, final Object component, final String componentName, final Object state)
throws StateStorage.StateStorageException {
throws StateStorageException {
assert mySession == this;
for (Storage storageSpec : storageSpecs) {
@@ -462,7 +462,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
}
}
public void setStateInOldStorage(Object component, final String componentName, Object state) throws StateStorage.StateStorageException {
public void setStateInOldStorage(Object component, final String componentName, Object state) throws StateStorageException {
assert mySession == this;
StateStorage stateStorage = getOldStorage(component, componentName, StateStorageOperation.WRITE);
if (stateStorage != null) {
@@ -472,12 +472,13 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
}
@Nullable
public StateStorage getOldStorage(Object component, final String componentName, final StateStorageOperation operation) throws StateStorage.StateStorageException {
public StateStorage getOldStorage(Object component, final String componentName, final StateStorageOperation operation) throws
StateStorageException {
return getFileStateStorage(getOldStorageSpec(component, componentName, operation));
}
protected abstract String getOldStorageSpec(Object component, final String componentName, final StateStorageOperation operation)
throws StateStorage.StateStorageException;
throws StateStorageException;
protected class MySaveSession implements SaveSession {
CompoundSaveSession myCompoundSaveSession;
@@ -495,7 +496,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
myCompoundSaveSession = new CompoundSaveSession(externalizationSession.myCompoundExternalizationSession);
}
public List<IFile> getAllStorageFilesToSave() throws StateStorage.StateStorageException {
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
assert mySession == this;
return myCompoundSaveSession.getAllStorageFilesToSave();
}
@@ -504,7 +505,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
return myCompoundSaveSession.getAllStorageFiles();
}
public void save() throws StateStorage.StateStorageException {
public void save() throws StateStorageException {
assert mySession == this;
myCompoundSaveSession.save();
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.DocumentRunnable;
@@ -89,7 +90,7 @@ public class StorageUtil {
}
}
static void save(final IFile file, final Parent element, final Object requestor) throws StateStorage.StateStorageException {
static void save(final IFile file, final Parent element, final Object requestor) throws StateStorageException {
final String filePath = file.getCanonicalPath();
try {
final Ref<IOException> refIOException = Ref.create(null);
@@ -122,11 +123,11 @@ public class StorageUtil {
}
});
if (refIOException.get() != null) {
throw new StateStorage.StateStorageException(refIOException.get());
throw new StateStorageException(refIOException.get());
}
}
catch (IOException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
}
@@ -164,12 +165,12 @@ public class StorageUtil {
}
@Deprecated
public static byte[] printDocument(final Document document) throws StateStorage.StateStorageException {
public static byte[] printDocument(final Document document) throws StateStorageException {
try {
return printDocumentToString(document).getBytes(CharsetToolkit.UTF8);
}
catch (IOException e) {
throw new StateStorage.StateStorageException(e);
throw new StateStorageException(e);
}
}
@@ -217,7 +218,7 @@ public class StorageUtil {
return printDocumentToString(document, SystemProperties.getLineSeparator());
}
static String printElement(final Element element, final String lineSeparator) throws StateStorage.StateStorageException {
static String printElement(final Element element, final String lineSeparator) throws StateStorageException {
return JDOMUtil.writeElement(element, lineSeparator);
}
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.components.impl.stores;
import com.intellij.application.options.PathMacrosCollector;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.*;
import com.intellij.openapi.diagnostic.Logger;
@@ -27,6 +27,7 @@ import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.application.impl.ApplicationImpl;
import com.intellij.openapi.components.ExportableApplicationComponent;
import com.intellij.openapi.components.StateStorage;
import com.intellij.openapi.components.StateStorageException;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
import com.intellij.openapi.components.impl.stores.IComponentStore;
import com.intellij.openapi.components.impl.stores.IProjectStore;
@@ -268,7 +269,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
scheduleDispose(project);
throw e;
}
catch (final StateStorage.StateStorageException e) {
catch (final StateStorageException e) {
scheduleDispose(project);
throw e;
}
@@ -292,13 +293,13 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
try {
return doLoadProject(filePath);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw new IOException(e.getMessage());
}
}
@Nullable
private Project doLoadProject(String filePath) throws IOException, StateStorage.StateStorageException {
private Project doLoadProject(String filePath) throws IOException, StateStorageException {
filePath = canonicalize(filePath);
ProjectImpl project = null;
try {
@@ -342,7 +343,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
catch (IOException e) {
LOG.error(e);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
LOG.error(e);
}
}
@@ -458,7 +459,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
return project;
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
throw new IOException(e.getMessage());
}
}
@@ -471,7 +472,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
@Nullable
public Project loadProjectWithProgress(final String filePath, Ref<Boolean> canceled) throws IOException {
final IOException[] io = {null};
final StateStorage.StateStorageException[] stateStorage = {null};
final StateStorageException[] stateStorage = {null};
if (filePath != null) {
refreshProjectFiles(filePath);
@@ -492,7 +493,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
io[0] = e;
return;
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
stateStorage[0] = e;
return;
}
@@ -614,7 +615,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
try {
reloadOk[0] = ((ApplicationImpl)app).getStateStore().reload(causes, components);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
Messages.showWarningDialog(ProjectBundle.message("project.reload.failed", e.getMessage()),
ProjectBundle.message("project.reload.failed.title"));
}
@@ -681,7 +682,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
LOG.debug("[RELOAD] Reloading project/components...");
reloadOk[0] = ((ProjectEx)project).getStateStore().reload(causes);
}
catch (StateStorage.StateStorageException e) {
catch (StateStorageException e) {
Messages.showWarningDialog(ProjectBundle.message("project.reload.failed", e.getMessage()),
ProjectBundle.message("project.reload.failed.title"));
}