mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.impl.convertors.Convertor12;
|
||||
import com.intellij.openapi.project.impl.convertors.Convertor23;
|
||||
import com.intellij.openapi.project.impl.convertors.Convertor34;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
@@ -32,6 +33,7 @@ public class IdeaProjectStoreImpl extends ProjectWithModulesStoreImpl {
|
||||
super(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected StateStorageManager createStateStorageManager() {
|
||||
return new ProjectStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myProject) {
|
||||
|
||||
+2
-1
@@ -310,7 +310,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
else {
|
||||
result = new IdeaPicoContainer();
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -409,6 +409,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
return myDisposedCondition;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getComponentName(@NotNull final Object component) {
|
||||
if (component instanceof NamedComponent) {
|
||||
return ((NamedComponent)component).getComponentName();
|
||||
|
||||
+1
@@ -252,6 +252,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
|
||||
return ((ProjectEx)myModule.getProject()).isOptimiseTestLoadSpeed();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected StateStorageManager createStateStorageManager() {
|
||||
return new ModuleStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myModule);
|
||||
|
||||
+5
-3
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.impl.ProjectImpl;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.fs.IFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -42,7 +43,7 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reinitComponents(final Set<String> componentNames, final boolean reloadData) {
|
||||
public void reinitComponents(@NotNull final Set<String> componentNames, final boolean reloadData) {
|
||||
super.reinitComponents(componentNames, reloadData);
|
||||
|
||||
for (Module module : getPersistentModules()) {
|
||||
@@ -63,7 +64,7 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReloadPossible(final Set<String> componentNames) {
|
||||
public boolean isReloadPossible(@NotNull final Set<String> componentNames) {
|
||||
if (!super.isReloadPossible(componentNames)) return false;
|
||||
|
||||
for (Module module : getPersistentModules()) {
|
||||
@@ -99,6 +100,7 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles(final boolean includingSubStructures) {
|
||||
final List<IFile> result = super.getAllStorageFiles(includingSubStructures);
|
||||
@@ -114,7 +116,7 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
|
||||
final Set<String> result = super.analyzeExternalChanges(changedFiles);
|
||||
if (result == null) return null;
|
||||
|
||||
|
||||
+6
-4
@@ -151,13 +151,13 @@ public class ClasspathStorage implements StateStorage {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setState(Object component, final String componentName, Object state) throws StateStorageException {
|
||||
public void setState(@NotNull Object component, @NotNull String componentName, @NotNull Object state) throws StateStorageException {
|
||||
assert component instanceof ModuleRootManager;
|
||||
assert componentName.equals("NewModuleRootManager");
|
||||
assert state.getClass() == ModuleRootManagerImpl.ModuleRootManagerState.class;
|
||||
|
||||
try {
|
||||
myConverter.setClasspath(((ModuleRootManagerImpl)component));
|
||||
myConverter.setClasspath((ModuleRootManagerImpl)component);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
throw new StateStorageException(e.getMessage());
|
||||
@@ -172,7 +172,7 @@ public class ClasspathStorage implements StateStorage {
|
||||
public ExternalizationSession startExternalization() {
|
||||
final ExternalizationSession session = new ExternalizationSession() {
|
||||
@Override
|
||||
public void setState(final Object component, final String componentName, final Object state, final Storage storageSpec)
|
||||
public void setState(@NotNull final Object component, final String componentName, @NotNull final Object state, final Storage storageSpec)
|
||||
throws StateStorageException {
|
||||
assert mySession == this;
|
||||
ClasspathStorage.this.setState(component, componentName, state);
|
||||
@@ -425,10 +425,11 @@ public class ClasspathStorage implements StateStorage {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
|
||||
if (needsSave()) {
|
||||
@@ -443,6 +444,7 @@ public class ClasspathStorage implements StateStorage {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
final List<IFile> list = new ArrayList<IFile>();
|
||||
|
||||
+14
-4
@@ -48,10 +48,12 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
|
||||
public ApplicationStoreImpl(final ApplicationImpl application, PathMacroManager pathMacroManager) {
|
||||
myApplication = application;
|
||||
myStateStorageManager = new StateStorageManagerImpl(pathMacroManager.createTrackingSubstitutor(), ROOT_ELEMENT_NAME, application, application.getPicoContainer()) {
|
||||
@Override
|
||||
protected StorageData createStorageData(String storageSpec) {
|
||||
return new FileBasedStorage.FileStorageData(ROOT_ELEMENT_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getOldStorageSpec(Object component, final String componentName, final StateStorageOperation operation) {
|
||||
final String fileName;
|
||||
|
||||
@@ -65,10 +67,12 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVersionsFilePath() {
|
||||
return PathManager.getConfigPath() + "/options/" + "appComponentVersions.xml";
|
||||
return PathManager.getConfigPath() + "/options/appComponentVersions.xml";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TrackingPathMacroSubstitutor getMacroSubstitutor(@NotNull final String fileSpec) {
|
||||
if (fileSpec.equals(StoragePathMacros.APP_CONFIG + "/" + PathMacrosImpl.EXT_FILE_NAME + XML_EXTENSION)) return null;
|
||||
return super.getMacroSubstitutor(fileSpec);
|
||||
@@ -77,23 +81,27 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
|
||||
myDefaultsStateStorage = new DefaultsStateStorage(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() throws IOException {
|
||||
long start = System.currentTimeMillis();
|
||||
myApplication.initComponents();
|
||||
LOG.info(myApplication.getComponentConfigurations().length + " application components initialized in " + (System.currentTimeMillis() - start) + " ms");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionsPath(final String path) {
|
||||
myStateStorageManager.addMacro(StoragePathMacros.getMacroName(StoragePathMacros.APP_CONFIG), path);
|
||||
myStateStorageManager.addMacro(OPTIONS_MACRO, path);
|
||||
}
|
||||
|
||||
public void setConfigPath(final String configPath) {
|
||||
@Override
|
||||
public void setConfigPath(@NotNull final String configPath) {
|
||||
myStateStorageManager.addMacro(CONFIG_MACRO, configPath);
|
||||
}
|
||||
|
||||
public boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles,
|
||||
final Collection<String> notReloadableComponents) throws StateStorageException, IOException {
|
||||
@Override
|
||||
public boolean reload(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles,
|
||||
@NotNull final Collection<String> notReloadableComponents) throws StateStorageException, IOException {
|
||||
final SaveSession saveSession = startSave();
|
||||
final Set<String> componentNames = saveSession.analyzeExternalChanges(changedFiles);
|
||||
|
||||
@@ -135,6 +143,8 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StateStorageManager getStateStorageManager() {
|
||||
return myStateStorageManager;
|
||||
}
|
||||
|
||||
+2
@@ -124,6 +124,7 @@ abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl {
|
||||
return myDefaultsStateStorage;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StateStorageManager getStateStorageManager() {
|
||||
if (myStateStorageManager == null) {
|
||||
@@ -132,5 +133,6 @@ abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl {
|
||||
return myStateStorageManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract StateStorageManager createStateStorageManager();
|
||||
}
|
||||
|
||||
+18
-4
@@ -65,8 +65,8 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
throw new UnsupportedOperationException("Method getDefaultsStorage is not supported in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent(@NotNull final Object component, final boolean service) {
|
||||
|
||||
if (component instanceof SettingsSavingComponent) {
|
||||
SettingsSavingComponent settingsSavingComponent = (SettingsSavingComponent)component;
|
||||
mySettingsSavingComponents.add(settingsSavingComponent);
|
||||
@@ -79,6 +79,7 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
|
||||
try {
|
||||
ApplicationManagerEx.getApplicationEx().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (component instanceof PersistentStateComponent) {
|
||||
initPersistentComponent((PersistentStateComponent<?>)component, false);
|
||||
@@ -97,11 +98,13 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaving() {
|
||||
return mySession != null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SaveSession startSave() throws IOException {
|
||||
try {
|
||||
@@ -411,6 +414,8 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
ShutDownTracker.getInstance().registerStopperThread(Thread.currentThread());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
|
||||
try {
|
||||
return myStorageManagerSaveSession.getAllStorageFilesToSave();
|
||||
@@ -420,6 +425,8 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SaveSession save() throws IOException {
|
||||
try {
|
||||
final SettingsSavingComponent[] settingsComponents =
|
||||
@@ -448,6 +455,7 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSave() {
|
||||
try {
|
||||
getStateStorageManager().finishSave(myStorageManagerSaveSession);
|
||||
@@ -459,6 +467,7 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
try {
|
||||
getStateStorageManager().reset();
|
||||
@@ -490,18 +499,22 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
myStorageManagerSaveSession = storageManager.startSave(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
return myStorageManagerSaveSession.analyzeExternalChanges(changedFiles);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles(final boolean includingSubStructures) {
|
||||
return myStorageManagerSaveSession.getAllStorageFiles();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isReloadPossible(final Set<String> componentNames) {
|
||||
@Override
|
||||
public boolean isReloadPossible(@NotNull final Set<String> componentNames) {
|
||||
for (String componentName : componentNames) {
|
||||
final Object component = myComponents.get(componentName);
|
||||
|
||||
@@ -516,7 +529,8 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reinitComponents(final Set<String> componentNames, final boolean reloadData) {
|
||||
@Override
|
||||
public void reinitComponents(@NotNull final Set<String> componentNames, final boolean reloadData) {
|
||||
for (String componentName : componentNames) {
|
||||
final PersistentStateComponent component = (PersistentStateComponent)myComponents.get(componentName);
|
||||
if (component != null) {
|
||||
|
||||
+9
-4
@@ -54,6 +54,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected StateStorageManager createStateStorageManager() {
|
||||
Document _d = null;
|
||||
@@ -98,11 +99,13 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
|
||||
myProjectManager.setDefaultProjectRootElement(getDocumentToSave().getRootElement());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
return Collections.emptyList();
|
||||
@@ -186,7 +189,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -210,13 +213,13 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(@NotNull final Storage[] storageSpecs, final Object component, final String componentName, final Object state)
|
||||
public void setState(@NotNull final Storage[] storageSpecs, @NotNull final Object component, final String componentName, @NotNull final Object state)
|
||||
throws StateStorageException {
|
||||
externalizationSession.setState(component, componentName, state, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStateInOldStorage(final Object component, final String componentName, final Object state) throws StateStorageException {
|
||||
public void setStateInOldStorage(@NotNull final Object component, @NotNull final String componentName, @NotNull final Object state) throws StateStorageException {
|
||||
externalizationSession.setState(component, componentName, state, null);
|
||||
}
|
||||
}
|
||||
@@ -231,15 +234,17 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
|
||||
//returns set of component which were changed, null if changes are much more than just component state.
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(Set<Pair<VirtualFile, StateStorage>> files) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile, StateStorage>> files) {
|
||||
throw new UnsupportedOperationException("Method analyzeExternalChanges not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
return Collections.emptyList();
|
||||
|
||||
+23
-3
@@ -78,16 +78,19 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
|
||||
final Listener listener = messageBus.syncPublisher(STORAGE_TOPIC);
|
||||
virtualFileTracker.addTracker(fileUrl, new VirtualFileAdapter() {
|
||||
@Override
|
||||
public void contentsChanged(final VirtualFileEvent event) {
|
||||
if (!StringUtil.endsWithIgnoreCase(event.getFile().getName(), ".xml")) return;
|
||||
listener.storageFileChanged(event, DirectoryBasedStorage.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileDeleted(final VirtualFileEvent event) {
|
||||
if (!StringUtil.endsWithIgnoreCase(event.getFile().getName(), ".xml")) return;
|
||||
listener.storageFileChanged(event, DirectoryBasedStorage.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileCreated(final VirtualFileEvent event) {
|
||||
if (!StringUtil.endsWithIgnoreCase(event.getFile().getName(), ".xml")) return;
|
||||
listener.storageFileChanged(event, DirectoryBasedStorage.this);
|
||||
@@ -98,6 +101,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
myFileTypeManager = FileTypeManager.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getState(final Object component, final String componentName, Class<T> stateClass, @Nullable T mergeInto)
|
||||
throws StateStorageException {
|
||||
@@ -118,12 +122,14 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasState(final Object component, final String componentName, final Class<?> aClass, final boolean reloadData) throws StateStorageException {
|
||||
if (!myDir.exists()) return false;
|
||||
if (reloadData) myStorageData = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ExternalizationSession startExternalization() {
|
||||
if (myStorageData == null) {
|
||||
@@ -140,6 +146,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SaveSession startSave(final ExternalizationSession externalizationSession) {
|
||||
assert mySession == externalizationSession;
|
||||
@@ -150,6 +157,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSave(final SaveSession saveSession) {
|
||||
try {
|
||||
LOG.assertTrue(mySession == saveSession);
|
||||
@@ -158,10 +166,12 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(final Set<String> changedComponents) throws StateStorageException {
|
||||
myStorageData = loadState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@@ -174,6 +184,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
myPathMacroSubstitutor = pathMacroSubstitutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() throws StateStorageException {
|
||||
assert mySession == this;
|
||||
final Set<String> currentNames = new HashSet<String>();
|
||||
@@ -187,6 +198,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
}
|
||||
|
||||
myStorageData.process(new DirectoryStorageData.StorageDataProcessor() {
|
||||
@Override
|
||||
public void process(final String componentName, final IFile file, final Element element) {
|
||||
currentNames.remove(file.getName());
|
||||
|
||||
@@ -208,6 +220,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
|
||||
if (myDir.exists() && !currentNames.isEmpty()) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myDir.exists()) {
|
||||
for (String name : currentNames) {
|
||||
@@ -238,8 +251,9 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
myStorageData.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
boolean containsSelf = false;
|
||||
|
||||
for (Pair<VirtualFile, StateStorage> pair : changedFiles) {
|
||||
@@ -263,6 +277,8 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
return new HashSet<String>(myStorageData.getComponentNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
|
||||
assert mySession == this;
|
||||
|
||||
@@ -278,6 +294,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
}
|
||||
|
||||
myStorageData.process(new DirectoryStorageData.StorageDataProcessor() {
|
||||
@Override
|
||||
public void process(final String componentName, final IFile file, final Element element) {
|
||||
if (currentChildNames.contains(file.getName())) {
|
||||
currentChildNames.remove(file.getName());
|
||||
@@ -303,6 +320,8 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
return filesToSave;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
return new ArrayList<IFile>(myStorageData.getAllStorageFiles().keySet());
|
||||
}
|
||||
@@ -315,13 +334,14 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
myStorageData = storageData;
|
||||
}
|
||||
|
||||
public void setState(final Object component, final String componentName, final Object state, final Storage storageSpec)
|
||||
@Override
|
||||
public void setState(@NotNull final Object component, final String componentName, @NotNull final Object state, final Storage storageSpec)
|
||||
throws StateStorageException {
|
||||
assert mySession == this;
|
||||
setState(componentName, state, storageSpec);
|
||||
}
|
||||
|
||||
private void setState(final String componentName, Object state, final Storage storageSpec) throws StateStorageException {
|
||||
private void setState(final String componentName, @NotNull Object state, final Storage storageSpec) throws StateStorageException {
|
||||
try {
|
||||
final Element element = DefaultStateSerializer.serializeState(state, storageSpec);
|
||||
|
||||
|
||||
+6
-6
@@ -174,6 +174,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
myCachedVirtualFile = StorageUtil.save(myFile, getDocumentToSave(), this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
|
||||
boolean needsSave = needsSave();
|
||||
@@ -189,6 +190,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
return Collections.singletonList(myFile);
|
||||
@@ -249,16 +251,14 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
myBlockSavingTheContent = false;
|
||||
try {
|
||||
VirtualFile file = getVirtualFile();
|
||||
if (file == null || file.isDirectory()) {
|
||||
LOG.info("Document was not loaded for " + myFileSpec + " file is " + (file == null ? "null" : "directory"));
|
||||
if (file == null || file.isDirectory() || !file.isValid()) {
|
||||
LOG.info("Document was not loaded for " + myFileSpec + " file is " + (file == null ? "null" : "directory"));
|
||||
return null;
|
||||
}
|
||||
else if (file.getLength() == 0) {
|
||||
if (file.getLength() == 0) {
|
||||
return processReadException(null);
|
||||
}
|
||||
else {
|
||||
return loadDocumentImpl(file);
|
||||
}
|
||||
return loadDocumentImpl(file);
|
||||
}
|
||||
catch (final JDOMException e) {
|
||||
return processReadException(e);
|
||||
|
||||
+4
-5
@@ -19,6 +19,7 @@ import com.intellij.openapi.components.StateStorageException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.components.StateStorage;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Collection;
|
||||
@@ -27,10 +28,8 @@ import java.io.IOException;
|
||||
public interface IApplicationStore extends IComponentStore {
|
||||
void setOptionsPath(String path);
|
||||
|
||||
StateStorageManager getStateStorageManager();
|
||||
void setConfigPath(@NotNull String configPath);
|
||||
|
||||
void setConfigPath(final String configPath);
|
||||
|
||||
boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles, final Collection<String> notReloadableComponents) throws
|
||||
StateStorageException, IOException;
|
||||
boolean reload(@NotNull Set<Pair<VirtualFile, StateStorage>> changedFiles, @NotNull Collection<String> notReloadableComponents)
|
||||
throws StateStorageException, IOException;
|
||||
}
|
||||
|
||||
+9
-6
@@ -28,19 +28,18 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IComponentStore {
|
||||
|
||||
void initComponent(Object component, boolean service);
|
||||
void reinitComponents(Set<String> componentNames, boolean reloadData);
|
||||
boolean isReloadPossible(Set<String> componentNames);
|
||||
void initComponent(@NotNull Object component, boolean service);
|
||||
void reinitComponents(@NotNull Set<String> componentNames, boolean reloadData);
|
||||
boolean isReloadPossible(@NotNull Set<String> componentNames);
|
||||
|
||||
void load() throws IOException, StateStorageException;
|
||||
boolean isSaving();
|
||||
|
||||
@NotNull
|
||||
StateStorageManager getStateStorageManager();
|
||||
|
||||
|
||||
class SaveCancelledException extends IOException {
|
||||
|
||||
public SaveCancelledException() {
|
||||
}
|
||||
|
||||
@@ -54,13 +53,17 @@ public interface IComponentStore {
|
||||
SaveSession startSave() throws IOException;
|
||||
|
||||
interface SaveSession {
|
||||
@NotNull
|
||||
List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException;
|
||||
@NotNull
|
||||
SaveSession save() throws IOException;
|
||||
void finishSave();
|
||||
void reset();
|
||||
|
||||
@Nullable
|
||||
Set<String> analyzeExternalChanges(Set<Pair<VirtualFile,StateStorage>> changedFiles);
|
||||
Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles);
|
||||
|
||||
@NotNull
|
||||
List<IFile> getAllStorageFiles(final boolean includingSubStructures);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ public interface IProjectStore extends IComponentStore {
|
||||
@Nullable
|
||||
String getPresentableUrl();
|
||||
|
||||
boolean reload(final Set<Pair<VirtualFile,StateStorage>> changedFiles) throws StateStorageException, IOException;
|
||||
boolean reload(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles) throws StateStorageException, IOException;
|
||||
|
||||
//------ This methods should be got rid of
|
||||
void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorageException;
|
||||
@@ -70,7 +70,7 @@ public interface IProjectStore extends IComponentStore {
|
||||
@Nullable
|
||||
VirtualFile getWorkspaceFile();
|
||||
|
||||
void loadProjectFromTemplate(ProjectImpl project);
|
||||
void loadProjectFromTemplate(@NotNull ProjectImpl project);
|
||||
|
||||
/** @deprecated please use {@linkplain #getProjectFile()} (to remove in IDEA 13) */
|
||||
@NotNull
|
||||
|
||||
+24
-4
@@ -106,6 +106,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
VirtualFile projectDir = projectFile.getParent();
|
||||
@@ -200,7 +201,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
}
|
||||
|
||||
|
||||
myCachedLocation = null;
|
||||
myPresentableUrl = null;
|
||||
}
|
||||
@@ -367,7 +368,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProjectFromTemplate(final ProjectImpl defaultProject) {
|
||||
public void loadProjectFromTemplate(@NotNull final ProjectImpl defaultProject) {
|
||||
final StateStorage stateStorage = getStateStorageManager().getFileStateStorage(DEFAULT_STATE_STORAGE);
|
||||
|
||||
assert stateStorage instanceof XmlElementStorage;
|
||||
@@ -407,6 +408,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return storage;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected StateStorageManager createStateStorageManager() {
|
||||
return new ProjectStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myProject);
|
||||
@@ -426,6 +428,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
myProject = storageData.myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageData clone() {
|
||||
return new ProjectStorageData(this);
|
||||
}
|
||||
@@ -440,6 +443,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
super(storageData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageData clone() {
|
||||
return new WsStorageData(this);
|
||||
}
|
||||
@@ -454,6 +458,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
super(storageData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(@NotNull final Element root) throws IOException {
|
||||
final String v = root.getAttributeValue(VERSION_OPTION);
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
@@ -469,6 +474,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
protected void convert(final Element root, final int originalVersion) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageData clone() {
|
||||
return new IprStorageData(this);
|
||||
}
|
||||
@@ -483,6 +489,8 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
ProjectSaveSession() throws StateStorageException {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
|
||||
List<IFile> result = new ArrayList<IFile>();
|
||||
|
||||
@@ -497,6 +505,8 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
protected void collectSubfilesToSave(final List<IFile> result) throws IOException { }
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SaveSession save() throws IOException {
|
||||
final ProjectImpl.UnableToSaveProjectNotification[] notifications =
|
||||
NotificationsManager.getNotificationsManager().getNotificationsOfType(ProjectImpl.UnableToSaveProjectNotification.class, myProject);
|
||||
@@ -523,6 +533,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
private ReadonlyStatusHandler.OperationStatus ensureConfigFilesWritable() {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<ReadonlyStatusHandler.OperationStatus>() {
|
||||
@Override
|
||||
public ReadonlyStatusHandler.OperationStatus compute() {
|
||||
final List<IFile> filesToSave;
|
||||
try {
|
||||
@@ -559,7 +570,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (readonlyFiles.size() == 0) {
|
||||
final VirtualFile projectBaseDir = getProjectBaseDir();
|
||||
if (projectBaseDir != null && projectBaseDir.isValid()) {
|
||||
@@ -594,6 +605,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
|
||||
private final StateStorageChooser myStateStorageChooser = new StateStorageChooser() {
|
||||
@Override
|
||||
public Storage[] selectStorages(final Storage[] storages, final Object component, final StateStorageOperation operation) {
|
||||
if (operation == StateStorageOperation.READ) {
|
||||
OrderedSet<Storage> result = new OrderedSet<Storage>();
|
||||
@@ -658,36 +670,44 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
@SuppressWarnings("ClassExplicitlyAnnotation")
|
||||
private static class MyStorage implements Storage {
|
||||
@Override
|
||||
public String id() {
|
||||
return "___Default___";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String file() {
|
||||
return DEFAULT_STATE_STORAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageScheme scheme() {
|
||||
return StorageScheme.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends StateStorage> storageClass() {
|
||||
return StorageAnnotationsDefaultValues.NullStateStorage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends StateSplitter> stateSplitter() {
|
||||
return StorageAnnotationsDefaultValues.NullStateSplitter.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
throw new UnsupportedOperationException("Method annotationType not implemented in " + getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean reload(final Set<Pair<VirtualFile, StateStorage>> changedFiles) throws IOException, StateStorageException {
|
||||
@Override
|
||||
public boolean reload(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) throws IOException, StateStorageException {
|
||||
final SaveSession saveSession = startSave();
|
||||
|
||||
final Set<String> componentNames;
|
||||
|
||||
+7
-3
@@ -66,17 +66,21 @@ public interface StateStorageManager {
|
||||
|
||||
|
||||
interface ExternalizationSession {
|
||||
void setState(@NotNull Storage[] storageSpecs, Object component, String componentName, Object state) throws StateStorageException;
|
||||
void setStateInOldStorage(Object component, String componentName, Object state) throws StateStorageException;
|
||||
void setState(@NotNull Storage[] storageSpecs, @NotNull Object component, String componentName, @NotNull Object state) throws StateStorageException;
|
||||
void setStateInOldStorage(@NotNull Object component, @NotNull String componentName, @NotNull Object state) throws StateStorageException;
|
||||
}
|
||||
|
||||
interface SaveSession {
|
||||
//returns set of component which were changed, null if changes are much more than just component state.
|
||||
@Nullable
|
||||
Set<String> analyzeExternalChanges(Set<Pair<VirtualFile, StateStorage>> files);
|
||||
Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile, StateStorage>> files);
|
||||
|
||||
@NotNull
|
||||
List<IFile> getAllStorageFilesToSave() throws StateStorageException;
|
||||
|
||||
@NotNull
|
||||
List<IFile> getAllStorageFiles();
|
||||
|
||||
void save() throws StateStorageException;
|
||||
}
|
||||
}
|
||||
|
||||
+37
-7
@@ -88,16 +88,19 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public TrackingPathMacroSubstitutor getMacroSubstitutor() {
|
||||
return myPathMacroSubstitutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addMacro(String macro, String expansion) {
|
||||
// avoid hundreds of $MODULE_FILE$ instances
|
||||
myMacros.put(("$" + macro + "$").intern(), expansion);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public StateStorage getStateStorage(@NotNull final Storage storageSpec) throws StateStorageException {
|
||||
String key = getStorageSpecId(storageSpec);
|
||||
@@ -116,6 +119,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public StateStorage getFileStateStorage(final String fileName) {
|
||||
myStorageLock.lock();
|
||||
@@ -132,6 +136,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getStorageFileNames() {
|
||||
myStorageLock.lock();
|
||||
try {
|
||||
@@ -169,12 +174,10 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
((MutablePicoContainer)myPicoContainer).registerComponentImplementation(key, storageSpec.storageClass());
|
||||
return (StateStorage)myPicoContainer.getComponentInstance(key);
|
||||
}
|
||||
else if (!storageSpec.stateSplitter().equals(StorageAnnotationsDefaultValues.NullStateSplitter.class)) {
|
||||
if (!storageSpec.stateSplitter().equals(StorageAnnotationsDefaultValues.NullStateSplitter.class)) {
|
||||
return createDirectoryStateStorage(storageSpec.file(), storageSpec.stateSplitter());
|
||||
}
|
||||
else {
|
||||
return createFileStateStorage(storageSpec.file());
|
||||
}
|
||||
return createFileStateStorage(storageSpec.file());
|
||||
}
|
||||
|
||||
private static String getStorageSpecId(Storage storageSpec) {
|
||||
@@ -186,6 +189,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStateStorage(@NotNull String file) {
|
||||
myStorageLock.lock();
|
||||
try {
|
||||
@@ -233,6 +237,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
|
||||
return new FileBasedStorage(getMacroSubstitutor(fileSpec), this, expandedFile, fileSpec, myRootTagName, this,
|
||||
myPicoContainer, ComponentRoamingManager.getInstance(), this) {
|
||||
@Override
|
||||
@NotNull
|
||||
protected StorageData createStorageData() {
|
||||
return StateStorageManagerImpl.this.createStorageData(fileSpec);
|
||||
@@ -240,6 +245,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVersion(String name) {
|
||||
Map<String, Long> versions = getComponentVersions();
|
||||
return versions.containsKey(name) ? versions.get(name).longValue() : 0;
|
||||
@@ -302,11 +308,13 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
|
||||
protected abstract String getVersionsFilePath();
|
||||
|
||||
@Override
|
||||
public void changeVersion(String name, long version) {
|
||||
getComponentVersions().put(name, version);
|
||||
isDirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveContent(final String fileSpec, final InputStream content, final long size, final RoamingType roamingType, boolean async) {
|
||||
for (StreamProvider streamProvider : getStreamProviders(roamingType)) {
|
||||
try {
|
||||
@@ -323,6 +331,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(final String fileSpec, final RoamingType roamingType) {
|
||||
for (StreamProvider streamProvider : getStreamProviders(roamingType)) {
|
||||
try {
|
||||
@@ -336,6 +345,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamProvider[] getStreamProviders(RoamingType type) {
|
||||
synchronized (myStreamProviders) {
|
||||
final Collection<StreamProvider> providers = myStreamProviders.get(type);
|
||||
@@ -349,6 +359,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream loadContent(final String fileSpec, final RoamingType roamingType) throws IOException {
|
||||
for (StreamProvider streamProvider : getStreamProviders(roamingType)) {
|
||||
try {
|
||||
@@ -369,10 +380,12 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listSubFiles(final String fileSpec) {
|
||||
return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
for (StreamProvider provider : getStreamProviders()) {
|
||||
if (provider.isEnabled()) return true;
|
||||
@@ -388,6 +401,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
|
||||
private static final Pattern MACRO_PATTERN = Pattern.compile("(\\$[^\\$]*\\$)");
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public synchronized String expandMacros(final String file) {
|
||||
final Matcher matcher = MACRO_PATTERN.matcher(file);
|
||||
@@ -410,6 +424,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
return actualFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalizationSession startExternalization() {
|
||||
if (mySession != null) {
|
||||
LOG.error("Starting duplicate externalization session: " + mySession);
|
||||
@@ -419,6 +434,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaveSession startSave(final ExternalizationSession externalizationSession) {
|
||||
assert mySession == externalizationSession;
|
||||
SaveSession session = createSaveSession(externalizationSession);
|
||||
@@ -430,6 +446,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
return new MySaveSession((MyExternalizationSession)externalizationSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSave(final SaveSession saveSession) {
|
||||
try {
|
||||
assert mySession == saveSession : "mySession=" + mySession + " saveSession=" + saveSession;
|
||||
@@ -441,6 +458,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
mySession = null;
|
||||
}
|
||||
@@ -448,7 +466,8 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
protected class MyExternalizationSession implements ExternalizationSession {
|
||||
CompoundExternalizationSession myCompoundExternalizationSession = new CompoundExternalizationSession();
|
||||
|
||||
public void setState(@NotNull final Storage[] storageSpecs, final Object component, final String componentName, final Object state)
|
||||
@Override
|
||||
public void setState(@NotNull final Storage[] storageSpecs, @NotNull final Object component, final String componentName, @NotNull final Object state)
|
||||
throws StateStorageException {
|
||||
assert mySession == this;
|
||||
|
||||
@@ -461,7 +480,8 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
public void setStateInOldStorage(Object component, final String componentName, Object state) throws StateStorageException {
|
||||
@Override
|
||||
public void setStateInOldStorage(@NotNull Object component, @NotNull final String componentName, @NotNull Object state) throws StateStorageException {
|
||||
assert mySession == this;
|
||||
StateStorage stateStorage = getOldStorage(component, componentName, StateStorageOperation.WRITE);
|
||||
if (stateStorage != null) {
|
||||
@@ -470,6 +490,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public StateStorage getOldStorage(Object component, String componentName, StateStorageOperation operation) throws StateStorageException {
|
||||
return getFileStateStorage(getOldStorageSpec(component, componentName, operation));
|
||||
@@ -485,15 +506,20 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
myCompoundSaveSession = new CompoundSaveSession(externalizationSession.myCompoundExternalizationSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
|
||||
assert mySession == this;
|
||||
return myCompoundSaveSession.getAllStorageFilesToSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
return myCompoundSaveSession.getAllStorageFiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() throws StateStorageException {
|
||||
assert mySession == this;
|
||||
myCompoundSaveSession.save();
|
||||
@@ -509,8 +535,9 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
|
||||
//returns set of component which were changed, null if changes are much more than just component state.
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
Set<String> result = new HashSet<String>();
|
||||
|
||||
nextStorage:
|
||||
@@ -528,15 +555,18 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStreamProvider(StreamProvider streamProvider, final RoamingType type) {
|
||||
synchronized (myStreamProviders) {
|
||||
myStreamProviders.putValue(type, streamProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterStreamProvider(StreamProvider streamProvider, final RoamingType roamingType) {
|
||||
synchronized (myStreamProviders) {
|
||||
myStreamProviders.removeValue(roamingType, streamProvider);
|
||||
|
||||
+11
-13
@@ -68,7 +68,7 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
|
||||
myLocalVersionProvider.changeVersion(componentName, System.currentTimeMillis());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private boolean myDisposed;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
|
||||
protected boolean isDisposed() {
|
||||
return myDisposed;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
protected abstract Document loadDocument() throws StateStorageException;
|
||||
|
||||
@@ -252,15 +252,17 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile, StateStorage>> changedFiles) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
return Collections.emptyList();
|
||||
@@ -295,7 +297,7 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(final Object component, final String componentName, final Object state, final Storage storageSpec) throws StateStorageException {
|
||||
public void setState(@NotNull final Object component, final String componentName, @NotNull final Object state, final Storage storageSpec) throws StateStorageException {
|
||||
assert mySession == this;
|
||||
|
||||
try {
|
||||
@@ -487,21 +489,17 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
|
||||
public Set<String> analyzeExternalChanges(@NotNull final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
|
||||
try {
|
||||
Document document = loadDocument();
|
||||
|
||||
StorageData storageData = createStorageData();
|
||||
|
||||
if (document != null) {
|
||||
loadState(storageData, document.getRootElement());
|
||||
return storageData.getDifference(myStorageData, myPathMacroSubstitutor);
|
||||
}
|
||||
else {
|
||||
if (document == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
loadState(storageData, document.getRootElement());
|
||||
return storageData.getDifference(myStorageData, myPathMacroSubstitutor);
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
LOG.info(e);
|
||||
@@ -566,7 +564,7 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
|
||||
|
||||
storageData.myComponentStates.keySet().retainAll(componentsToRetain);
|
||||
}
|
||||
|
||||
|
||||
myLoadedData = storageData;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -125,7 +125,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
MessageBusConnection connection = messageBus.connect(app);
|
||||
connection.subscribe(StateStorage.STORAGE_TOPIC, new StateStorage.Listener() {
|
||||
@Override
|
||||
public void storageFileChanged(final VirtualFileEvent event, @NotNull final StateStorage storage) {
|
||||
public void storageFileChanged(@NotNull final VirtualFileEvent event, @NotNull final StateStorage storage) {
|
||||
VirtualFile file = event.getFile();
|
||||
if (!file.isDirectory() && !(event.getRequestor() instanceof StateStorage.SaveSession)) {
|
||||
saveChangedProjectFile(file, null, storage);
|
||||
@@ -142,7 +142,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
MessageBusConnection connection = messageBus.connect(project);
|
||||
connection.subscribe(StateStorage.STORAGE_TOPIC, new StateStorage.Listener() {
|
||||
@Override
|
||||
public void storageFileChanged(final VirtualFileEvent event, @NotNull final StateStorage storage) {
|
||||
public void storageFileChanged(@NotNull final VirtualFileEvent event, @NotNull final StateStorage storage) {
|
||||
VirtualFile file = event.getFile();
|
||||
if (!file.isDirectory() && !(event.getRequestor() instanceof StateStorage.SaveSession)) {
|
||||
saveChangedProjectFile(file, project, storage);
|
||||
|
||||
+3
@@ -28,6 +28,7 @@ import com.intellij.testFramework.LightPlatformLangTestCase;
|
||||
import com.intellij.util.io.fs.IFile;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -102,11 +103,13 @@ public class XmlElementStorageTest extends LightPlatformLangTestCase {
|
||||
mySavedDocument = (Document)getDocumentToSave().clone();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
|
||||
return needsSave() ? getAllStorageFiles() : Collections.<IFile>emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IFile> getAllStorageFiles() {
|
||||
throw new UnsupportedOperationException("Method getAllStorageFiles not implemented in " + getClass());
|
||||
|
||||
@@ -44,20 +44,23 @@ public interface StateStorage {
|
||||
void reload(final Set<String> changedComponents) throws StateStorageException;
|
||||
|
||||
interface ExternalizationSession {
|
||||
void setState(Object component, final String componentName, Object state, @Nullable final Storage storageSpec) throws StateStorageException;
|
||||
void setState(@NotNull Object component, final String componentName, @NotNull Object state, @Nullable final Storage storageSpec) throws StateStorageException;
|
||||
}
|
||||
|
||||
interface SaveSession {
|
||||
void save() throws StateStorageException;
|
||||
|
||||
@Nullable
|
||||
Set<String> analyzeExternalChanges(final Set<Pair<VirtualFile,StateStorage>> changedFiles);
|
||||
Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles);
|
||||
|
||||
@NotNull
|
||||
Collection<IFile> getStorageFilesToSave() throws StateStorageException;
|
||||
|
||||
@NotNull
|
||||
List<IFile> getAllStorageFiles();
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
void storageFileChanged(final VirtualFileEvent event, final StateStorage storage);
|
||||
interface Listener {
|
||||
void storageFileChanged(@NotNull VirtualFileEvent event, @NotNull StateStorage storage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ public class MockProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reinitComponents(Set<String> componentNames, boolean reloadData) {
|
||||
public void reinitComponents(@NotNull Set<String> componentNames, boolean reloadData) {
|
||||
throw new UnsupportedOperationException("Method reinitComponents is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReloadPossible(Set<String> componentNames) {
|
||||
public boolean isReloadPossible(@NotNull Set<String> componentNames) {
|
||||
throw new UnsupportedOperationException("Method isReloadPossible is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class MockProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProjectFromTemplate(ProjectImpl project) {
|
||||
public void loadProjectFromTemplate(@NotNull ProjectImpl project) {
|
||||
throw new UnsupportedOperationException("Method loadProjectFromTemplate is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class MockProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent(Object component, final boolean service) {
|
||||
public void initComponent(@NotNull Object component, final boolean service) {
|
||||
throw new UnsupportedOperationException("Method initComponent is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@@ -152,10 +152,11 @@ public class MockProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reload(final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
|
||||
public boolean reload(@NotNull final Set<Pair<VirtualFile,StateStorage>> changedFiles) {
|
||||
throw new UnsupportedOperationException("Method reload not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StateStorageManager getStateStorageManager() {
|
||||
throw new UnsupportedOperationException("Method getStateStorageManager not implemented in " + getClass());
|
||||
|
||||
@@ -170,15 +170,18 @@ public class PathManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getConfigPath(boolean createIfNotExists) {
|
||||
ensureConfigFolderExists(createIfNotExists);
|
||||
return ourConfigPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getConfigPath() {
|
||||
return getConfigPath(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getConfigPathWithoutDialog() {
|
||||
if (ourConfigPath != null) return ourConfigPath;
|
||||
|
||||
@@ -197,6 +200,7 @@ public class PathManager {
|
||||
return ourConfigPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getDefaultConfigPathFor(String selector) {
|
||||
return SystemProperties.getUserHome() + (SystemInfo.isMac ? "/Library/Preferences/" + selector
|
||||
: File.separator + "." + selector + File.separator + "config");
|
||||
@@ -279,6 +283,7 @@ public class PathManager {
|
||||
return ourLogPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getAbsolutePath(String path) {
|
||||
if (path.startsWith("~/") || path.startsWith("~\\")) {
|
||||
path = SystemProperties.getUserHome() + path.substring(1);
|
||||
|
||||
Reference in New Issue
Block a user