state store in kotlin
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Thu, 23 Jul 2015 07:55:38 +0000 (09:55 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Thu, 23 Jul 2015 14:56:18 +0000 (16:56 +0200)
28 files changed:
platform/configuration-store-impl/src/PlatformLangProjectStoreClassProvider.kt [moved from platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/PlatformLangProjectStoreClassProvider.java with 59% similarity]
platform/configuration-store-impl/src/PlatformProjectStoreClassProvider.kt [moved from platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/PlatformProjectStoreClassProvider.java with 59% similarity]
platform/configuration-store-impl/src/SchemeManagerImpl.kt
platform/configuration-store-impl/src/com/intellij/configurationStore/DefaultProjectStorage.java [new file with mode: 0644]
platform/configuration-store-impl/src/com/intellij/configurationStore/DefaultStorageAnnotation.java [new file with mode: 0644]
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/ApplicationPathMacroManager.java [deleted file]
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ApplicationStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/BaseFileConfigurableStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/DefaultProjectStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleFileData.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleStateStorageManager.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ProjectStateStorageManager.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ProjectWithModulesStoreImpl.java
platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java
platform/configuration-store-impl/testSrc/ApplicationStoreTest.kt
platform/configuration-store-impl/testSrc/com/intellij/openapi/components/impl/StateStorageManagerImplTest.java [deleted file]
platform/configuration-store-impl/testSrc/com/intellij/openapi/components/impl/StateStorageManagerImplTest.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
platform/platform-resources/src/META-INF/LangExtensions.xml
platform/platform-resources/src/META-INF/PlatformExtensions.xml
platform/platform-resources/src/componentSets/PlatformComponents.xml
platform/platform-resources/src/componentSets/PlatformLangComponents.xml
platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/StorageData.java
plugins/settings-repository/src/sync.kt
resources/src/componentSets/IdeaComponents.xml

similarity index 59%
rename from platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/PlatformLangProjectStoreClassProvider.java
rename to platform/configuration-store-impl/src/PlatformLangProjectStoreClassProvider.kt
index 5655f526dba883f5405c921b8e06b70ba0532c0a..af3a35a5730205ce2d0b3b951251ffb050125cad 100644 (file)
  * limitations under the License.
  */
 
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.project.impl.ProjectStoreClassProvider;
-import org.jetbrains.annotations.NotNull;
+import com.intellij.openapi.components.impl.stores.DefaultProjectStoreImpl
+import com.intellij.openapi.components.impl.stores.IComponentStore
+import com.intellij.openapi.project.impl.ProjectStoreClassProvider
 
 /**
  * @author yole
  */
-class PlatformLangProjectStoreClassProvider implements ProjectStoreClassProvider {
-  @NotNull
-  @Override
-  public Class<? extends IComponentStore> getProjectStoreClass(final boolean isDefaultProject) {
-    return isDefaultProject ? DefaultProjectStoreImpl.class : ProjectWithModulesStoreImpl.class;
+class PlatformLangProjectStoreClassProvider : ProjectStoreClassProvider {
+  override fun getProjectStoreClass(isDefaultProject: Boolean): Class<out IComponentStore> {
+    return if (isDefaultProject) javaClass<DefaultProjectStoreImpl>() else javaClass<ProjectWithModulesStoreImpl>()
   }
 }
similarity index 59%
rename from platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/PlatformProjectStoreClassProvider.java
rename to platform/configuration-store-impl/src/PlatformProjectStoreClassProvider.kt
index b98bf9eccfd22c7f50efbe063da93e5380242a29..7005ebbd814aba458e3a7d1f4ccc49b420e07a94 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.project.impl.ProjectStoreClassProvider;
-import org.jetbrains.annotations.NotNull;
+import com.intellij.openapi.components.impl.stores.DefaultProjectStoreImpl
+import com.intellij.openapi.components.impl.stores.IComponentStore
+import com.intellij.openapi.project.impl.ProjectStoreClassProvider
 
-public class PlatformProjectStoreClassProvider implements ProjectStoreClassProvider {
-  @NotNull
-  public Class<? extends IComponentStore> getProjectStoreClass(boolean isDefaultProject) {
-    return isDefaultProject ? DefaultProjectStoreImpl.class : ProjectStoreImpl.class;
+class PlatformProjectStoreClassProvider : ProjectStoreClassProvider {
+  override fun getProjectStoreClass(isDefaultProject: Boolean): Class<out IComponentStore> {
+    return if (isDefaultProject) javaClass<DefaultProjectStoreImpl>() else javaClass<ProjectStoreImpl>()
   }
 }
\ No newline at end of file
index 8a9559ad203d0f7bfa4a0b6cd72d87b182b7f661..596676415a9078c7da25bdd96db3c23ca61fc53b 100644 (file)
@@ -26,7 +26,6 @@ import com.intellij.openapi.components.impl.stores.DirectoryStorageData
 import com.intellij.openapi.components.impl.stores.StorageUtil
 import com.intellij.openapi.components.impl.stores.StreamProvider
 import com.intellij.openapi.components.service
-import com.intellij.openapi.diagnostic.Logger
 import com.intellij.openapi.extensions.AbstractExtensionPointBean
 import com.intellij.openapi.options.*
 import com.intellij.openapi.util.Comparing
@@ -54,8 +53,6 @@ import java.io.InputStream
 import java.util.ArrayList
 import java.util.Collections
 
-private val LOG = Logger.getInstance(javaClass<SchemeManagerImpl<*, *>>())
-
 public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val fileSpec: String,
                                                                      private val processor: SchemeProcessor<E>,
                                                                      private val roamingType: RoamingType,
diff --git a/platform/configuration-store-impl/src/com/intellij/configurationStore/DefaultProjectStorage.java b/platform/configuration-store-impl/src/com/intellij/configurationStore/DefaultProjectStorage.java
new file mode 100644 (file)
index 0000000..d3d0fc3
--- /dev/null
@@ -0,0 +1,55 @@
+package com.intellij.configurationStore;
+
+import com.intellij.openapi.components.PathMacroManager;
+import com.intellij.openapi.components.RoamingType;
+import com.intellij.openapi.components.impl.stores.DefaultProjectStoreImpl;
+import com.intellij.openapi.components.impl.stores.StorageData;
+import com.intellij.openapi.components.impl.stores.XmlElementStorage;
+import com.intellij.openapi.project.impl.ProjectManagerImpl;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class DefaultProjectStorage extends XmlElementStorage {
+  private final DefaultProjectStoreImpl store;
+  private final ProjectManagerImpl projectManager;
+
+  public DefaultProjectStorage(DefaultProjectStoreImpl store, PathMacroManager pathMacroManager, ProjectManagerImpl projectManager) {
+    super("", RoamingType.DISABLED, pathMacroManager.createTrackingSubstitutor(), "defaultProject", null);
+
+    this.store = store;
+    this.projectManager = projectManager;
+  }
+
+  @Override
+  @Nullable
+  protected Element loadLocalData() {
+    return store.getStateCopy();
+  }
+
+  @NotNull
+  @Override
+  protected XmlElementStorageSaveSession createSaveSession(@NotNull StorageData storageData) {
+    return new XmlElementStorageSaveSession(storageData) {
+      @Override
+      protected void doSave(@Nullable Element element) {
+        // we must set empty element instead of null as indicator - ProjectManager state is ready to save
+        projectManager.setDefaultProjectRootElement(element == null ? new Element("empty") : element);
+      }
+
+      // we must not collapse paths here, because our solution is just a big hack
+      // by default, getElementToSave() returns collapsed paths -> setDefaultProjectRootElement -> project manager writeExternal -> save -> compare old and new - diff because old has expanded, but new collapsed
+      // -> needless save
+      @Override
+      protected boolean isCollapsePathsOnSave() {
+        return false;
+      }
+    };
+  }
+
+  @Override
+  @NotNull
+  protected StorageData createStorageData() {
+    return new BaseFileConfigurableStoreImpl.BaseStorageData(myRootElementName);
+  }
+}
diff --git a/platform/configuration-store-impl/src/com/intellij/configurationStore/DefaultStorageAnnotation.java b/platform/configuration-store-impl/src/com/intellij/configurationStore/DefaultStorageAnnotation.java
new file mode 100644 (file)
index 0000000..b9b89f4
--- /dev/null
@@ -0,0 +1,55 @@
+package com.intellij.configurationStore;
+
+import com.intellij.openapi.components.*;
+import org.jetbrains.annotations.NotNull;
+
+import java.lang.annotation.Annotation;
+
+@SuppressWarnings("ClassExplicitlyAnnotation")
+public final class DefaultStorageAnnotation implements Storage {
+  @Override
+  public String id() {
+    return "___Default___";
+  }
+
+  @Override
+  public boolean isDefault() {
+    return true;
+  }
+
+  @Override
+  public String file() {
+    return StoragePathMacros.PROJECT_FILE;
+  }
+
+  @Override
+  public StorageScheme scheme() {
+    return StorageScheme.DEFAULT;
+  }
+
+  @Override
+  public boolean deprecated() {
+    return true;
+  }
+
+  @Override
+  public RoamingType roamingType() {
+    return RoamingType.PER_USER;
+  }
+
+  @Override
+  public Class<? extends StateStorage> storageClass() {
+    return StateStorage.class;
+  }
+
+  @Override
+  public Class<StateSplitterEx> stateSplitter() {
+    return StateSplitterEx.class;
+  }
+
+  @NotNull
+  @Override
+  public Class<? extends Annotation> annotationType() {
+    throw new UnsupportedOperationException("Method annotationType not implemented in " + getClass());
+  }
+}
\ No newline at end of file
diff --git a/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/ApplicationPathMacroManager.java b/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/ApplicationPathMacroManager.java
deleted file mode 100644 (file)
index 1a93f02..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.components.impl;
-
-/**
- * @author mike
- */
-public class ApplicationPathMacroManager extends BasePathMacroManager {
-  public ApplicationPathMacroManager() {
-    super(null);
-  }
-}
index 0c23e2e774c415869e6144039064133bbf9638f0..9e3d9328ce3b47b233b7d5dc4ab0eafe79da0dd5 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-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.*;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.NamedJDOMExternalizable;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VfsUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.messages.MessageBus;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-class ApplicationStoreImpl extends ComponentStoreImpl {
-  private static final Logger LOG = Logger.getInstance(ApplicationStoreImpl.class);
-
-  private static final String DEFAULT_STORAGE_SPEC = StoragePathMacros.APP_CONFIG + "/" + PathManager.DEFAULT_OPTIONS_FILE_NAME + DirectoryStorageData.DEFAULT_EXT;
-  private static final String ROOT_ELEMENT_NAME = "application";
-
-  private final ApplicationImpl myApplication;
-  private final StateStorageManager myStateStorageManager;
-
-  public ApplicationStoreImpl(@NotNull ApplicationImpl application, @NotNull PathMacroManager pathMacroManager) {
-    myApplication = application;
-    myStateStorageManager = new StateStorageManagerImpl(pathMacroManager.createTrackingSubstitutor(), ROOT_ELEMENT_NAME, application, application.getPicoContainer()) {
-      private boolean myConfigDirectoryRefreshed;
-
-      @Nullable
-      protected StateStorage.Listener createStorageTopicListener() {
-        return myApplication.getMessageBus().syncPublisher(StateStorage.STORAGE_TOPIC);
+package com.intellij.configurationStore
+
+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.StoragePathMacros
+import com.intellij.openapi.components.impl.BasePathMacroManager
+import com.intellij.openapi.components.impl.stores.DirectoryStorageData
+import com.intellij.openapi.components.impl.stores.StateStorageManager
+import com.intellij.openapi.components.impl.stores.StorageData
+import com.intellij.openapi.diagnostic.Logger
+import com.intellij.openapi.util.NamedJDOMExternalizable
+import com.intellij.openapi.vfs.LocalFileSystem
+import com.intellij.openapi.vfs.VfsUtil
+import com.intellij.util.messages.MessageBus
+
+public class ApplicationPathMacroManager : BasePathMacroManager(null)
+
+class ApplicationStoreImpl(private val myApplication: ApplicationImpl, pathMacroManager: PathMacroManager) : ComponentStoreImpl() {
+  private val myStateStorageManager: StateStorageManager
+
+  init {
+    myStateStorageManager = object : StateStorageManagerImpl(pathMacroManager.createTrackingSubstitutor(), ROOT_ELEMENT_NAME, myApplication, myApplication.getPicoContainer()) {
+      private var myConfigDirectoryRefreshed: Boolean = false
+
+      override fun createStorageTopicListener(): StateStorage.Listener? {
+        return myApplication.getMessageBus().syncPublisher(StateStorage.STORAGE_TOPIC)
       }
 
-      @NotNull
-      @Override
-      protected StorageData createStorageData(@NotNull String fileSpec, @NotNull String filePath) {
-        return new StorageData(ROOT_ELEMENT_NAME);
+      override fun createStorageData(fileSpec: String, filePath: String): StorageData {
+        return StorageData(ROOT_ELEMENT_NAME)
       }
 
-      @Nullable
-      @Override
-      protected String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) {
-        if (component instanceof NamedJDOMExternalizable) {
-          return StoragePathMacros.APP_CONFIG + '/' + ((NamedJDOMExternalizable)component).getExternalFileName() + DirectoryStorageData.DEFAULT_EXT;
+      override fun getOldStorageSpec(component: Any, componentName: String, operation: StateStorageOperation): String? {
+        if (component is NamedJDOMExternalizable) {
+          return StoragePathMacros.APP_CONFIG + '/' + component.getExternalFileName() + DirectoryStorageData.DEFAULT_EXT
         }
         else {
-          return DEFAULT_STORAGE_SPEC;
+          return DEFAULT_STORAGE_SPEC
         }
       }
 
-      @Override
-      protected TrackingPathMacroSubstitutor getMacroSubstitutor(@NotNull String fileSpec) {
-        return fileSpec.equals(StoragePathMacros.APP_CONFIG + '/' + PathMacrosImpl.EXT_FILE_NAME + DirectoryStorageData.DEFAULT_EXT) ? null : super.getMacroSubstitutor(fileSpec);
-      }
+      override fun getMacroSubstitutor(fileSpec: String) = if (fileSpec == StoragePathMacros.APP_CONFIG + '/' + PathMacrosImpl.EXT_FILE_NAME + DirectoryStorageData.DEFAULT_EXT) null else super.getMacroSubstitutor(fileSpec)
 
-      @Override
-      protected boolean isUseXmlProlog() {
-        return false;
-      }
+      override fun isUseXmlProlog() = false
 
-      @Override
-      protected void beforeFileBasedStorageCreate() {
+      override fun beforeFileBasedStorageCreate() {
         if (myConfigDirectoryRefreshed || (!myApplication.isUnitTestMode() && !myApplication.isDispatchThread())) {
-          return;
+          return
         }
 
         try {
-          String configPath = getMacrosValue(StoragePathMacros.ROOT_CONFIG);
+          val configPath = getMacrosValue(StoragePathMacros.ROOT_CONFIG)
           if (configPath == null) {
-            LOG.warn("Macros ROOT_CONFIG is not defined");
-            return;
+            LOG.warn("Macros ROOT_CONFIG is not defined")
+            return
           }
 
-          VirtualFile configDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(configPath);
+          val configDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(configPath)
           if (configDir != null) {
-            VfsUtil.markDirtyAndRefresh(false, true, true, configDir);
+            VfsUtil.markDirtyAndRefresh(false, true, true, configDir)
           }
         }
         finally {
-          myConfigDirectoryRefreshed = true;
+          myConfigDirectoryRefreshed = true
         }
       }
-    };
+    }
   }
 
-  @Override
-  @NotNull
-  protected MessageBus getMessageBus() {
-    return myApplication.getMessageBus();
+  override fun getMessageBus(): MessageBus {
+    return myApplication.getMessageBus()
   }
 
-  @NotNull
-  @Override
-  public StateStorageManager getStateStorageManager() {
-    return myStateStorageManager;
+  override fun getStateStorageManager(): StateStorageManager {
+    return myStateStorageManager
+  }
+
+  companion object {
+    private val LOG = Logger.getInstance(javaClass<ApplicationStoreImpl>())
+
+    private val DEFAULT_STORAGE_SPEC = StoragePathMacros.APP_CONFIG + "/" + PathManager.DEFAULT_OPTIONS_FILE_NAME + DirectoryStorageData.DEFAULT_EXT
+    private val ROOT_ELEMENT_NAME = "application"
   }
 }
index 26aa6c54eb4c1f0b0c42c08427ddb96d757019dd..a90f11c5a4c815e829858258eb640c0251f7cff0 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.components.PathMacroManager;
-import com.intellij.openapi.components.PathMacroSubstitutor;
-import com.intellij.openapi.project.impl.ProjectManagerImpl;
-import com.intellij.util.SmartList;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.openapi.components.PathMacroManager
+import com.intellij.openapi.components.PathMacroSubstitutor
+import com.intellij.openapi.components.impl.stores.StateStorageManager
+import com.intellij.openapi.components.impl.stores.StorageData
+import com.intellij.openapi.project.impl.ProjectManagerImpl
+import org.jdom.Element
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+val VERSION_OPTION: String = "version"
 
-abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl {
-  @NonNls protected static final String VERSION_OPTION = "version";
-  @NonNls public static final String ATTRIBUTE_NAME = "name";
+abstract class BaseFileConfigurableStoreImpl(protected val myPathMacroManager: PathMacroManager) : ComponentStoreImpl() {
+  private var myStateStorageManager: StateStorageManager? = null
 
-  private static final List<String> ourConversionProblemsStorage = new SmartList<String>();
+  public open class BaseStorageData : StorageData {
+    private var myVersion = ProjectManagerImpl.CURRENT_FORMAT_VERSION
 
-  private StateStorageManager myStateStorageManager;
-  protected final PathMacroManager myPathMacroManager;
-
-  protected BaseFileConfigurableStoreImpl(@NotNull PathMacroManager pathMacroManager) {
-    myPathMacroManager = pathMacroManager;
-  }
-
-  protected static class BaseStorageData extends StorageData {
-    private int myVersion = ProjectManagerImpl.CURRENT_FORMAT_VERSION;
-
-    public BaseStorageData(@NotNull String rootElementName) {
-      super(rootElementName);
+    public constructor(rootElementName: String) : super(rootElementName) {
     }
 
-    protected BaseStorageData(BaseStorageData storageData) {
-      super(storageData);
+    protected constructor(storageData: BaseStorageData) : super(storageData) {
     }
 
-    @Override
-    public void load(@NotNull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
-      super.load(rootElement, pathMacroSubstitutor, intern);
+    override fun load(rootElement: Element, pathMacroSubstitutor: PathMacroSubstitutor?, intern: Boolean) {
+      super.load(rootElement, pathMacroSubstitutor, intern)
 
-      String v = rootElement.getAttributeValue(VERSION_OPTION);
-      myVersion = v == null ? ProjectManagerImpl.CURRENT_FORMAT_VERSION : Integer.parseInt(v);
+      val v = rootElement.getAttributeValue(VERSION_OPTION)
+      myVersion = if (v == null) ProjectManagerImpl.CURRENT_FORMAT_VERSION else Integer.parseInt(v)
     }
 
-    @Override
-    @NotNull
-    protected final Element save(@NotNull Map<String, Element> newLiveStates) {
-      Element root = super.save(newLiveStates);
+    override fun save(newLiveStates: Map<String, Element>): Element {
+      var root = super.save(newLiveStates)
       if (root == null) {
-        root = new Element(myRootElementName);
+        root = Element(myRootElementName)
       }
-      writeOptions(root, Integer.toString(myVersion));
-      return root;
+      writeOptions(root, Integer.toString(myVersion))
+      return root
     }
 
-    protected void writeOptions(@NotNull Element root, @NotNull String versionString) {
-      root.setAttribute(VERSION_OPTION, versionString);
+    protected open fun writeOptions(root: Element, versionString: String) {
+      root.setAttribute(VERSION_OPTION, versionString)
     }
 
-    @Override
-    public StorageData clone() {
-      return new BaseStorageData(this);
+    override fun clone(): StorageData {
+      return BaseStorageData(this)
     }
 
-    @Nullable
-    @Override
-    public Set<String> getChangedComponentNames(@NotNull StorageData newStorageData, @Nullable PathMacroSubstitutor substitutor) {
-      BaseStorageData data = (BaseStorageData)newStorageData;
+    override fun getChangedComponentNames(newStorageData: StorageData, substitutor: PathMacroSubstitutor?): Set<String>? {
+      val data = newStorageData as BaseStorageData
       if (myVersion != data.myVersion) {
-        return null;
+        return null
       }
-      return super.getChangedComponentNames(newStorageData, substitutor);
+      return super.getChangedComponentNames(newStorageData, substitutor)
     }
   }
 
-  @Nullable
-  static List<String> getConversionProblemsStorage() {
-    return ourConversionProblemsStorage;
-  }
-
-  @NotNull
-  @Override
-  protected final PathMacroManager getPathMacroManagerForDefaults() {
-    return myPathMacroManager;
+  override fun getPathMacroManagerForDefaults(): PathMacroManager {
+    return myPathMacroManager
   }
 
-  @NotNull
-  @Override
-  public final StateStorageManager getStateStorageManager() {
+  override fun getStateStorageManager(): StateStorageManager {
     if (myStateStorageManager == null) {
-      myStateStorageManager = createStateStorageManager();
+      myStateStorageManager = createStateStorageManager()
     }
-    return myStateStorageManager;
+    return myStateStorageManager!!
   }
 
-  @NotNull
-  protected abstract StateStorageManager createStateStorageManager();
+  protected abstract fun createStateStorageManager(): StateStorageManager
 }
index 7a43c36265c9b32faae91fb3b48b9725145c283e..fe1fed51ffc04e0399773c73b9b95c2bfe8e28a1 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
-
-import com.intellij.openapi.application.*;
-import com.intellij.openapi.application.ex.DecodeDefaultsUtil;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.StateStorage.SaveSession;
-import com.intellij.openapi.components.StateStorageChooserEx.Resolution;
-import com.intellij.openapi.components.impl.ComponentManagerImpl;
-import com.intellij.openapi.components.impl.stores.StateStorageManager.ExternalizationSession;
-import com.intellij.openapi.components.store.ReadOnlyModificationException;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
-import com.intellij.util.ArrayUtilRt;
-import com.intellij.util.ReflectionUtil;
-import com.intellij.util.SmartList;
-import com.intellij.util.containers.MultiMap;
-import com.intellij.util.containers.SmartHashSet;
-import com.intellij.util.lang.CompoundRuntimeException;
-import com.intellij.util.messages.MessageBus;
-import com.intellij.util.xmlb.JDOMXIncluder;
-import gnu.trove.THashMap;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.TestOnly;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-@SuppressWarnings({"deprecation"})
-public abstract class ComponentStoreImpl implements IComponentStore {
-  private static final Logger LOG = Logger.getInstance(ComponentStoreImpl.class);
-  private final Map<String, Object> myComponents = Collections.synchronizedMap(new THashMap<String, Object>());
-  private final List<SettingsSavingComponent> mySettingsSavingComponents = new CopyOnWriteArrayList<SettingsSavingComponent>();
-
-  @Override
-  public void initComponent(@NotNull Object component, boolean service) {
-    if (component instanceof SettingsSavingComponent) {
-      mySettingsSavingComponents.add((SettingsSavingComponent)component);
-    }
-
-    if (!(component instanceof JDOMExternalizable || component instanceof PersistentStateComponent)) {
-      return;
-    }
-
-    AccessToken token = ReadAction.start();
+package com.intellij.configurationStore
+
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.application.PathManager
+import com.intellij.openapi.application.ReadAction
+import com.intellij.openapi.application.WriteAction
+import com.intellij.openapi.application.ex.DecodeDefaultsUtil
+import com.intellij.openapi.components.*
+import com.intellij.openapi.components.StateStorage.SaveSession
+import com.intellij.openapi.components.StateStorageChooserEx.Resolution
+import com.intellij.openapi.components.impl.ComponentManagerImpl
+import com.intellij.openapi.components.impl.stores.*
+import com.intellij.openapi.components.impl.stores.StateStorageManager.ExternalizationSession
+import com.intellij.openapi.components.store.ReadOnlyModificationException
+import com.intellij.openapi.diagnostic.Logger
+import com.intellij.openapi.progress.ProcessCanceledException
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.util
+import com.intellij.openapi.util.*
+import com.intellij.openapi.util.Pair
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
+import com.intellij.util.ArrayUtilRt
+import com.intellij.util.ReflectionUtil
+import com.intellij.util.SmartList
+import com.intellij.util.containers.MultiMap
+import com.intellij.util.containers.SmartHashSet
+import com.intellij.util.lang.CompoundRuntimeException
+import com.intellij.util.messages.MessageBus
+import com.intellij.util.xmlb.JDOMXIncluder
+import gnu.trove.THashMap
+import org.jdom.Element
+import org.jdom.JDOMException
+import org.jetbrains.annotations.TestOnly
+import java.io.File
+import java.io.IOException
+import java.util.Arrays
+import java.util.Collections
+import java.util.Comparator
+import java.util.LinkedHashSet
+import java.util.concurrent.CopyOnWriteArrayList
+import kotlin.reflect.jvm.java
+
+private val LOG = Logger.getInstance(javaClass<ComponentStoreImpl>())
+
+public abstract class ComponentStoreImpl : IComponentStore {
+  private val myComponents = Collections.synchronizedMap(THashMap<String, Any>())
+  private val mySettingsSavingComponents = CopyOnWriteArrayList<SettingsSavingComponent>()
+
+  override fun initComponent(component: Any, service: Boolean) {
+    if (component is SettingsSavingComponent) {
+      mySettingsSavingComponents.add(component)
+    }
+
+    if (!(component is JDOMExternalizable || component is PersistentStateComponent<*>)) {
+      return
+    }
+
+    val token = ReadAction.start()
     try {
-      String componentNameIfStateExists;
-      if (component instanceof PersistentStateComponent) {
-        componentNameIfStateExists = initPersistentComponent((PersistentStateComponent<?>)component, null, false);
+      val componentNameIfStateExists: String?
+      if (component is PersistentStateComponent<*>) {
+        componentNameIfStateExists = initPersistentComponent(component, null, false)
       }
       else {
-        componentNameIfStateExists = initJdomExternalizable((JDOMExternalizable)component);
+        componentNameIfStateExists = initJdomExternalizable(component as JDOMExternalizable)
       }
 
       // if not service, so, component manager will check it later for all components
       if (componentNameIfStateExists != null && service) {
-        Project project = getProject();
-        Application app = ApplicationManager.getApplication();
+        val project = getProject()
+        val app = ApplicationManager.getApplication()
         if (project != null && !app.isHeadlessEnvironment() && !app.isUnitTestMode() && project.isInitialized()) {
-          TrackingPathMacroSubstitutor substitutor = getStateStorageManager().getMacroSubstitutor();
+          val substitutor = getStateStorageManager().getMacroSubstitutor()
           if (substitutor != null) {
-            StorageUtil.notifyUnknownMacros(substitutor, project, componentNameIfStateExists);
+            StorageUtil.notifyUnknownMacros(substitutor, project, componentNameIfStateExists)
           }
         }
       }
     }
-    catch (StateStorageException e) {
-      throw e;
+    catch (e: StateStorageException) {
+      throw e
     }
-    catch (ProcessCanceledException e) {
-      throw e;
+    catch (e: ProcessCanceledException) {
+      throw e
     }
-    catch (Exception e) {
-      LOG.error(e);
+    catch (e: Exception) {
+      LOG.error(e)
     }
     finally {
-      token.finish();
+      token.finish()
     }
   }
 
-  @Override
-  public final void save(@NotNull List<Pair<StateStorage.SaveSession, VirtualFile>> readonlyFiles) {
-    ExternalizationSession externalizationSession = myComponents.isEmpty() ? null : getStateStorageManager().startExternalization();
+  override fun save(readonlyFiles: MutableList<util.Pair<StateStorage.SaveSession, VirtualFile>>) {
+    val externalizationSession = if (myComponents.isEmpty()) null else getStateStorageManager().startExternalization()
     if (externalizationSession != null) {
-      String[] names = ArrayUtilRt.toStringArray(myComponents.keySet());
-      Arrays.sort(names);
-      for (String name : names) {
-        commitComponent(externalizationSession, myComponents.get(name), name);
+      val names = ArrayUtilRt.toStringArray(myComponents.keySet())
+      Arrays.sort(names)
+      for (name in names) {
+        commitComponent(externalizationSession, myComponents.get(name)!!, name)
       }
     }
 
-    List<Throwable> errors = null;
-    for (SettingsSavingComponent settingsSavingComponent : mySettingsSavingComponents) {
+    var errors: MutableList<Throwable>? = null
+    for (settingsSavingComponent in mySettingsSavingComponents) {
       try {
-        settingsSavingComponent.save();
+        settingsSavingComponent.save()
       }
-      catch (Throwable e) {
+      catch (e: Throwable) {
         if (errors == null) {
-          errors = new SmartList<Throwable>();
+          errors = SmartList<Throwable>()
         }
-        errors.add(e);
+        errors.add(e)
       }
+
     }
 
-    errors = doSave(externalizationSession == null ? null : externalizationSession.createSaveSessions(), readonlyFiles, errors);
-    CompoundRuntimeException.doThrow(errors);
+    errors = doSave(externalizationSession?.createSaveSessions(), readonlyFiles, errors)
+    CompoundRuntimeException.doThrow(errors)
   }
 
-  @TestOnly
-  @Override
-  public void saveApplicationComponent(@NotNull Object component) {
-    StateStorageManager.ExternalizationSession externalizationSession = getStateStorageManager().startExternalization();
-    if (externalizationSession == null) {
-      return;
-    }
+  TestOnly
+  override fun saveApplicationComponent(component: Any) {
+    val externalizationSession = getStateStorageManager().startExternalization() ?: return
 
-    commitComponent(externalizationSession, component, null);
-    List<SaveSession> sessions = externalizationSession.createSaveSessions();
+    commitComponent(externalizationSession, component, null)
+    val sessions = externalizationSession.createSaveSessions()
     if (sessions.isEmpty()) {
-      return;
+      return
     }
 
-    final File file;
-    State state = StoreUtil.getStateSpec(component.getClass());
+    val file: File
+    val state = StoreUtil.getStateSpec(component.javaClass)
     if (state != null) {
-      file = new File(getStateStorageManager().expandMacros(findNonDeprecated(state.storages()).file()));
+      file = File(getStateStorageManager().expandMacros(findNonDeprecated(state.storages).file))
     }
-    else if (component instanceof ExportableApplicationComponent && component instanceof NamedJDOMExternalizable) {
-      file = PathManager.getOptionsFile((NamedJDOMExternalizable)component);
+    else if (component is ExportableApplicationComponent && component is NamedJDOMExternalizable) {
+      file = PathManager.getOptionsFile(component)
     }
     else {
-      throw new AssertionError(component.getClass() + " doesn't have @State annotation and doesn't implement ExportableApplicationComponent");
+      throw AssertionError("${component.javaClass} doesn't have @State annotation and doesn't implement ExportableApplicationComponent")
     }
 
-    AccessToken token = WriteAction.start();
+    val token = WriteAction.start()
     try {
-      VfsRootAccess.allowRootAccess(file.getAbsolutePath());
-      CompoundRuntimeException.doThrow(doSave(sessions, Collections.<Pair<SaveSession, VirtualFile>>emptyList(), null));
+      VfsRootAccess.allowRootAccess(file.getAbsolutePath())
+      CompoundRuntimeException.doThrow(doSave(sessions, arrayListOf(), null))
     }
     finally {
       try {
-        VfsRootAccess.disallowRootAccess(file.getAbsolutePath());
+        VfsRootAccess.disallowRootAccess(file.getAbsolutePath())
       }
       finally {
-        token.finish();
-      }
-    }
-  }
-
-  private static Storage findNonDeprecated(Storage[] storages) {
-    for (Storage storage : storages) {
-      if (!storage.deprecated()) {
-        return storage;
+        token.finish()
       }
     }
-    throw new AssertionError("All storages are deprecated");
   }
 
-  private void commitComponent(@NotNull ExternalizationSession externalizationSession, @NotNull Object component, @Nullable String componentName) {
-    if (component instanceof PersistentStateComponent) {
-      commitPersistentComponent((PersistentStateComponent<?>)component, externalizationSession, componentName);
+  private fun commitComponent(externalizationSession: ExternalizationSession, component: Any, componentName: String?) {
+    if (component is PersistentStateComponent<*>) {
+      commitPersistentComponent(component, externalizationSession, componentName)
     }
-    else if (component instanceof JDOMExternalizable) {
-      externalizationSession.setStateInOldStorage(component, componentName == null ? ComponentManagerImpl.getComponentName(component) : componentName, component);
+    else if (component is JDOMExternalizable) {
+      externalizationSession.setStateInOldStorage(component, componentName ?: ComponentManagerImpl.getComponentName(component), component)
     }
   }
 
-  @Nullable
-  protected List<Throwable> doSave(@Nullable List<SaveSession> saveSessions, @NotNull List<Pair<SaveSession, VirtualFile>> readonlyFiles, @Nullable List<Throwable> errors) {
+  protected open fun doSave(saveSessions: List<SaveSession>?, readonlyFiles: MutableList<Pair<SaveSession, VirtualFile>>, prevErrors: MutableList<Throwable>?): MutableList<Throwable>? {
+    var errors = prevErrors
     if (saveSessions != null) {
-      for (SaveSession session : saveSessions) {
-        errors = executeSave(session, readonlyFiles, errors);
-      }
-    }
-    return errors;
-  }
-
-  @Nullable
-  protected static List<Throwable> executeSave(@NotNull SaveSession session, @NotNull List<Pair<SaveSession, VirtualFile>> readonlyFiles, @Nullable List<Throwable> errors) {
-    try {
-      session.save();
-    }
-    catch (ReadOnlyModificationException e) {
-      LOG.warn(e);
-      readonlyFiles.add(Pair.create(e.getSession() == null ? session : e.getSession(), e.getFile()));
-    }
-    catch (Exception e) {
-      if (errors == null) {
-        errors = new SmartList<Throwable>();
+      for (session in saveSessions) {
+        errors = executeSave(session, readonlyFiles, prevErrors)
       }
-      errors.add(e);
     }
-    return errors;
+    return errors
   }
 
-  private <T> void commitPersistentComponent(@NotNull PersistentStateComponent<T> component, @NotNull ExternalizationSession session, @Nullable String componentName) {
-    T state = component.getState();
+  private fun <T> commitPersistentComponent(component: PersistentStateComponent<T>, session: ExternalizationSession, componentName: String?) {
+    val state = component.getState()
     if (state != null) {
-      Storage[] storageSpecs = getComponentStorageSpecs(component, StoreUtil.getStateSpec(component), StateStorageOperation.WRITE);
-      session.setState(storageSpecs, component, componentName == null ? StoreUtil.getComponentName(component) : componentName, state);
+      val storageSpecs = getComponentStorageSpecs(component, StoreUtil.getStateSpec(component), StateStorageOperation.WRITE)
+      session.setState(storageSpecs, component, componentName ?: StoreUtil.getComponentName(component), state)
     }
   }
 
-  @Nullable
-  private String initJdomExternalizable(@NotNull JDOMExternalizable component) {
-    String componentName = ComponentManagerImpl.getComponentName(component);
-    doAddComponent(componentName, component);
+  private fun initJdomExternalizable(component: JDOMExternalizable): String? {
+    val componentName = ComponentManagerImpl.getComponentName(component)
+    doAddComponent(componentName, component)
 
     if (optimizeTestLoading()) {
-      return null;
-    }
-
-    loadJdomDefaults(component, componentName);
-
-    StateStorage stateStorage = getStateStorageManager().getOldStorage(component, componentName, StateStorageOperation.READ);
-    if (stateStorage == null) {
-      return null;
+      return null
     }
 
-    Element element = stateStorage.getState(component, componentName, Element.class, null);
-    if (element == null) {
-      return null;
-    }
+    loadJdomDefaults(component, componentName)
 
+    val stateStorage = getStateStorageManager().getOldStorage(component, componentName, StateStorageOperation.READ) ?: return null
+    val element = stateStorage.getState<Element>(component, componentName, javaClass<Element>(), null) ?: return null
     try {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Loading configuration for " + component.getClass());
+        LOG.debug("Loading configuration for " + component.javaClass)
       }
-      component.readExternal(element);
+      component.readExternal(element)
     }
-    catch (InvalidDataException e) {
-      LOG.error(e);
-      return null;
+    catch (e: InvalidDataException) {
+      LOG.error(e)
+      return null
     }
 
-    return componentName;
+
+    return componentName
   }
 
-  private void doAddComponent(String componentName, Object component) {
-    Object existing = myComponents.get(componentName);
-    if (existing != null && existing != component) {
-      LOG.error("Conflicting component name '" + componentName + "': " + existing.getClass() + " and " + component.getClass());
+  private fun doAddComponent(componentName: String, component: Any) {
+    val existing = myComponents.get(componentName)
+    if (existing != null && existing !== component) {
+      LOG.error("Conflicting component name '" + componentName + "': " + existing.javaClass + " and " + component.javaClass)
     }
-    myComponents.put(componentName, component);
+    myComponents.put(componentName, component)
   }
 
-  private void loadJdomDefaults(@NotNull JDOMExternalizable component, @NotNull String componentName) {
+  private fun loadJdomDefaults(component: JDOMExternalizable, componentName: String) {
     try {
-      Element defaultState = getDefaultState(component, componentName, Element.class);
+      val defaultState = getDefaultState(component, componentName, javaClass<Element>())
       if (defaultState != null) {
-        component.readExternal(defaultState);
+        component.readExternal(defaultState)
       }
     }
-    catch (Exception e) {
-      LOG.error("Cannot load defaults for " + component.getClass(), e);
+    catch (e: Exception) {
+      LOG.error("Cannot load defaults for " + component.javaClass, e)
     }
+
   }
 
-  @Nullable
-  protected Project getProject() {
-    return null;
+  protected open fun getProject(): Project? {
+    return null
   }
 
-  @Nullable
-  private <T> String initPersistentComponent(@NotNull PersistentStateComponent<T> component, @Nullable Set<StateStorage> changedStorages, boolean reloadData) {
-    State stateSpec = StoreUtil.getStateSpec(component);
-    String name = stateSpec.name();
+  private fun <T> initPersistentComponent(component: PersistentStateComponent<T>, changedStorages: Set<StateStorage>?, reloadData: Boolean): String? {
+    val stateSpec = StoreUtil.getStateSpec(component)
+    val name = stateSpec.name
     if (changedStorages == null || !reloadData) {
-      doAddComponent(name, component);
+      doAddComponent(name, component)
     }
     if (optimizeTestLoading()) {
-      return null;
+      return null
     }
 
-    Class<T> stateClass = ComponentSerializationUtil.getStateClass(component.getClass());
-    if (!stateSpec.defaultStateAsResource() && LOG.isDebugEnabled() && getDefaultState(component, name, stateClass) != null) {
-      LOG.error(name + " has default state, but not marked to load it");
+    val stateClass = ComponentSerializationUtil.getStateClass<T>(component.javaClass)
+    if (!stateSpec.defaultStateAsResource && LOG.isDebugEnabled() && getDefaultState(component, name, stateClass) != null) {
+      LOG.error(name + " has default state, but not marked to load it")
     }
 
-    T state = stateSpec.defaultStateAsResource() ? getDefaultState(component, name, stateClass) : null;
-    Storage[] storageSpecs = getComponentStorageSpecs(component, stateSpec, StateStorageOperation.READ);
-    StateStorageChooserEx stateStorageChooser = component instanceof StateStorageChooserEx ? (StateStorageChooserEx)component : null;
-    for (Storage storageSpec : storageSpecs) {
-      Resolution resolution = stateStorageChooser == null ? Resolution.DO : stateStorageChooser.getResolution(storageSpec, StateStorageOperation.READ);
-      if (resolution == Resolution.SKIP) {
-        continue;
+    var state = if (stateSpec.defaultStateAsResource) getDefaultState(component, name, stateClass) else null
+    val storageSpecs = getComponentStorageSpecs(component, stateSpec, StateStorageOperation.READ)
+    val stateStorageChooser = component as? StateStorageChooserEx
+    for (storageSpec in storageSpecs) {
+      val resolution = if (stateStorageChooser == null) Resolution.DO else stateStorageChooser.getResolution(storageSpec, StateStorageOperation.READ)
+      if (resolution === Resolution.SKIP) {
+        continue
       }
 
-      StateStorage stateStorage = getStateStorageManager().getStateStorage(storageSpec);
-      boolean forcedState = false;
-      if (stateStorage != null && (stateStorage.hasState(component, name, stateClass, reloadData) ||
-                                   (forcedState = changedStorages != null && changedStorages.contains(stateStorage)))) {
-        state = stateStorage.getState(component, name, stateClass, state);
+      val stateStorage = getStateStorageManager().getStateStorage(storageSpec)
+      if (stateStorage != null) {
+        var forcedState = false
+        if (!stateStorage.hasState(component, name, stateClass, reloadData)) {
+          forcedState = changedStorages != null && changedStorages.contains(stateStorage)
+          if (!forcedState) {
+            continue
+          }
+        }
+
+        state = stateStorage.getState(component, name, stateClass, state)
         if (state == null && forcedState) {
           // state will be null if file deleted
           // we must create empty (initial) state to reinit component
-          state = DefaultStateSerializer.deserializeState(new Element("state"), stateClass, null);
+          state = DefaultStateSerializer.deserializeState(Element("state"), stateClass, null)
         }
-        break;
+        break
       }
     }
 
     if (state != null) {
-      component.loadState(state);
+      component.loadState(state)
     }
 
-    return name;
+    return name
   }
 
-  @Nullable
-  protected PathMacroManager getPathMacroManagerForDefaults() {
-    return null;
+  protected open fun getPathMacroManagerForDefaults(): PathMacroManager? {
+    return null
   }
 
-  @Nullable
-  protected <T> T getDefaultState(@NotNull Object component, @NotNull String componentName, @NotNull final Class<T> stateClass) {
-    URL url = DecodeDefaultsUtil.getDefaults(component, componentName);
-    if (url == null) {
-      return null;
-    }
-
+  protected fun <T : Any> getDefaultState(component: Any, componentName: String, stateClass: Class<T>): T? {
+    val url = DecodeDefaultsUtil.getDefaults(component, componentName) ?: return null
     try {
-      Element documentElement = JDOMXIncluder.resolve(JDOMUtil.loadDocument(url), url.toExternalForm()).detachRootElement();
-
-      PathMacroManager pathMacroManager = getPathMacroManagerForDefaults();
-      if (pathMacroManager != null) {
-        pathMacroManager.expandPaths(documentElement);
-      }
-
-      return DefaultStateSerializer.deserializeState(documentElement, stateClass, null);
+      val documentElement = JDOMXIncluder.resolve(JDOMUtil.loadDocument(url), url.toExternalForm()).detachRootElement()
+      getPathMacroManagerForDefaults()?.expandPaths(documentElement)
+      return DefaultStateSerializer.deserializeState<T>(documentElement, stateClass, null)
     }
-    catch (IOException e) {
-      throw new StateStorageException("Error loading state from " + url, e);
+    catch (e: IOException) {
+      throw StateStorageException("Error loading state from " + url, e)
     }
-    catch (JDOMException e) {
-      throw new StateStorageException("Error loading state from " + url, e);
+    catch (e: JDOMException) {
+      throw StateStorageException("Error loading state from " + url, e)
     }
+
   }
 
-  @NotNull
-  protected <T> Storage[] getComponentStorageSpecs(@NotNull PersistentStateComponent<T> component,
-                                                   @NotNull State stateSpec,
-                                                   @NotNull StateStorageOperation operation) {
-    Storage[] storages = stateSpec.storages();
-    if (storages.length == 1) {
-      return storages;
+  protected open fun <T> getComponentStorageSpecs(component: PersistentStateComponent<T>, stateSpec: State, operation: StateStorageOperation): Array<Storage> {
+    val storages = stateSpec.storages
+    if (storages.size() == 1) {
+      return storages
     }
-    assert storages.length > 0;
+    assert(!storages.isEmpty())
 
-    StateStorageChooser<PersistentStateComponent<T>> storageChooser;
-    Class<? extends StateStorageChooser> storageChooserClass = stateSpec.storageChooser();
-    if (storageChooserClass != StateStorageChooser.class) {
-      //noinspection unchecked
-      storageChooser = ReflectionUtil.newInstance(storageChooserClass);
-      return storageChooser.selectStorages(storages, component, operation);
+    var storageChooserClass = stateSpec.storageChooser.java
+    if (storageChooserClass != javaClass<StateStorageChooser<*>>()) {
+      @suppress("UNCHECKED_CAST")
+      val stateStorageChooser: StateStorageChooser<Any> = ReflectionUtil.newInstance(stateSpec.storageChooser.java as Class<out StateStorageChooser<Any>>)
+      return stateStorageChooser.selectStorages(storages, component, operation)
     }
 
-    StateStorageChooser<PersistentStateComponent<?>> defaultStateStorageChooser = getDefaultStateStorageChooser();
+    val defaultStateStorageChooser = getDefaultStateStorageChooser()
     if (defaultStateStorageChooser != null) {
-      return defaultStateStorageChooser.selectStorages(storages, component, operation);
+      return defaultStateStorageChooser.selectStorages(storages, component, operation)
     }
 
-    if (component instanceof StateStorageChooserEx) {
-      return storages;
+    if (component is StateStorageChooserEx) {
+      return storages
     }
 
-    int actualStorageCount = 0;
-    for (Storage storage : storages) {
-      if (!storage.deprecated()) {
-        actualStorageCount++;
+    var actualStorageCount = 0
+    for (storage in storages) {
+      if (!storage.deprecated) {
+        actualStorageCount++
       }
     }
 
     if (actualStorageCount > 1) {
-      LOG.error("State chooser not specified for: " + component.getClass());
+      LOG.error("State chooser not specified for: " + component.javaClass)
     }
 
-    if (!storages[0].deprecated()) {
-      boolean othersAreDeprecated = true;
-      for (int i = 1; i < storages.length; i++) {
-        if (!storages[i].deprecated()) {
-          othersAreDeprecated = false;
-          break;
+    if (!storages[0].deprecated) {
+      var othersAreDeprecated = true
+      for (i in 1..storages.size() - 1) {
+        if (!storages[i].deprecated) {
+          othersAreDeprecated = false
+          break
         }
       }
 
       if (othersAreDeprecated) {
-        return storages;
+        return storages
       }
     }
 
-    Storage[] sorted = Arrays.copyOf(storages, storages.length);
-    Arrays.sort(sorted, new Comparator<Storage>() {
-      @Override
-      public int compare(Storage o1, Storage o2) {
-        int w1 = o1.deprecated() ? 1 : 0;
-        int w2 = o2.deprecated() ? 1 : 0;
-        return w1 - w2;
+    val sorted = Arrays.copyOf(storages, storages.size())
+    Arrays.sort(sorted, object : Comparator<Storage> {
+      override fun compare(o1: Storage, o2: Storage): Int {
+        val w1 = if (o1.deprecated) 1 else 0
+        val w2 = if (o2.deprecated) 1 else 0
+        return w1 - w2
       }
-    });
-    return sorted;
+    })
+    return sorted
   }
 
-  protected boolean optimizeTestLoading() {
-    return false;
+  protected open fun optimizeTestLoading(): Boolean {
+    return false
   }
 
-  @Nullable
-  protected StateStorageChooser<PersistentStateComponent<?>> getDefaultStateStorageChooser() {
-    return null;
+  protected open fun getDefaultStateStorageChooser(): StateStorageChooser<PersistentStateComponent<*>>? {
+    return null
   }
 
-  @Override
-  public boolean isReloadPossible(@NotNull final Set<String> componentNames) {
-    for (String componentName : componentNames) {
-      final Object component = myComponents.get(componentName);
-      if (component != null && (!(component instanceof PersistentStateComponent) || !StoreUtil.getStateSpec((PersistentStateComponent<?>)component).reloadable())) {
-        return false;
+  override fun isReloadPossible(componentNames: Set<String>): Boolean {
+    for (componentName in componentNames) {
+      val component = myComponents.get(componentName)
+      if (component != null && (component !is PersistentStateComponent<*> || !StoreUtil.getStateSpec(component).reloadable)) {
+        return false
       }
     }
 
-    return true;
+    return true
   }
 
-  @Override
-  @NotNull
-  public final Collection<String> getNotReloadableComponents(@NotNull Collection<String> componentNames) {
-    Set<String> notReloadableComponents = null;
-    for (String componentName : componentNames) {
-      Object component = myComponents.get(componentName);
-      if (component != null && (!(component instanceof PersistentStateComponent) || !StoreUtil.getStateSpec((PersistentStateComponent<?>)component).reloadable())) {
+  override fun getNotReloadableComponents(componentNames: Collection<String>): Collection<String> {
+    var notReloadableComponents: MutableSet<String>? = null
+    for (componentName in componentNames) {
+      val component = myComponents.get(componentName)
+      if (component != null && (component !is PersistentStateComponent<*> || !StoreUtil.getStateSpec(component).reloadable)) {
         if (notReloadableComponents == null) {
-          notReloadableComponents = new LinkedHashSet<String>();
+          notReloadableComponents = LinkedHashSet<String>()
         }
-        notReloadableComponents.add(componentName);
+        notReloadableComponents.add(componentName)
       }
     }
-    return notReloadableComponents == null ? Collections.<String>emptySet() : notReloadableComponents;
+    return if (notReloadableComponents == null) emptySet<String>() else notReloadableComponents
   }
 
-  @Override
-  public void reinitComponents(@NotNull Set<String> componentNames, boolean reloadData) {
-    reinitComponents(componentNames, Collections.<String>emptySet(), Collections.<StateStorage>emptySet());
+  override fun reinitComponents(componentNames: Set<String>, reloadData: Boolean) {
+    reinitComponents(componentNames, emptySet<String>(), emptySet<StateStorage>())
   }
 
-  @Override
-  public boolean reinitComponent(@NotNull String componentName, @NotNull Set<StateStorage> changedStorages) {
-    PersistentStateComponent component = (PersistentStateComponent)myComponents.get(componentName);
+  override fun reinitComponent(componentName: String, changedStorages: Set<StateStorage>): Boolean {
+    val component = myComponents.get(componentName) as PersistentStateComponent<*>?
     if (component == null) {
-      return false;
+      return false
     }
     else {
-      boolean changedStoragesEmpty = changedStorages.isEmpty();
-      initPersistentComponent(component, changedStoragesEmpty ? null : changedStorages, changedStoragesEmpty);
-      return true;
+      val changedStoragesEmpty = changedStorages.isEmpty()
+      initPersistentComponent(component, if (changedStoragesEmpty) null else changedStorages, changedStoragesEmpty)
+      return true
     }
   }
 
-  @NotNull
-  protected abstract MessageBus getMessageBus();
+  protected abstract fun getMessageBus(): MessageBus
 
-  @Override
-  @Nullable
-  public final Collection<String> reload(@NotNull MultiMap<StateStorage, VirtualFile> changedStorages) {
+  override fun reload(changedStorages: MultiMap<StateStorage, VirtualFile>): Collection<String>? {
     if (changedStorages.isEmpty()) {
-      return Collections.emptySet();
+      return emptySet()
     }
 
-    Set<String> componentNames = new SmartHashSet<String>();
-    for (StateStorage storage : changedStorages.keySet()) {
+    val componentNames = SmartHashSet<String>()
+    for (storage in changedStorages.keySet()) {
       try {
         // we must update (reload in-memory storage data) even if non-reloadable component will be detected later
         // not saved -> user does own modification -> new (on disk) state will be overwritten and not applied
-        storage.analyzeExternalChangesAndUpdateIfNeed(changedStorages.get(storage), componentNames);
+        storage.analyzeExternalChangesAndUpdateIfNeed(changedStorages.get(storage), componentNames)
       }
-      catch (Throwable e) {
-        LOG.error(e);
+      catch (e: Throwable) {
+        LOG.error(e)
       }
+
     }
 
     if (componentNames.isEmpty()) {
-      return Collections.emptySet();
+      return emptySet()
     }
 
-    Collection<String> notReloadableComponents = getNotReloadableComponents(componentNames);
-    reinitComponents(componentNames, notReloadableComponents, changedStorages.keySet());
-    return notReloadableComponents.isEmpty() ? null : notReloadableComponents;
+    val notReloadableComponents = getNotReloadableComponents(componentNames)
+    reinitComponents(componentNames, notReloadableComponents, changedStorages.keySet())
+    return if (notReloadableComponents.isEmpty()) null else notReloadableComponents
   }
 
   // used in settings repository plugin
-  public void reinitComponents(@NotNull Set<String> componentNames, @NotNull Collection<String> notReloadableComponents, @NotNull Set<StateStorage> changedStorages) {
-    MessageBus messageBus = getMessageBus();
-    messageBus.syncPublisher(BatchUpdateListener.TOPIC).onBatchUpdateStarted();
+  public fun reinitComponents(componentNames: Set<String>, notReloadableComponents: Collection<String>, changedStorages: Set<StateStorage>) {
+    val messageBus = getMessageBus()
+    messageBus.syncPublisher(BatchUpdateListener.TOPIC).onBatchUpdateStarted()
     try {
-      for (String componentName : componentNames) {
+      for (componentName in componentNames) {
         if (!notReloadableComponents.contains(componentName)) {
-          reinitComponent(componentName, changedStorages);
+          reinitComponent(componentName, changedStorages)
         }
       }
     }
     finally {
-      messageBus.syncPublisher(BatchUpdateListener.TOPIC).onBatchUpdateFinished();
+      messageBus.syncPublisher(BatchUpdateListener.TOPIC).onBatchUpdateFinished()
+    }
+  }
+
+  companion object {
+    private fun findNonDeprecated(storages: Array<Storage>): Storage {
+      for (storage in storages) {
+        if (!storage.deprecated) {
+          return storage
+        }
+      }
+      throw AssertionError("All storages are deprecated")
+    }
+
+    protected fun executeSave(session: SaveSession, readonlyFiles: MutableList<Pair<SaveSession, VirtualFile>>, previousErrors: MutableList<Throwable>?): MutableList<Throwable>? {
+      var errors = previousErrors
+      try {
+        session.save()
+      }
+      catch (e: ReadOnlyModificationException) {
+        LOG.warn(e)
+        readonlyFiles.add(util.Pair.create<SaveSession, VirtualFile>(if (e.getSession() == null) session else e.getSession(), e.getFile()))
+      }
+      catch (e: Exception) {
+        if (errors == null) {
+          errors = SmartList<Throwable>()
+        }
+        errors.add(e)
+      }
+
+      return errors
     }
   }
 }
index a9e3170d0071183cbca5056d8cd4c200df331908..0f161cef00b829c0de41d9a1a94b94a580862cc1 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
-
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.StateStorage.SaveSession;
-import com.intellij.openapi.project.impl.ProjectImpl;
-import com.intellij.openapi.project.impl.ProjectManagerImpl;
-import com.intellij.openapi.util.Couple;
-import com.intellij.util.containers.ContainerUtil;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-public class DefaultProjectStoreImpl extends ProjectStoreImpl {
-  private final ProjectManagerImpl myProjectManager;
-  @NonNls private static final String ROOT_TAG_NAME = "defaultProject";
-
-  public DefaultProjectStoreImpl(@NotNull ProjectImpl project, @NotNull ProjectManagerImpl projectManager, @NotNull PathMacroManager pathMacroManager) {
-    super(project, pathMacroManager);
-
-    myProjectManager = projectManager;
+package com.intellij.openapi.components.impl.stores
+
+import com.intellij.openapi.components.*
+import com.intellij.openapi.components.impl.stores.FileBasedStorage
+import com.intellij.openapi.components.impl.stores.StateStorageManager
+import com.intellij.openapi.components.impl.stores.StreamProvider
+import com.intellij.openapi.project.impl.ProjectImpl
+import com.intellij.openapi.project.impl.ProjectManagerImpl
+import com.intellij.openapi.util.Couple
+import com.intellij.util.containers.ContainerUtil
+import org.jdom.Element
+
+public class DefaultProjectStoreImpl(project: ProjectImpl, private val projectManager: ProjectManagerImpl, pathMacroManager: PathMacroManager) : ProjectStoreImpl(project, pathMacroManager) {
+  fun getStateCopy(): Element? {
+    val element = projectManager.getDefaultProjectRootElement()
+    return element?.clone()
   }
 
-  @Nullable
-  Element getStateCopy() {
-    final Element element = myProjectManager.getDefaultProjectRootElement();
-    return element != null ? element.clone() : null;
-  }
-
-  @NotNull
-  @Override
-  protected StateStorageManager createStateStorageManager() {
-    final XmlElementStorage storage = new XmlElementStorage("", RoamingType.DISABLED, myPathMacroManager.createTrackingSubstitutor(),
-                                                            ROOT_TAG_NAME, null) {
-      @Override
-      @Nullable
-      protected Element loadLocalData() {
-        return getStateCopy();
-      }
-
-      @NotNull
-      @Override
-      protected XmlElementStorageSaveSession createSaveSession(@NotNull StorageData storageData) {
-        return new XmlElementStorageSaveSession(storageData) {
-          @Override
-          protected void doSave(@Nullable Element element) {
-            // we must set empty element instead of null as indicator - ProjectManager state is ready to save
-            myProjectManager.setDefaultProjectRootElement(element == null ? new Element("empty") : element);
-          }
-
-          // we must not collapse paths here, because our solution is just a big hack
-          // by default, getElementToSave() returns collapsed paths -> setDefaultProjectRootElement -> project manager writeExternal -> save -> compare old and new - diff because old has expanded, but new collapsed
-          // -> needless save
-          @Override
-          protected boolean isCollapsePathsOnSave() {
-            return false;
-          }
-        };
-      }
-
-      @Override
-      @NotNull
-      protected StorageData createStorageData() {
-        return new BaseStorageData(ROOT_TAG_NAME);
-      }
-    };
-
+  protected override fun createStateStorageManager(): StateStorageManager {
+    val storage = DefaultProjectStorage(this, myPathMacroManager, projectManager)
     //noinspection deprecation
-    return new StateStorageManager() {
-      @Override
-      public void addMacro(@NotNull String macro, @NotNull String expansion) {
-        throw new UnsupportedOperationException("Method addMacro not implemented in " + getClass());
-      }
-
-      @Override
-      @Nullable
-      public TrackingPathMacroSubstitutor getMacroSubstitutor() {
-        return null;
-      }
-
-      @Override
-      @Nullable
-      public StateStorage getStateStorage(@NotNull Storage storageSpec) {
-        return storage;
-      }
+    return object : StateStorageManager {
+      override fun addMacro(macro: String, expansion: String) = throw UnsupportedOperationException("Method addMacro not implemented in " + javaClass)
 
-      @Nullable
-      @Override
-      public StateStorage getStateStorage(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
-        return storage;
-      }
+      override fun getMacroSubstitutor() = null
 
-      @NotNull
-      @Override
-      public Couple<Collection<FileBasedStorage>> getCachedFileStateStorages(@NotNull Collection<String> changed, @NotNull Collection<String> deleted) {
-        return new Couple<Collection<FileBasedStorage>>(Collections.<FileBasedStorage>emptyList(), Collections.<FileBasedStorage>emptyList());
-      }
+      override fun getStateStorage(storageSpec: Storage) = storage
 
-      @Override
-      public void clearStateStorage(@NotNull String file) {
-      }
+      override fun getStateStorage(fileSpec: String, roamingType: RoamingType) = storage
 
-      @Nullable
-      @Override
-      public ExternalizationSession startExternalization() {
-        StateStorage.ExternalizationSession externalizationSession = storage.startExternalization();
-        return externalizationSession == null ? null : new MyExternalizationSession(externalizationSession);
-      }
+      override fun getCachedFileStateStorages(changed: Collection<String>, deleted: Collection<String>): Couple<Collection<FileBasedStorage>> = Couple(emptyList<FileBasedStorage>(), emptyList<FileBasedStorage>())
 
-      @NotNull
-      @Override
-      public String expandMacros(@NotNull String file) {
-        throw new UnsupportedOperationException("Method expandMacros not implemented in " + getClass());
+      override fun clearStateStorage(file: String) {
       }
 
-      @NotNull
-      @Override
-      public String collapseMacros(@NotNull String path) {
-        throw new UnsupportedOperationException("Method collapseMacros not implemented in " + getClass());
+      override fun startExternalization(): StateStorageManager.ExternalizationSession? {
+        val externalizationSession = storage.startExternalization()
+        return if (externalizationSession == null) null else MyExternalizationSession(externalizationSession)
       }
 
-      @Override
-      @Nullable
-      public StateStorage getOldStorage(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) {
-        return storage;
-      }
+      override fun expandMacros(file: String) = throw UnsupportedOperationException("Method expandMacros not implemented in " + javaClass)
 
-      @Override
-      public void setStreamProvider(@Nullable StreamProvider streamProvider) {
-        throw new UnsupportedOperationException("Method setStreamProvider not implemented in " + getClass());
-      }
+      override fun collapseMacros(path: String) = throw UnsupportedOperationException("Method collapseMacros not implemented in " + javaClass)
 
-      @Nullable
-      @Override
-      public StreamProvider getStreamProvider() {
-        throw new UnsupportedOperationException("Method getStreamProviders not implemented in " + getClass());
-      }
+      override fun getOldStorage(component: Any, componentName: String, operation: StateStorageOperation) = storage
 
-      @NotNull
-      @Override
-      public Collection<String> getStorageFileNames() {
-        throw new UnsupportedOperationException("Method getStorageFileNames not implemented in " + getClass());
-      }
-    };
-  }
+      override fun setStreamProvider(streamProvider: StreamProvider?) = throw UnsupportedOperationException("Method setStreamProvider not implemented in " + javaClass)
 
-  private static class MyExternalizationSession implements StateStorageManager.ExternalizationSession {
-    @NotNull final StateStorage.ExternalizationSession externalizationSession;
+      override fun getStreamProvider() = throw UnsupportedOperationException("Method getStreamProviders not implemented in " + javaClass)
 
-    public MyExternalizationSession(@NotNull StateStorage.ExternalizationSession externalizationSession) {
-      this.externalizationSession = externalizationSession;
+      override fun getStorageFileNames() = throw UnsupportedOperationException("Method getStorageFileNames not implemented in " + javaClass)
     }
+  }
 
-    @Override
-    public void setState(@NotNull Storage[] storageSpecs, @NotNull Object component, @NotNull String componentName, @NotNull Object state) {
-      externalizationSession.setState(component, componentName, state, null);
+  private class MyExternalizationSession(val externalizationSession: StateStorage.ExternalizationSession) : StateStorageManager.ExternalizationSession {
+    override fun setState(storageSpecs: Array<Storage>, component: Any, componentName: String, state: Any) {
+      externalizationSession.setState(component, componentName, state, null)
     }
 
-    @Override
-    public void setStateInOldStorage(@NotNull Object component, @NotNull String componentName, @NotNull Object state) {
-      externalizationSession.setState(component, componentName, state, null);
+    override fun setStateInOldStorage(component: Any, componentName: String, state: Any) {
+      externalizationSession.setState(component, componentName, state, null)
     }
 
-    @NotNull
-    @Override
-    public List<SaveSession> createSaveSessions() {
-      return ContainerUtil.createMaybeSingletonList(externalizationSession.createSaveSession());
-    }
+    override fun createSaveSessions() = ContainerUtil.createMaybeSingletonList(externalizationSession.createSaveSession())
   }
 }
index 76a997237e37d8309dab5b904c1e24383f143604..491b7137fb24bb9ff39135b78be773b429764d88 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.components.PathMacroSubstitutor;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.OptionManager;
-import com.intellij.openapi.util.text.StringUtil;
-import org.jdom.Attribute;
-import org.jdom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.openapi.components.PathMacroSubstitutor
+import com.intellij.openapi.components.impl.stores.StorageData
+import com.intellij.openapi.module.Module
+import com.intellij.openapi.module.OptionManager
+import com.intellij.openapi.util.text.StringUtil
+import org.jdom.Element
+import java.util.TreeMap
 
-import java.util.Set;
-import java.util.TreeMap;
+class ModuleFileData : BaseFileConfigurableStoreImpl.BaseStorageData, OptionManager {
+  private var options: TreeMap<String, String>? = null
+  private val module: Module
 
-final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData implements OptionManager {
-  private TreeMap<String, String> options;
-  private final Module myModule;
+  private var dirty = true
 
-  private boolean dirty = true;
+  override fun isDirty() = dirty
 
-  public ModuleFileData(@NotNull String rootElementName, @NotNull Module module) {
-    super(rootElementName);
-
-    myModule = module;
-    options = new TreeMap<String, String>();
-  }
-
-  @Override
-  public boolean isDirty() {
-    return dirty;
+  public constructor(rootElementName: String, module: Module) : super(rootElementName) {
+    this.module = module
+    options = TreeMap<String, String>()
   }
 
-  private ModuleFileData(@NotNull ModuleFileData storageData) {
-    super(storageData);
-
-    myModule = storageData.myModule;
-    dirty = storageData.dirty;
-    options = new TreeMap<String, String>(storageData.options);
+  private constructor(storageData: ModuleFileData) : super(storageData) {
+    module = storageData.module
+    dirty = storageData.dirty
+    options = TreeMap(storageData.options)
   }
 
-  @Override
-  public void load(@NotNull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
-    super.load(rootElement, pathMacroSubstitutor, intern);
+  override fun load(rootElement: Element, pathMacroSubstitutor: PathMacroSubstitutor?, intern: Boolean) {
+    super<BaseFileConfigurableStoreImpl.BaseStorageData>.load(rootElement, pathMacroSubstitutor, intern)
 
-    for (Attribute attribute : rootElement.getAttributes()) {
-      String name = attribute.getName();
-      if (!name.equals(BaseFileConfigurableStoreImpl.VERSION_OPTION) && !StringUtil.isEmpty(name)) {
-        options.put(name, attribute.getValue());
+    for (attribute in rootElement.getAttributes()) {
+      val name = attribute.getName()
+      if (name != VERSION_OPTION && !StringUtil.isEmpty(name)) {
+        options!!.put(name, attribute.getValue())
       }
     }
 
-    dirty = false;
+    dirty = false
   }
 
-  @Override
-  protected void writeOptions(@NotNull Element root, @NotNull String versionString) {
-    if (!options.isEmpty()) {
-      for (String key : options.keySet()) {
-        String value = options.get(key);
+  override fun writeOptions(root: Element, versionString: String) {
+    if (!options!!.isEmpty()) {
+      for (key in options!!.keySet()) {
+        val value = options!!.get(key)
         if (value != null) {
-          root.setAttribute(key, value);
+          root.setAttribute(key, value)
         }
       }
     }
     // need be last for compat reasons
-    super.writeOptions(root, versionString);
+    super<BaseFileConfigurableStoreImpl.BaseStorageData>.writeOptions(root, versionString)
 
-    dirty = false;
+    dirty = false
   }
 
-  @Override
-  public StorageData clone() {
-    return new ModuleFileData(this);
+  override fun clone(): StorageData {
+    return ModuleFileData(this)
   }
 
-  @Nullable
-  @Override
-  public Set<String> getChangedComponentNames(@NotNull StorageData newStorageData, @Nullable PathMacroSubstitutor substitutor) {
-    final ModuleFileData data = (ModuleFileData)newStorageData;
-    if (!options.equals(data.options)) {
-      return null;
+  override fun getChangedComponentNames(newStorageData: StorageData, substitutor: PathMacroSubstitutor?): Set<String>? {
+    val data = newStorageData as ModuleFileData
+    if (options != data.options) {
+      return null
     }
 
-    return super.getChangedComponentNames(newStorageData, substitutor);
+    return super<BaseFileConfigurableStoreImpl.BaseStorageData>.getChangedComponentNames(newStorageData, substitutor)
   }
 
-  @Override
-  public void setOption(@NotNull String key, @NotNull String value) {
-    if (!value.equals(options.put(key, value))) {
-      dirty = true;
+  override fun setOption(key: String, value: String) {
+    if (value != options!!.put(key, value)) {
+      dirty = true
     }
   }
 
-  @Override
-  public void clearOption(@NotNull String key) {
-    if (options.remove(key) != null) {
-      dirty = true;
+  override fun clearOption(key: String) {
+    if (options!!.remove(key) != null) {
+      dirty = true
     }
   }
 
-  @Override
-  @Nullable
-  public String getOptionValue(@NotNull String key) {
-    return options.get(key);
+  override fun getOptionValue(key: String): String? {
+    return options!!.get(key)
   }
 }
index ced6c3b206cdf1cfc9879ee0b53effa9be09b6ce..63baa6f6ed7413e6af433945cd9ff908d8d85bd8 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
-
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.module.Module;
-import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collections;
-import java.util.List;
-
-public class ModuleStateStorageManager extends StateStorageManagerImpl {
-  @NonNls private static final String ROOT_TAG_NAME = "module";
-  private final Module myModule;
-
-  public ModuleStateStorageManager(@NotNull TrackingPathMacroSubstitutor pathMacroManager, @NotNull Module module) {
-    super(pathMacroManager, ROOT_TAG_NAME, module, module.getPicoContainer());
-
-    myModule = module;
-  }
-
-  @NotNull
-  @Override
-  protected StorageData createStorageData(@NotNull String fileSpec, @NotNull String filePath) {
-    return new ModuleFileData(ROOT_TAG_NAME, myModule);
-  }
-
-  @NotNull
-  @Override
-  public ExternalizationSession startExternalization() {
-    return new StateStorageManagerExternalizationSession() {
-      @NotNull
-      @Override
-      public List<StateStorage.SaveSession> createSaveSessions() {
-        StateStorageManagerImpl storageManager = (StateStorageManagerImpl)ComponentsPackage.getStateStore(myModule).getStateStorageManager();
-        FileBasedStorage storage = ContainerUtil.getFirstItem(storageManager.getCachedFileStorages(Collections.singletonList(StoragePathMacros.MODULE_FILE)));
-        if (storage != null && storage.getStorageData().isDirty()) {
-          // force XmlElementStorageSaveSession creation
-          getExternalizationSession(storage);
-        }
-        return super.createSaveSessions();
+package com.intellij.configurationStore
+
+import com.intellij.openapi.components.StateStorage
+import com.intellij.openapi.components.StateStorageOperation
+import com.intellij.openapi.components.StoragePathMacros
+import com.intellij.openapi.components.TrackingPathMacroSubstitutor
+import com.intellij.openapi.module.Module
+import com.intellij.util.containers.ContainerUtil
+
+class ModuleStateStorageManager(pathMacroManager: TrackingPathMacroSubstitutor, private val myModule: Module) : StateStorageManagerImpl(pathMacroManager, "module", myModule, myModule.getPicoContainer()) {
+  override fun createStorageData(fileSpec: String, filePath: String) = ModuleFileData(rootTagName, myModule)
+
+  override fun startExternalization() = MyStateStorageManagerExternalizationSession(this)
+
+  private class MyStateStorageManagerExternalizationSession(storageManager: StateStorageManagerImpl) : StateStorageManagerImpl.StateStorageManagerExternalizationSession(storageManager) {
+    override fun createSaveSessions(): List<StateStorage.SaveSession> {
+      val storage = ContainerUtil.getFirstItem(storageManager.getCachedFileStorages(listOf(StoragePathMacros.MODULE_FILE)))
+      if (storage != null && storage.getStorageData().isDirty()) {
+        // force XmlElementStorageSaveSession creation
+        getExternalizationSession(storage)
       }
-    };
+      return super.createSaveSessions()
+    }
   }
 
-  @Nullable
-  @Override
-  protected String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) {
-    return StoragePathMacros.MODULE_FILE;
-  }
+  override fun getOldStorageSpec(component: Any, componentName: String, operation: StateStorageOperation) = StoragePathMacros.MODULE_FILE
 
-  @NotNull
-  @Override
-  protected StateStorage.Listener createStorageTopicListener() {
-    return myModule.getProject().getMessageBus().syncPublisher(StateStorage.PROJECT_STORAGE_TOPIC);
-  }
+  override fun createStorageTopicListener() = myModule.getProject().getMessageBus().syncPublisher(StateStorage.PROJECT_STORAGE_TOPIC)
 }
\ No newline at end of file
index 62429b486ad01cd134a952ee30db59ccc79a93a4..727e7d021275cf4bddac8229ca9a1f54fecdd306 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.components.PathMacroManager;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ex.ProjectEx;
-import com.intellij.util.messages.MessageBus;
-import org.jetbrains.annotations.NotNull;
+import com.intellij.openapi.components.PathMacroManager
+import com.intellij.openapi.module.Module
+import com.intellij.openapi.project.ex.ProjectEx
 
-final class ModuleStoreImpl extends BaseFileConfigurableStoreImpl {
-  private final Module myModule;
+class ModuleStoreImpl(private val myModule: Module, pathMacroManager: PathMacroManager) : BaseFileConfigurableStoreImpl(pathMacroManager) {
+  override fun getProject() = myModule.getProject()
 
-  public ModuleStoreImpl(@NotNull Module module, @NotNull PathMacroManager pathMacroManager) {
-    super(pathMacroManager);
+  override fun optimizeTestLoading() = (myModule.getProject() as ProjectEx).isOptimiseTestLoadSpeed()
 
-    myModule = module;
-  }
+  override fun getMessageBus() = myModule.getMessageBus()
 
-  @Override
-  protected Project getProject() {
-    return myModule.getProject();
-  }
-
-  @Override
-  protected boolean optimizeTestLoading() {
-    return ((ProjectEx)myModule.getProject()).isOptimiseTestLoadSpeed();
-  }
-
-  @NotNull
-  @Override
-  protected MessageBus getMessageBus() {
-    return myModule.getMessageBus();
-  }
-
-  @NotNull
-  @Override
-  protected StateStorageManager createStateStorageManager() {
-    return new ModuleStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myModule);
-  }
+  override fun createStateStorageManager() = ModuleStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myModule)
 }
index 6a4c4d047d57fad4581842745e4182024d0ed3f0..425b93224a10b4110fc25b66b0a4d605a87f89a4 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.project.impl.ProjectImpl;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.openapi.components.*
+import com.intellij.openapi.components.impl.stores.StorageData
+import com.intellij.openapi.project.impl.ProjectImpl
+import org.jdom.Element
 
-public class ProjectStateStorageManager extends StateStorageManagerImpl {
-  protected final ProjectImpl myProject;
-  @NonNls protected static final String ROOT_TAG_NAME = "project";
-
-  public ProjectStateStorageManager(@NotNull TrackingPathMacroSubstitutor macroSubstitutor, @NotNull ProjectImpl project) {
-    super(macroSubstitutor, ROOT_TAG_NAME, project, project.getPicoContainer());
-    myProject = project;
+public class ProjectStateStorageManager(macroSubstitutor: TrackingPathMacroSubstitutor, protected val myProject: ProjectImpl) : StateStorageManagerImpl(macroSubstitutor, ProjectStateStorageManager.ROOT_TAG_NAME, myProject, myProject.getPicoContainer()) {
+  companion object {
+    protected val ROOT_TAG_NAME: String = "project"
   }
 
-  @NotNull
-  @Override
-  protected StorageData createStorageData(@NotNull String fileSpec, @NotNull String filePath) {
-    if (fileSpec.equals(StoragePathMacros.PROJECT_FILE)) {
-      return createIprStorageData(filePath);
+  override fun createStorageData(fileSpec: String, filePath: String): StorageData {
+    if (fileSpec == StoragePathMacros.PROJECT_FILE) {
+      return createIprStorageData(filePath)
     }
-    if (fileSpec.equals(StoragePathMacros.WORKSPACE_FILE)) {
-      return new ProjectStoreImpl.WsStorageData(ROOT_TAG_NAME, myProject);
+    if (fileSpec == StoragePathMacros.WORKSPACE_FILE) {
+      return ProjectStoreImpl.WsStorageData(ROOT_TAG_NAME, myProject)
     }
-    return new ProjectStoreImpl.ProjectStorageData(ROOT_TAG_NAME, myProject);
+    return ProjectStoreImpl.ProjectStorageData(ROOT_TAG_NAME, myProject)
   }
 
-  @NotNull
-  protected StorageData createIprStorageData(@NotNull String filePath) {
-    return new ProjectStoreImpl.IprStorageData(ROOT_TAG_NAME, myProject);
-  }
+  protected fun createIprStorageData(filePath: String): StorageData = ProjectStoreImpl.IprStorageData(ROOT_TAG_NAME, myProject)
 
-  @Nullable
-  @Override
-  protected String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) {
-    boolean workspace = myProject.isWorkspaceComponent(component.getClass());
-    String fileSpec = workspace ? StoragePathMacros.WORKSPACE_FILE : StoragePathMacros.PROJECT_FILE;
-    StateStorage storage = getStateStorage(fileSpec, workspace ? RoamingType.DISABLED : RoamingType.PER_USER);
-    if (operation == StateStorageOperation.READ && storage != null && workspace && !storage.hasState(component, componentName, Element.class, false)) {
-      fileSpec = StoragePathMacros.PROJECT_FILE;
+  override fun getOldStorageSpec(component: Any, componentName: String, operation: StateStorageOperation): String? {
+    val workspace = myProject.isWorkspaceComponent(component.javaClass)
+    var fileSpec = if (workspace) StoragePathMacros.WORKSPACE_FILE else StoragePathMacros.PROJECT_FILE
+    val storage = getStateStorage(fileSpec, if (workspace) RoamingType.DISABLED else RoamingType.PER_USER)
+    if (operation === StateStorageOperation.READ && storage != null && workspace && !storage.hasState(component, componentName, javaClass<Element>(), false)) {
+      fileSpec = StoragePathMacros.PROJECT_FILE
     }
-    return fileSpec;
+    return fileSpec
   }
 
-  @NotNull
-  @Override
-  protected StateStorage.Listener createStorageTopicListener() {
-    return myProject.getMessageBus().syncPublisher(StateStorage.PROJECT_STORAGE_TOPIC);
-  }
+  override fun createStorageTopicListener() = myProject.getMessageBus().syncPublisher(StateStorage.PROJECT_STORAGE_TOPIC)
 }
index b8638ab5059f52a3e34432466ca2faee7d264c77..30aa0b1de6a8ca044e8f48a1990e17b92ba1d5cc 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
-
-import com.intellij.CommonBundle;
-import com.intellij.ide.highlighter.ProjectFileType;
-import com.intellij.ide.highlighter.WorkspaceFileType;
-import com.intellij.notification.Notifications;
-import com.intellij.notification.NotificationsManager;
-import com.intellij.openapi.application.*;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.StateStorage.SaveSession;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.fileTypes.FileType;
-import com.intellij.openapi.fileTypes.FileTypeManager;
-import com.intellij.openapi.help.HelpManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ProjectBundle;
-import com.intellij.openapi.project.impl.ProjectImpl;
-import com.intellij.openapi.project.impl.ProjectManagerImpl;
-import com.intellij.openapi.project.impl.ProjectManagerImpl.UnableToSaveProjectNotification;
-import com.intellij.openapi.ui.MessageDialogBuilder;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.io.FileUtilRt;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.*;
-import com.intellij.util.PathUtilRt;
-import com.intellij.util.SmartList;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.lang.CompoundRuntimeException;
-import com.intellij.util.messages.MessageBus;
-import org.jdom.Element;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.*;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProjectStore {
-  private static final Logger LOG = Logger.getInstance(ProjectStoreImpl.class);
-
-  private static final Storage DEFAULT_STORAGE_ANNOTATION = new MyStorage();
-
-  @NonNls private static final String OLD_PROJECT_SUFFIX = "_old.";
-
-  private static int originalVersion = -1;
-
-  protected ProjectImpl myProject;
-  @NotNull
-  private StorageScheme myScheme = StorageScheme.DEFAULT;
-  private String myPresentableUrl;
-
-  public ProjectStoreImpl(@NotNull ProjectImpl project, @NotNull PathMacroManager pathMacroManager) {
-    super(pathMacroManager);
-
-    myProject = project;
-  }
-
-  @SuppressWarnings("unused") //used in upsource
-  protected void setStorageScheme(@NotNull StorageScheme scheme) {
-    myScheme = scheme;
-  }
-
-  @Override
-  public boolean checkVersion() {
+package com.intellij.configurationStore
+
+import com.intellij.CommonBundle
+import com.intellij.ide.highlighter.ProjectFileType
+import com.intellij.ide.highlighter.WorkspaceFileType
+import com.intellij.notification.Notifications
+import com.intellij.notification.NotificationsManager
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.application.ApplicationNamesInfo
+import com.intellij.openapi.application.ModalityState
+import com.intellij.openapi.application.ReadAction
+import com.intellij.openapi.components.*
+import com.intellij.openapi.components.StateStorage.SaveSession
+import com.intellij.openapi.components.impl.stores.*
+import com.intellij.openapi.fileTypes.FileTypeManager
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.project.ProjectBundle
+import com.intellij.openapi.project.impl.ProjectImpl
+import com.intellij.openapi.project.impl.ProjectManagerImpl
+import com.intellij.openapi.project.impl.ProjectManagerImpl.UnableToSaveProjectNotification
+import com.intellij.openapi.ui.MessageDialogBuilder
+import com.intellij.openapi.ui.Messages
+import com.intellij.openapi.util.Pair
+import com.intellij.openapi.util.io.FileUtil
+import com.intellij.openapi.util.io.FileUtilRt
+import com.intellij.openapi.util.text.StringUtil
+import com.intellij.openapi.vfs.*
+import com.intellij.util.PathUtilRt
+import com.intellij.util.SmartList
+import com.intellij.util.lang.CompoundRuntimeException
+import com.intellij.util.messages.MessageBus
+import org.jdom.Element
+import java.io.BufferedReader
+import java.io.File
+import java.io.IOException
+import java.io.InputStreamReader
+import java.util.ArrayList
+
+public open class ProjectStoreImpl(protected var myProject: ProjectImpl, pathMacroManager: PathMacroManager) : BaseFileConfigurableStoreImpl(pathMacroManager), IProjectStore {
+  private var myScheme = StorageScheme.DEFAULT
+  private var myPresentableUrl: String? = null
+
+  SuppressWarnings("unused") //used in upsource
+  protected fun setStorageScheme(scheme: StorageScheme) {
+    myScheme = scheme
+  }
+
+  override fun checkVersion(): Boolean {
     if (originalVersion >= 0 && originalVersion < ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
-      final VirtualFile projectFile = getProjectFile();
-      LOG.assertTrue(projectFile != null);
-      String message = ProjectBundle.message("project.convert.old.prompt", projectFile.getName(),
-                                             ApplicationNamesInfo.getInstance().getProductName(),
-                                             projectFile.getNameWithoutExtension() + OLD_PROJECT_SUFFIX + projectFile.getExtension());
-      if (Messages.showYesNoDialog(message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()) != Messages.YES) return false;
-
-      List<String> conversionProblems = getConversionProblemsStorage();
-      if (!ContainerUtil.isEmpty(conversionProblems)) {
-        StringBuilder buffer = new StringBuilder();
-        buffer.append(ProjectBundle.message("project.convert.problems.detected"));
-        for (String s : conversionProblems) {
-          buffer.append('\n');
-          buffer.append(s);
-        }
-        buffer.append(ProjectBundle.message("project.convert.problems.help"));
-        if (Messages.showOkCancelDialog(myProject, buffer.toString(), ProjectBundle.message("project.convert.problems.title"),
-                                               ProjectBundle.message("project.convert.problems.help.button"),
-                                                 CommonBundle.getCloseButtonText(), Messages.getWarningIcon()) == Messages.OK) {
-          HelpManager.getInstance().invokeHelp("project.migrationProblems");
-        }
-      }
-
-      ApplicationManager.getApplication().runWriteAction(new Runnable() {
-        @Override
-        public void run() {
+      val projectFile = getProjectFile()
+      LOG.assertTrue(projectFile != null)
+      val message = ProjectBundle.message("project.convert.old.prompt", projectFile!!.getName(), ApplicationNamesInfo.getInstance().getProductName(), projectFile.getNameWithoutExtension() + OLD_PROJECT_SUFFIX + projectFile.getExtension())
+      if (Messages.showYesNoDialog(message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()) != Messages.YES) return false
+
+//      val conversionProblems = BaseFileConfigurableStoreImpl.conversionProblemsStorage
+//      if (!ContainerUtil.isEmpty(conversionProblems)) {
+//        val buffer = StringBuilder()
+//        buffer.append(ProjectBundle.message("project.convert.problems.detected"))
+//        for (s in conversionProblems) {
+//          buffer.append('\n')
+//          buffer.append(s)
+//        }
+//        buffer.append(ProjectBundle.message("project.convert.problems.help"))
+//        if (Messages.showOkCancelDialog(myProject, buffer.toString(), ProjectBundle.message("project.convert.problems.title"), ProjectBundle.message("project.convert.problems.help.button"), CommonBundle.getCloseButtonText(), Messages.getWarningIcon()) == Messages.OK) {
+//          HelpManager.getInstance().invokeHelp("project.migrationProblems")
+//        }
+//      }
+
+      ApplicationManager.getApplication().runWriteAction(object : Runnable {
+        override fun run() {
           try {
-            VirtualFile projectDir = projectFile.getParent();
-            assert projectDir != null;
+            val projectDir = projectFile.getParent()
+            assert(projectDir != null)
 
-            backup(projectDir, projectFile);
+            backup(projectDir, projectFile)
 
-            VirtualFile workspaceFile = getWorkspaceFile();
+            val workspaceFile = getWorkspaceFile()
             if (workspaceFile != null) {
-              backup(projectDir, workspaceFile);
+              backup(projectDir, workspaceFile)
             }
           }
-          catch (IOException e) {
-            LOG.error(e);
+          catch (e: IOException) {
+            LOG.error(e)
           }
+
         }
 
-        private void backup(final VirtualFile projectDir, final VirtualFile vile) throws IOException {
-          final String oldName = vile.getNameWithoutExtension() + OLD_PROJECT_SUFFIX + vile.getExtension();
-          VfsUtil.saveText(projectDir.findOrCreateChildData(this, oldName), VfsUtilCore.loadText(vile));
+        throws(IOException::class)
+        private fun backup(projectDir: VirtualFile, vile: VirtualFile) {
+          val oldName = vile.getNameWithoutExtension() + OLD_PROJECT_SUFFIX + vile.getExtension()
+          VfsUtil.saveText(projectDir.findOrCreateChildData(this, oldName), VfsUtilCore.loadText(vile))
         }
-      });
+      })
     }
 
-    return originalVersion <= ProjectManagerImpl.CURRENT_FORMAT_VERSION ||
-           MessageDialogBuilder.yesNo(CommonBundle.getWarningTitle(),
-                                      ProjectBundle.message("project.load.new.version.warning", myProject.getName(), ApplicationNamesInfo.getInstance().getProductName()))
-             .icon(Messages.getWarningIcon())
-             .project(myProject).is();
+    return originalVersion <= ProjectManagerImpl.CURRENT_FORMAT_VERSION || MessageDialogBuilder.yesNo(CommonBundle.getWarningTitle(), ProjectBundle.message("project.load.new.version.warning", myProject.getName(), ApplicationNamesInfo.getInstance().getProductName())).icon(Messages.getWarningIcon()).project(myProject).`is`()
   }
 
-  @NotNull
-  @Override
-  public TrackingPathMacroSubstitutor[] getSubstitutors() {
-    return new TrackingPathMacroSubstitutor[] {getStateStorageManager().getMacroSubstitutor()};
+  override fun getSubstitutors(): Array<TrackingPathMacroSubstitutor> {
+    val substitutor = getStateStorageManager().getMacroSubstitutor()
+    return if (substitutor == null) emptyArray() else arrayOf(substitutor)
   }
 
-  @Override
-  protected boolean optimizeTestLoading() {
-    return myProject.isOptimiseTestLoadSpeed();
-  }
+  override fun optimizeTestLoading() = myProject.isOptimiseTestLoadSpeed()
 
-  @Override
-  protected Project getProject() {
-    return myProject;
-  }
+  override fun getProject() = myProject
 
-  @Override
-  public void setProjectFilePath(@NotNull final String filePath) {
-    final StateStorageManager stateStorageManager = getStateStorageManager();
-    final LocalFileSystem fs = LocalFileSystem.getInstance();
+  override fun setProjectFilePath(filePath: String) {
+    val stateStorageManager = getStateStorageManager()
+    val fs = LocalFileSystem.getInstance()
 
-    final File file = new File(filePath);
+    val file = File(filePath)
     if (isIprPath(file)) {
-      myScheme = StorageScheme.DEFAULT;
+      myScheme = StorageScheme.DEFAULT
 
-      stateStorageManager.addMacro(StoragePathMacros.PROJECT_FILE, filePath);
+      stateStorageManager.addMacro(StoragePathMacros.PROJECT_FILE, filePath)
 
-      final String workspacePath = composeWsPath(filePath);
-      stateStorageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, workspacePath);
+      val workspacePath = composeWsPath(filePath)
+      stateStorageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, workspacePath)
 
-      ApplicationManager.getApplication().invokeAndWait(new Runnable() {
-        @Override
-        public void run() {
-          VfsUtil.markDirtyAndRefresh(false, true, false, fs.refreshAndFindFileByPath(filePath), fs.refreshAndFindFileByPath(workspacePath));
+      ApplicationManager.getApplication().invokeAndWait(object : Runnable {
+        override fun run() {
+          VfsUtil.markDirtyAndRefresh(false, true, false, fs.refreshAndFindFileByPath(filePath), fs.refreshAndFindFileByPath(workspacePath))
         }
-      }, ModalityState.defaultModalityState());
+      }, ModalityState.defaultModalityState())
     }
     else {
-      myScheme = StorageScheme.DIRECTORY_BASED;
+      myScheme = StorageScheme.DIRECTORY_BASED
 
-      final File dirStore = file.isDirectory() ? new File(file, Project.DIRECTORY_STORE_FOLDER)
-                                               : new File(file.getParentFile(), Project.DIRECTORY_STORE_FOLDER);
-      stateStorageManager.addMacro(StoragePathMacros.PROJECT_FILE, new File(dirStore, "misc.xml").getPath());
+      val dirStore = if (file.isDirectory())
+        File(file, Project.DIRECTORY_STORE_FOLDER)
+      else
+        File(file.getParentFile(), Project.DIRECTORY_STORE_FOLDER)
+      stateStorageManager.addMacro(StoragePathMacros.PROJECT_FILE, File(dirStore, "misc.xml").getPath())
 
-      final File ws = new File(dirStore, "workspace.xml");
-      stateStorageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, ws.getPath());
+      val ws = File(dirStore, "workspace.xml")
+      stateStorageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, ws.getPath())
       if (!ws.exists() && !file.isDirectory()) {
-        useOldWsContent(filePath, ws);
+        useOldWsContent(filePath, ws)
       }
 
-      stateStorageManager.addMacro(StoragePathMacros.PROJECT_CONFIG_DIR, dirStore.getPath());
+      stateStorageManager.addMacro(StoragePathMacros.PROJECT_CONFIG_DIR, dirStore.getPath())
 
-      ApplicationManager.getApplication().invokeAndWait(new Runnable() {
-        @Override
-        public void run() {
-          VfsUtil.markDirtyAndRefresh(false, true, true, fs.refreshAndFindFileByIoFile(dirStore));
+      ApplicationManager.getApplication().invokeAndWait(object : Runnable {
+        override fun run() {
+          VfsUtil.markDirtyAndRefresh(false, true, true, fs.refreshAndFindFileByIoFile(dirStore))
         }
-      }, ModalityState.defaultModalityState());
+      }, ModalityState.defaultModalityState())
     }
 
-    myPresentableUrl = null;
-  }
-
-  private static boolean isIprPath(final File file) {
-    return FileUtilRt.extensionEquals(file.getName(), ProjectFileType.DEFAULT_EXTENSION);
-  }
-
-  private static String composeWsPath(String filePath) {
-    final int lastDot = filePath.lastIndexOf('.');
-    final String filePathWithoutExt = lastDot > 0 ? filePath.substring(0, lastDot) : filePath;
-    return filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
-  }
-
-  private static void useOldWsContent(final String filePath, final File ws) {
-    final File oldWs = new File(composeWsPath(filePath));
-    if (oldWs.exists()) {
-      try {
-        final InputStream is = new FileInputStream(oldWs);
-        try {
-          final byte[] bytes = FileUtil.loadBytes(is, (int)oldWs.length());
-
-          final OutputStream os = new FileOutputStream(ws);
-          try {
-            os.write(bytes);
-          }
-          finally {
-            os.close();
-          }
-        }
-        finally {
-          is.close();
-        }
-      }
-      catch (IOException e) {
-        LOG.error(e);
-      }
-    }
+    myPresentableUrl = null
   }
 
-  @Override
-  public VirtualFile getProjectBaseDir() {
-    if (myProject.isDefault()) return null;
+  override fun getProjectBaseDir(): VirtualFile? {
+    if (myProject.isDefault()) return null
 
-    final String path = getProjectBasePath();
-    if (path == null) return null;
+    val path = getProjectBasePath() ?: return null
 
-    return LocalFileSystem.getInstance().findFileByPath(path);
+    return LocalFileSystem.getInstance().findFileByPath(path)
   }
 
-  @Override
-  public String getProjectBasePath() {
-    if (myProject.isDefault()) return null;
+  override fun getProjectBasePath(): String? {
+    if (myProject.isDefault()) return null
 
-    final String path = getProjectFilePath();
+    val path = getProjectFilePath()
     if (!StringUtil.isEmptyOrSpaces(path)) {
-      return getBasePath(new File(path));
+      return getBasePath(File(path))
     }
 
     //we are not yet initialized completely ("open directory", etc)
-    StateStorage storage = getStateStorageManager().getStateStorage(StoragePathMacros.PROJECT_FILE, RoamingType.PER_USER);
-    if (!(storage instanceof FileBasedStorage)) {
-      return null;
+    val storage = getStateStorageManager().getStateStorage(StoragePathMacros.PROJECT_FILE, RoamingType.PER_USER)
+    if (storage !is FileBasedStorage) {
+      return null
     }
 
-    return getBasePath(((FileBasedStorage)storage).getFile());
+    return getBasePath(storage.getFile())
   }
 
-  private String getBasePath(@NotNull File file) {
-    if (myScheme == StorageScheme.DEFAULT) {
-      return file.getParent();
+  private fun getBasePath(file: File): String? {
+    if (myScheme === StorageScheme.DEFAULT) {
+      return file.getParent()
     }
     else {
-      File parentFile = file.getParentFile();
-      return parentFile == null ? null : parentFile.getParent();
+      val parentFile = file.getParentFile()
+      return parentFile?.getParent()
     }
   }
 
-  @NotNull
-  @Override
-  public String getProjectName() {
-    if (myScheme == StorageScheme.DIRECTORY_BASED) {
-      final VirtualFile baseDir = getProjectBaseDir();
-      assert baseDir != null : "scheme=" + myScheme + " project file=" + getProjectFilePath();
+  override fun getProjectName(): String {
+    if (myScheme === StorageScheme.DIRECTORY_BASED) {
+      val baseDir = getProjectBaseDir()
+      assert(baseDir != null) { "scheme=" + myScheme + " project file=" + getProjectFilePath() }
 
-      final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER);
+      val ideaDir = baseDir!!.findChild(Project.DIRECTORY_STORE_FOLDER)
       if (ideaDir != null && ideaDir.isValid()) {
-        final VirtualFile nameFile = ideaDir.findChild(ProjectImpl.NAME_FILE);
+        val nameFile = ideaDir.findChild(ProjectImpl.NAME_FILE)
         if (nameFile != null && nameFile.isValid()) {
           try {
-            BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), CharsetToolkit.UTF8_CHARSET));
+            val `in` = BufferedReader(InputStreamReader(nameFile.getInputStream(), CharsetToolkit.UTF8_CHARSET))
             try {
-              final String name = in.readLine();
+              val name = `in`.readLine()
               if (name != null && !name.isEmpty()) {
-                return name.trim();
+                return name.trim()
               }
             }
             finally {
-              in.close();
+              `in`.close()
             }
           }
-          catch (IOException ignored) { }
+          catch (ignored: IOException) {
+          }
+
         }
       }
 
-      return baseDir.getName().replace(":", "");
+      return baseDir.getName().replace(":", "")
     }
     else {
-      String temp = PathUtilRt.getFileName(((FileBasedStorage)getProjectFileStorage()).getFilePath());
-      FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(temp);
-      if (fileType instanceof ProjectFileType) {
-        temp = temp.substring(0, temp.length() - fileType.getDefaultExtension().length() - 1);
+      var temp = PathUtilRt.getFileName((getProjectFileStorage() as FileBasedStorage).getFilePath())
+      val fileType = FileTypeManager.getInstance().getFileTypeByFileName(temp)
+      if (fileType is ProjectFileType) {
+        temp = temp.substring(0, temp.length() - fileType.getDefaultExtension().length() - 1)
       }
-      final int i = temp.lastIndexOf(File.separatorChar);
+      val i = temp.lastIndexOf(File.separatorChar)
       if (i >= 0) {
-        temp = temp.substring(i + 1, temp.length() - i + 1);
+        temp = temp.substring(i + 1, temp.length() - i + 1)
       }
-      return temp;
+      return temp
     }
   }
 
-  @NotNull
-  @Override
-  public StorageScheme getStorageScheme() {
-    return myScheme;
+  override fun getStorageScheme(): StorageScheme {
+    return myScheme
   }
 
-  @Override
-  public String getPresentableUrl() {
+  override fun getPresentableUrl(): String? {
     if (myProject.isDefault()) {
-      return null;
+      return null
     }
     if (myPresentableUrl == null) {
-      String url = myScheme == StorageScheme.DIRECTORY_BASED ? getProjectBasePath() : getProjectFilePath();
+      val url = if (myScheme === StorageScheme.DIRECTORY_BASED) getProjectBasePath() else getProjectFilePath()
       if (url != null) {
-        myPresentableUrl = FileUtil.toSystemDependentName(url);
+        myPresentableUrl = FileUtil.toSystemDependentName(url)
       }
     }
-    return myPresentableUrl;
+    return myPresentableUrl
   }
 
-  @Override
-  public VirtualFile getProjectFile() {
-    return myProject.isDefault() ? null : ((FileBasedStorage)getProjectFileStorage()).getVirtualFile();
-  }
+  override fun getProjectFile() = if (myProject.isDefault()) null else (getProjectFileStorage() as FileBasedStorage).getVirtualFile()
 
-  @NotNull
-  @Override
-  public String getProjectFilePath() {
-    return myProject.isDefault() ? "" : ((FileBasedStorage)getProjectFileStorage()).getFilePath();
-  }
+  override fun getProjectFilePath() = if (myProject.isDefault()) "" else (getProjectFileStorage() as FileBasedStorage).getFilePath()
 
-  @NotNull
-  private XmlElementStorage getProjectFileStorage() {
-    // XmlElementStorage if default project, otherwise FileBasedStorage
-    XmlElementStorage storage = (XmlElementStorage)getStateStorageManager().getStateStorage(StoragePathMacros.PROJECT_FILE, RoamingType.PER_USER);
-    assert storage != null;
-    return storage;
-  }
+  // XmlElementStorage if default project, otherwise FileBasedStorage
+  private fun getProjectFileStorage() = getStateStorageManager().getStateStorage(StoragePathMacros.PROJECT_FILE, RoamingType.PER_USER) as XmlElementStorage
 
-  @Override
-  public VirtualFile getWorkspaceFile() {
-    if (myProject.isDefault()) return null;
-    final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getStateStorage(StoragePathMacros.WORKSPACE_FILE, RoamingType.DISABLED);
-    assert storage != null;
-    return storage.getVirtualFile();
+  override fun getWorkspaceFile(): VirtualFile? {
+    if (myProject.isDefault()) return null
+    val storage = getStateStorageManager().getStateStorage(StoragePathMacros.WORKSPACE_FILE, RoamingType.DISABLED) as FileBasedStorage?
+    assert(storage != null)
+    return storage!!.getVirtualFile()
   }
 
-  @Nullable
-  @Override
-  public String getWorkspaceFilePath() {
-    if (myProject.isDefault()) return null;
-    final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getStateStorage(StoragePathMacros.WORKSPACE_FILE, RoamingType.DISABLED);
-    assert storage != null;
-    return storage.getFilePath();
+  override fun getWorkspaceFilePath(): String? {
+    if (myProject.isDefault()) return null
+    val storage = getStateStorageManager().getStateStorage(StoragePathMacros.WORKSPACE_FILE, RoamingType.DISABLED) as FileBasedStorage?
+    assert(storage != null)
+    return storage!!.getFilePath()
   }
 
-  @Override
-  public void loadProjectFromTemplate(@NotNull ProjectImpl defaultProject) {
-    defaultProject.save();
+  override fun loadProjectFromTemplate(defaultProject: ProjectImpl) {
+    defaultProject.save()
 
-    Element element = ((DefaultProjectStoreImpl)defaultProject.getStateStore()).getStateCopy();
+    val element = (defaultProject.getStateStore() as DefaultProjectStoreImpl).getStateCopy()
     if (element != null) {
-      getProjectFileStorage().setDefaultState(element);
+      getProjectFileStorage().setDefaultState(element)
     }
   }
 
-  @NotNull
-  @Override
-  protected StateStorageManager createStateStorageManager() {
-    return new ProjectStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myProject);
+  override fun createStateStorageManager(): StateStorageManager {
+    return ProjectStateStorageManager(myPathMacroManager.createTrackingSubstitutor(), myProject)
   }
 
-  static class  ProjectStorageData extends BaseStorageData {
-    protected final Project myProject;
+  open class ProjectStorageData : BaseFileConfigurableStoreImpl.BaseStorageData {
+    protected val myProject: Project
 
-    ProjectStorageData(final String rootElementName, Project project) {
-      super(rootElementName);
-      myProject = project;
+    constructor(rootElementName: String, project: Project) : super(rootElementName) {
+      myProject = project
     }
 
-    protected ProjectStorageData(ProjectStorageData storageData) {
-      super(storageData);
-      myProject = storageData.myProject;
+    protected constructor(storageData: ProjectStorageData) : super(storageData) {
+      myProject = storageData.myProject
     }
 
-    @Override
-    public StorageData clone() {
-      return new ProjectStorageData(this);
+    override fun clone(): StorageData {
+      return ProjectStorageData(this)
     }
   }
 
-  static class WsStorageData extends ProjectStorageData {
-    WsStorageData(final String rootElementName, final Project project) {
-      super(rootElementName, project);
+  class WsStorageData : ProjectStorageData {
+    constructor(rootElementName: String, project: Project) : super(rootElementName, project) {
     }
 
-    private WsStorageData(final WsStorageData storageData) {
-      super(storageData);
+    private constructor(storageData: WsStorageData) : super(storageData) {
     }
 
-    @Override
-    public StorageData clone() {
-      return new WsStorageData(this);
+    override fun clone(): StorageData {
+      return WsStorageData(this)
     }
   }
 
-  static class IprStorageData extends ProjectStorageData {
-    IprStorageData(final String rootElementName, Project project) {
-      super(rootElementName, project);
+  class IprStorageData : ProjectStorageData {
+    constructor(rootElementName: String, project: Project) : super(rootElementName, project) {
     }
 
-    IprStorageData(final IprStorageData storageData) {
-      super(storageData);
+    constructor(storageData: IprStorageData) : super(storageData) {
     }
 
-    @Override
-    public void load(@NotNull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) {
-      final String v = rootElement.getAttributeValue(VERSION_OPTION);
+    override fun load(rootElement: Element, pathMacroSubstitutor: PathMacroSubstitutor?, intern: Boolean) {
+      val v = rootElement.getAttributeValue(VERSION_OPTION)
       //noinspection AssignmentToStaticFieldFromInstanceMethod
-      originalVersion = v != null ? Integer.parseInt(v) : 0;
+      originalVersion = if (v != null) Integer.parseInt(v) else 0
 
       if (originalVersion != ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
-        convert(rootElement, originalVersion);
+        convert(rootElement, originalVersion)
       }
 
-      super.load(rootElement, pathMacroSubstitutor, intern);
+      super.load(rootElement, pathMacroSubstitutor, intern)
     }
 
-    @SuppressWarnings("UnusedParameters")
-    protected void convert(Element root, int originalVersion) {
+    @suppress("UNUSED_PARAMETER")
+    protected fun convert(root: Element, originalVersion: Int) {
     }
 
-    @Override
-    public StorageData clone() {
-      return new IprStorageData(this);
+    override fun clone(): StorageData {
+      return IprStorageData(this)
     }
   }
 
-  @Override
-  protected final List<Throwable> doSave(@Nullable List<SaveSession> saveSessions, @NotNull List<Pair<SaveSession, VirtualFile>> readonlyFiles, @Nullable List<Throwable> errors) {
-    beforeSave(readonlyFiles);
+  override fun doSave(saveSessions: List<SaveSession>?, readonlyFiles: MutableList<Pair<SaveSession, VirtualFile>>, prevErrors: MutableList<Throwable>?): MutableList<Throwable>? {
+    var errors = prevErrors
+    beforeSave(readonlyFiles)
 
-    super.doSave(saveSessions, readonlyFiles, errors);
+    super<BaseFileConfigurableStoreImpl>.doSave(saveSessions, readonlyFiles, errors)
 
-    UnableToSaveProjectNotification[] notifications =
-      NotificationsManager.getNotificationsManager().getNotificationsOfType(UnableToSaveProjectNotification.class, myProject);
+    val notifications = NotificationsManager.getNotificationsManager().getNotificationsOfType(javaClass<UnableToSaveProjectNotification>(), myProject)
     if (readonlyFiles.isEmpty()) {
-      if (notifications.length > 0) {
-        for (UnableToSaveProjectNotification notification : notifications) {
-          notification.expire();
+      if (notifications.size() > 0) {
+        for (notification in notifications) {
+          notification.expire()
         }
       }
-      return errors;
+      return errors
     }
 
-    if (notifications.length > 0) {
-      throw new SaveCancelledException();
+    if (notifications.size() > 0) {
+      throw IComponentStore.SaveCancelledException()
     }
 
-    ReadonlyStatusHandler.OperationStatus status;
-    AccessToken token = ReadAction.start();
+    val status: ReadonlyStatusHandler.OperationStatus
+    val token = ReadAction.start()
     try {
-      status = ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(getFilesList(readonlyFiles));
+      status = ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(*getFilesList(readonlyFiles))
     }
     finally {
-      token.finish();
+      token.finish()
     }
 
     if (status.hasReadonlyFiles()) {
-      dropUnableToSaveProjectNotification(myProject, status.getReadonlyFiles());
-      throw new SaveCancelledException();
+      dropUnableToSaveProjectNotification(myProject, status.getReadonlyFiles())
+      throw IComponentStore.SaveCancelledException()
     }
-    List<Pair<SaveSession, VirtualFile>> oldList = new ArrayList<Pair<SaveSession, VirtualFile>>(readonlyFiles);
-    readonlyFiles.clear();
-    for (Pair<SaveSession, VirtualFile> entry : oldList) {
-      errors = executeSave(entry.first, readonlyFiles, errors);
+    val oldList = ArrayList(readonlyFiles)
+    readonlyFiles.clear()
+    for (entry in oldList) {
+      errors = ComponentStoreImpl.executeSave(entry.first, readonlyFiles, errors)
     }
 
     if (errors != null) {
-      CompoundRuntimeException.doThrow(errors);
+      CompoundRuntimeException.doThrow(errors)
     }
 
     if (!readonlyFiles.isEmpty()) {
-      dropUnableToSaveProjectNotification(myProject, getFilesList(readonlyFiles));
-      throw new SaveCancelledException();
-    }
-
-    return errors;
-  }
-
-  private static void dropUnableToSaveProjectNotification(@NotNull Project project, @NotNull VirtualFile[] readOnlyFiles) {
-    UnableToSaveProjectNotification[] notifications =
-      NotificationsManager.getNotificationsManager().getNotificationsOfType(UnableToSaveProjectNotification.class, project);
-    if (notifications.length == 0) {
-      Notifications.Bus.notify(new UnableToSaveProjectNotification(project, readOnlyFiles), project);
-    }
-    else {
-      notifications[0].myFiles = readOnlyFiles;
+      dropUnableToSaveProjectNotification(myProject, getFilesList(readonlyFiles))
+      throw IComponentStore.SaveCancelledException()
     }
-  }
 
-  protected void beforeSave(@NotNull List<Pair<SaveSession, VirtualFile>> readonlyFiles) {
+    return errors
   }
 
-  @NotNull
-  private static VirtualFile[] getFilesList(List<Pair<SaveSession, VirtualFile>> readonlyFiles) {
-    final VirtualFile[] files = new VirtualFile[readonlyFiles.size()];
-    for (int i = 0, size = readonlyFiles.size(); i < size; i++) {
-      files[i] = readonlyFiles.get(i).second;
-    }
-    return files;
+  protected open fun beforeSave(readonlyFiles: List<Pair<SaveSession, VirtualFile>>) {
   }
 
-  private final StateStorageChooser<PersistentStateComponent<?>> myStateStorageChooser = new StateStorageChooser<PersistentStateComponent<?>>() {
-    @NotNull
-    @Override
-    public Storage[] selectStorages(@NotNull Storage[] storages, @NotNull PersistentStateComponent<?> component, @NotNull StateStorageOperation operation) {
-      if (operation == StateStorageOperation.READ) {
-        List<Storage> result = new SmartList<Storage>();
-        for (int i = storages.length - 1; i >= 0; i--) {
-          Storage storage = storages[i];
-          if (storage.scheme() == myScheme) {
-            result.add(storage);
+  private val myStateStorageChooser = object : StateStorageChooser<PersistentStateComponent<*>> {
+    override fun selectStorages(storages: Array<Storage>, component: PersistentStateComponent<*>, operation: StateStorageOperation): Array<Storage> {
+      if (operation === StateStorageOperation.READ) {
+        val result = SmartList<Storage>()
+        for (i in storages.indices.reversed()) {
+          val storage = storages[i]
+          if (storage.scheme === myScheme) {
+            result.add(storage)
           }
         }
 
-        for (Storage storage : storages) {
-          if (storage.scheme() == StorageScheme.DEFAULT && !result.contains(storage)) {
-            result.add(storage);
+        for (storage in storages) {
+          if (storage.scheme === StorageScheme.DEFAULT && !result.contains(storage)) {
+            result.add(storage)
           }
         }
 
-        return result.toArray(new Storage[result.size()]);
+        return result.toArray<Storage>(arrayOfNulls<Storage>(result.size()))
       }
-      else if (operation == StateStorageOperation.WRITE) {
-        List<Storage> result = new SmartList<Storage>();
-        for (Storage storage : storages) {
-          if (storage.scheme() == myScheme) {
-            result.add(storage);
+      else if (operation === StateStorageOperation.WRITE) {
+        val result = SmartList<Storage>()
+        for (storage in storages) {
+          if (storage.scheme === myScheme) {
+            result.add(storage)
           }
         }
 
         if (!result.isEmpty()) {
-          return result.toArray(new Storage[result.size()]);
+          return result.toArray<Storage>(arrayOfNulls<Storage>(result.size()))
         }
 
-        for (Storage storage : storages) {
-          if (storage.scheme() == StorageScheme.DEFAULT) {
-            result.add(storage);
+        for (storage in storages) {
+          if (storage.scheme === StorageScheme.DEFAULT) {
+            result.add(storage)
           }
         }
 
-        return result.toArray(new Storage[result.size()]);
+        return result.toArray<Storage>(arrayOfNulls<Storage>(result.size()))
       }
       else {
-        return new Storage[]{};
+        return arrayOf()
       }
     }
-  };
+  }
 
-  @Override
-  protected StateStorageChooser<PersistentStateComponent<?>> getDefaultStateStorageChooser() {
-    return myStateStorageChooser;
+  override fun getDefaultStateStorageChooser(): StateStorageChooser<PersistentStateComponent<*>>? {
+    return myStateStorageChooser
   }
 
-  @NotNull
-  @Override
-  protected MessageBus getMessageBus() {
-    return myProject.getMessageBus();
+  override fun getMessageBus(): MessageBus {
+    return myProject.getMessageBus()
   }
 
-  @NotNull
-  @Override
-  protected <T> Storage[] getComponentStorageSpecs(@NotNull PersistentStateComponent<T> component,
-                                                   @NotNull State stateSpec,
-                                                   @NotNull StateStorageOperation operation) {
+  override fun <T> getComponentStorageSpecs(component: PersistentStateComponent<T>, stateSpec: State, operation: StateStorageOperation): Array<Storage> {
     // if we create project from default, component state written not to own storage file, but to project file,
     // we don't have time to fix it properly, so, ancient hack restored.
-    Storage[] result = super.getComponentStorageSpecs(component, stateSpec, operation);
+    val result = super<BaseFileConfigurableStoreImpl>.getComponentStorageSpecs(component, stateSpec, operation)
     // don't add fake storage if project file storage already listed, otherwise data will be deleted on write (because of "deprecated")
-    for (Storage storage : result) {
-      if (storage.file().equals(StoragePathMacros.PROJECT_FILE)) {
-        return result;
+    for (storage in result) {
+      if (storage.file == StoragePathMacros.PROJECT_FILE) {
+        return result
       }
     }
-
-    Storage[] withProjectFileStorage = new Storage[result.length + 1];
-    System.arraycopy(result, 0, withProjectFileStorage, 0, result.length);
-    withProjectFileStorage[result.length] = DEFAULT_STORAGE_ANNOTATION;
-    return withProjectFileStorage;
+    return Array(result.size() + 1) { if (it == result.size()) DEFAULT_STORAGE_ANNOTATION else result[it] }
   }
 
-  @SuppressWarnings("ClassExplicitlyAnnotation")
-  private static class MyStorage implements Storage {
-    @Override
-    public String id() {
-      return "___Default___";
-    }
+  companion object {
+    private val DEFAULT_STORAGE_ANNOTATION = DefaultStorageAnnotation()
 
-    @Override
-    public boolean isDefault() {
-      return true;
-    }
+    private val OLD_PROJECT_SUFFIX = "_old."
 
-    @Override
-    public String file() {
-      return StoragePathMacros.PROJECT_FILE;
-    }
+    private var originalVersion = -1
 
-    @Override
-    public StorageScheme scheme() {
-      return StorageScheme.DEFAULT;
-    }
+    private fun isIprPath(file: File) = FileUtilRt.extensionEquals(file.getName(), ProjectFileType.DEFAULT_EXTENSION)
 
-    @Override
-    public boolean deprecated() {
-      return true;
+    private fun composeWsPath(filePath: String): String {
+      val lastDot = filePath.lastIndexOf('.')
+      val filePathWithoutExt = if (lastDot > 0) filePath.substring(0, lastDot) else filePath
+      return "$filePathWithoutExt${WorkspaceFileType.DOT_DEFAULT_EXTENSION}"
     }
 
-    @Override
-    public RoamingType roamingType() {
-      return RoamingType.PER_USER;
-    }
+    private fun useOldWsContent(filePath: String, ws: File) {
+      val oldWs = File(composeWsPath(filePath))
+      if (!oldWs.exists()) {
+        return
+      }
 
-    @Override
-    public Class<? extends StateStorage> storageClass() {
-      return StateStorage.class;
+      try {
+        FileUtil.copyContent(oldWs, ws)
+      }
+      catch (e: IOException) {
+        LOG.error(e)
+      }
     }
 
-    @Override
-    public Class<StateSplitterEx> stateSplitter() {
-      return StateSplitterEx.class;
+    private fun dropUnableToSaveProjectNotification(project: Project, readOnlyFiles: Array<VirtualFile>) {
+      val notifications = NotificationsManager.getNotificationsManager().getNotificationsOfType(javaClass<UnableToSaveProjectNotification>(), project)
+      if (notifications.isEmpty()) {
+        Notifications.Bus.notify(UnableToSaveProjectNotification(project, readOnlyFiles), project)
+      }
+      else {
+        notifications[0].myFiles = readOnlyFiles
+      }
     }
 
-    @NotNull
-    @Override
-    public Class<? extends Annotation> annotationType() {
-      throw new UnsupportedOperationException("Method annotationType not implemented in " + getClass());
-    }
+    private fun getFilesList(readonlyFiles: List<Pair<SaveSession, VirtualFile>>) = Array(readonlyFiles.size()) { readonlyFiles.get(it).second }
   }
 }
index 68a97cd0b2ce0269a2b6b5ed15db92c218fe7a95..b44a5d647a119e925872a128b3fa4a85cb0b58bf 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.configurationStore
 
-import com.intellij.openapi.components.PathMacroManager;
-import com.intellij.openapi.components.StateStorage;
-import com.intellij.openapi.components.StateStorage.SaveSession;
-import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.project.impl.ProjectImpl;
-import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.SmartList;
-import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.NotNull;
+import com.intellij.openapi.components.PathMacroManager
+import com.intellij.openapi.components.StateStorage
+import com.intellij.openapi.components.StateStorage.SaveSession
+import com.intellij.openapi.components.TrackingPathMacroSubstitutor
+import com.intellij.openapi.components.impl.stores.IComponentStore
+import com.intellij.openapi.module.Module
+import com.intellij.openapi.module.ModuleManager
+import com.intellij.openapi.project.impl.ProjectImpl
+import com.intellij.openapi.util.Pair
+import com.intellij.openapi.vfs.VirtualFile
+import com.intellij.util.SmartList
+import com.intellij.util.containers.ContainerUtil
 
-import java.util.List;
-import java.util.Set;
+public class ProjectWithModulesStoreImpl(project: ProjectImpl, pathMacroManager: PathMacroManager) : ProjectStoreImpl(project, pathMacroManager) {
 
-public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
-  public ProjectWithModulesStoreImpl(@NotNull ProjectImpl project, @NotNull PathMacroManager pathMacroManager) {
-    super(project, pathMacroManager);
-  }
-
-  @Override
-  public boolean reinitComponent(@NotNull String componentName, @NotNull Set<StateStorage> changedStorages) {
+  override fun reinitComponent(componentName: String, changedStorages: Set<StateStorage>): Boolean {
     if (super.reinitComponent(componentName, changedStorages)) {
-      return true;
+      return true
     }
 
-    for (Module module : getPersistentModules()) {
+    for (module in getPersistentModules()) {
       // we have to reinit all modules for component because we don't know affected module
-      getComponentStore(module).reinitComponent(componentName, changedStorages);
+      getComponentStore(module).reinitComponent(componentName, changedStorages)
     }
-    return true;
+    return true
   }
 
-  @NotNull
-  private static IComponentStore getComponentStore(@NotNull Module module) {
-    return (IComponentStore)module.getPicoContainer().getComponentInstance(IComponentStore.class);
+  private fun getComponentStore(module: Module): IComponentStore {
+    return module.getPicoContainer().getComponentInstance(javaClass<IComponentStore>()) as IComponentStore
   }
 
-  @NotNull
-  @Override
-  public TrackingPathMacroSubstitutor[] getSubstitutors() {
-    List<TrackingPathMacroSubstitutor> result = new SmartList<TrackingPathMacroSubstitutor>();
-    ContainerUtil.addIfNotNull(result, getStateStorageManager().getMacroSubstitutor());
+  override fun getSubstitutors(): Array<TrackingPathMacroSubstitutor> {
+    val result = SmartList<TrackingPathMacroSubstitutor>()
+    ContainerUtil.addIfNotNull(result, getStateStorageManager().getMacroSubstitutor())
 
-    for (Module module : getPersistentModules()) {
-      ContainerUtil.addIfNotNull(result, getComponentStore(module).getStateStorageManager().getMacroSubstitutor());
+    for (module in getPersistentModules()) {
+      ContainerUtil.addIfNotNull(result, getComponentStore(module).getStateStorageManager().getMacroSubstitutor())
     }
 
-    return result.toArray(new TrackingPathMacroSubstitutor[result.size()]);
+    return result.toArray<TrackingPathMacroSubstitutor>(arrayOfNulls<TrackingPathMacroSubstitutor>(result.size()))
   }
 
-  @Override
-  public boolean isReloadPossible(@NotNull Set<String> componentNames) {
+  override fun isReloadPossible(componentNames: Set<String>): Boolean {
     if (!super.isReloadPossible(componentNames)) {
-      return false;
+      return false
     }
 
-    for (Module module : getPersistentModules()) {
+    for (module in getPersistentModules()) {
       if (!getComponentStore(module).isReloadPossible(componentNames)) {
-        return false;
+        return false
       }
     }
 
-    return true;
+    return true
   }
 
-  @NotNull
-  protected Module[] getPersistentModules() {
-    ModuleManager moduleManager = ModuleManager.getInstance(myProject);
-    return moduleManager == null ? Module.EMPTY_ARRAY : moduleManager.getModules();
+  protected fun getPersistentModules(): Array<Module> {
+    val moduleManager = ModuleManager.getInstance(myProject)
+    return if (moduleManager == null) Module.EMPTY_ARRAY else moduleManager.getModules()
   }
 
-  @Override
-  protected void beforeSave(@NotNull List<Pair<SaveSession, VirtualFile>> readonlyFiles) {
-    super.beforeSave(readonlyFiles);
+  override protected fun beforeSave(readonlyFiles: List<Pair<SaveSession, VirtualFile>>) {
+    super.beforeSave(readonlyFiles)
 
-    for (Module module : getPersistentModules()) {
-      getComponentStore(module).save(readonlyFiles);
+    for (module in getPersistentModules()) {
+      getComponentStore(module).save(readonlyFiles)
     }
   }
 }
index 71bd942fb47f9aa7116777a821573056ad84143d..5651f7a6ba9042f2656159329936077af89f4121 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
-
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.StateStorage.SaveSession;
-import com.intellij.openapi.components.StateStorageChooserEx.Resolution;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.util.Couple;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.RoamingTypeDisabled;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.PathUtilRt;
-import com.intellij.util.ReflectionUtil;
-import com.intellij.util.SmartList;
-import com.intellij.util.containers.ContainerUtil;
-import gnu.trove.THashMap;
-import org.jdom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.picocontainer.MutablePicoContainer;
-import org.picocontainer.PicoContainer;
-
-import java.io.File;
-import java.util.*;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public abstract class StateStorageManagerImpl implements StateStorageManager, Disposable {
-  private static final Logger LOG = Logger.getInstance(StateStorageManagerImpl.class);
-
-  private final Map<String, String> myMacros = new LinkedHashMap<String, String>();
-  private final Lock myStorageLock = new ReentrantLock();
-  private final Map<String, StateStorage> myStorages = new THashMap<String, StateStorage>();
-  private final TrackingPathMacroSubstitutor myPathMacroSubstitutor;
-  private final String myRootTagName;
-  private final PicoContainer myPicoContainer;
-
-  private StreamProvider myStreamProvider;
-
-  public StateStorageManagerImpl(@NotNull TrackingPathMacroSubstitutor pathMacroSubstitutor,
-                                 @NotNull String rootTagName,
-                                 @NotNull Disposable parentDisposable,
-                                 @NotNull PicoContainer picoContainer) {
-    myPicoContainer = picoContainer;
-    myRootTagName = rootTagName;
-    myPathMacroSubstitutor = pathMacroSubstitutor;
-    Disposer.register(parentDisposable, this);
+package com.intellij.configurationStore
+
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.components.*
+import com.intellij.openapi.components.StateStorage.SaveSession
+import com.intellij.openapi.components.StateStorageChooserEx.Resolution
+import com.intellij.openapi.components.impl.stores.*
+import com.intellij.openapi.util.Couple
+import com.intellij.openapi.util.Disposer
+import com.intellij.openapi.util.text.StringUtil
+import com.intellij.util.PathUtilRt
+import com.intellij.util.ReflectionUtil
+import com.intellij.util.SmartList
+import com.intellij.util.containers.ContainerUtil
+import gnu.trove.THashMap
+import org.jdom.Element
+import org.picocontainer.MutablePicoContainer
+import org.picocontainer.PicoContainer
+import java.io.File
+import java.util.LinkedHashMap
+import java.util.UUID
+import java.util.concurrent.locks.ReentrantLock
+import java.util.regex.Pattern
+import kotlin.reflect.jvm.java
+
+abstract class StateStorageManagerImpl(private val myPathMacroSubstitutor: TrackingPathMacroSubstitutor, protected val rootTagName: String, parentDisposable: Disposable, private val myPicoContainer: PicoContainer) : StateStorageManager, Disposable {
+  private val myMacros = LinkedHashMap<String, String>()
+  private val myStorageLock = ReentrantLock()
+  private val myStorages = THashMap<String, StateStorage>()
+
+  private var myStreamProvider: StreamProvider? = null
+
+  init {
+    Disposer.register(parentDisposable, this)
   }
 
-  @Override
-  public TrackingPathMacroSubstitutor getMacroSubstitutor() {
-    return myPathMacroSubstitutor;
+  companion object {
+    private val MACRO_PATTERN = Pattern.compile("(\\$[^\\$]*\\$)")
   }
 
-  @Override
-  public synchronized void addMacro(@NotNull String macro, @NotNull String expansion) {
-    assert !macro.isEmpty();
+  override fun getMacroSubstitutor(): TrackingPathMacroSubstitutor? {
+    return myPathMacroSubstitutor
+  }
+
+  synchronized override fun addMacro(macro: String, expansion: String) {
+    var effectiveExpansion = expansion
+    assert(!macro.isEmpty())
     // backward compatibility
     if (macro.charAt(0) != '$') {
-      LOG.warn("Add macros instead of macro name: " + macro);
-      expansion = '$' + macro + '$';
+      LOG.warn("Add macros instead of macro name: " + macro)
+      effectiveExpansion = '$' + macro + '$'
     }
-    myMacros.put(macro, expansion);
+    myMacros.put(macro, effectiveExpansion)
   }
 
-  @Nullable
-  protected final String getMacrosValue(@NotNull String macro) {
-    return myMacros.get(macro);
+  protected fun getMacrosValue(macro: String): String? {
+    return myMacros.get(macro)
   }
 
-  @Override
-  @NotNull
-  public StateStorage getStateStorage(@NotNull Storage storageSpec) {
-    String key = storageSpec.storageClass().equals(StateStorage.class) ? storageSpec.file() : storageSpec.storageClass().getName();
+  override fun getStateStorage(storageSpec: Storage): StateStorage {
+    @suppress("USELESS_CAST")
+    val storageClass = storageSpec.storageClass.java as Class<out StateStorage>
+    val key = if (storageClass == javaClass<StateStorage>()) storageSpec.file else storageClass.getName()
 
-    myStorageLock.lock();
+    myStorageLock.lock()
     try {
-      StateStorage stateStorage = myStorages.get(key);
+      var stateStorage: StateStorage? = myStorages.get(key)
       if (stateStorage == null) {
-        stateStorage = createStateStorage(storageSpec.storageClass(), storageSpec.file(), storageSpec.roamingType(), storageSpec.stateSplitter());
-        myStorages.put(key, stateStorage);
+        stateStorage = createStateStorage(storageClass, storageSpec.file, storageSpec.roamingType, storageSpec.stateSplitter.java)
+        myStorages.put(key, stateStorage)
       }
-      return stateStorage;
+      return stateStorage
     }
     finally {
-      myStorageLock.unlock();
+      myStorageLock.unlock()
     }
   }
 
-  @Nullable
-  @Override
-  public StateStorage getStateStorage(@NotNull String fileSpec, @NotNull RoamingType roamingType) {
-    myStorageLock.lock();
+  override fun getStateStorage(fileSpec: String, roamingType: RoamingType): StateStorage? {
+    myStorageLock.lock()
     try {
-      StateStorage stateStorage = myStorages.get(fileSpec);
+      var stateStorage: StateStorage? = myStorages.get(fileSpec)
       if (stateStorage == null) {
-        stateStorage = createStateStorage(StateStorage.class, fileSpec, roamingType, StateSplitterEx.class);
-        myStorages.put(fileSpec, stateStorage);
+        stateStorage = createStateStorage(javaClass<StateStorage>(), fileSpec, roamingType, javaClass<StateSplitterEx>())
+        myStorages.put(fileSpec, stateStorage)
       }
-      return stateStorage;
+      return stateStorage
     }
     finally {
-      myStorageLock.unlock();
+      myStorageLock.unlock()
     }
   }
 
-  @NotNull
-  @Override
-  public Couple<Collection<FileBasedStorage>> getCachedFileStateStorages(@NotNull Collection<String> changed, @NotNull Collection<String> deleted) {
-    myStorageLock.lock();
+  override fun getCachedFileStateStorages(changed: Collection<String>, deleted: Collection<String>): Couple<Collection<FileBasedStorage>> {
+    myStorageLock.lock()
     try {
-      return Couple.of(getCachedFileStorages(changed), getCachedFileStorages(deleted));
+      return Couple.of(getCachedFileStorages(changed), getCachedFileStorages(deleted))
     }
     finally {
-      myStorageLock.unlock();
+      myStorageLock.unlock()
     }
   }
 
-  @NotNull
-  Collection<FileBasedStorage> getCachedFileStorages(@NotNull Collection<String> fileSpecs) {
+  public fun getCachedFileStorages(fileSpecs: Collection<String>): Collection<FileBasedStorage> {
     if (fileSpecs.isEmpty()) {
-      return Collections.emptyList();
+      return emptyList()
     }
 
-    List<FileBasedStorage> result = null;
-    for (String fileSpec : fileSpecs) {
-      StateStorage storage = myStorages.get(fileSpec);
-      if (storage instanceof FileBasedStorage) {
+    var result: MutableList<FileBasedStorage>? = null
+    for (fileSpec in fileSpecs) {
+      val storage = myStorages.get(fileSpec)
+      if (storage is FileBasedStorage) {
         if (result == null) {
-          result = new SmartList<FileBasedStorage>();
+          result = SmartList<FileBasedStorage>()
         }
-        result.add((FileBasedStorage)storage);
+        result.add(storage)
       }
     }
-    return result == null ? Collections.<FileBasedStorage>emptyList() : result;
+    return if (result == null) emptyList<FileBasedStorage>() else result
   }
 
-  @NotNull
-  @Override
-  public Collection<String> getStorageFileNames() {
-    myStorageLock.lock();
+  override fun getStorageFileNames(): Collection<String> {
+    myStorageLock.lock()
     try {
-      return myStorages.keySet();
+      return myStorages.keySet()
     }
     finally {
-      myStorageLock.unlock();
+      myStorageLock.unlock()
     }
   }
 
   // overridden in upsource
-  protected StateStorage createStateStorage(@NotNull Class<? extends StateStorage> storageClass,
-                                            @NotNull String fileSpec,
-                                            @NotNull RoamingType roamingType,
-                                            @SuppressWarnings("deprecation") @NotNull Class<? extends StateSplitter> stateSplitter) {
-    if (!storageClass.equals(StateStorage.class)) {
-      String key = UUID.randomUUID().toString();
-      ((MutablePicoContainer)myPicoContainer).registerComponentImplementation(key, storageClass);
-      return (StateStorage)myPicoContainer.getComponentInstance(key);
+  protected fun createStateStorage(storageClass: Class<out StateStorage>, fileSpec: String, roamingType: RoamingType, SuppressWarnings("deprecation") stateSplitter: Class<out StateSplitter>): StateStorage {
+    if (storageClass != javaClass<StateStorage>()) {
+      val key = UUID.randomUUID().toString()
+      (myPicoContainer as MutablePicoContainer).registerComponentImplementation(key, storageClass)
+      return myPicoContainer.getComponentInstance(key) as StateStorage
     }
 
-    String filePath = expandMacros(fileSpec);
-    File file = new File(filePath);
+    val filePath = expandMacros(fileSpec)
+    val file = File(filePath)
 
     //noinspection deprecation
-    if (!stateSplitter.equals(StateSplitter.class) && !stateSplitter.equals(StateSplitterEx.class)) {
-      return new DirectoryBasedStorage(myPathMacroSubstitutor, file, ReflectionUtil.newInstance(stateSplitter), this, createStorageTopicListener());
+    if (stateSplitter != javaClass<StateSplitter>() && stateSplitter != javaClass<StateSplitterEx>()) {
+      return DirectoryBasedStorage(myPathMacroSubstitutor, file, ReflectionUtil.newInstance(stateSplitter), this, createStorageTopicListener())
     }
 
     if (!ApplicationManager.getApplication().isHeadlessEnvironment() && PathUtilRt.getFileName(filePath).lastIndexOf('.') < 0) {
-      throw new IllegalArgumentException("Extension is missing for storage file: " + filePath);
-    }
-
-    if (roamingType == RoamingType.PER_USER && fileSpec.equals(StoragePathMacros.WORKSPACE_FILE)) {
-      roamingType = RoamingType.DISABLED;
+      throw IllegalArgumentException("Extension is missing for storage file: " + filePath)
     }
 
-    beforeFileBasedStorageCreate();
-    return new FileBasedStorage(file, fileSpec,
-                                roamingType, getMacroSubstitutor(fileSpec), myRootTagName, StateStorageManagerImpl.this,
-                                createStorageTopicListener(), myStreamProvider) {
-      @Override
-      @NotNull
-      protected StorageData createStorageData() {
-        return StateStorageManagerImpl.this.createStorageData(myFileSpec, getFilePath());
-      }
+    val effectiveRoamingType = if (roamingType == RoamingType.PER_USER && fileSpec == StoragePathMacros.WORKSPACE_FILE) RoamingType.DISABLED else roamingType
+    beforeFileBasedStorageCreate()
+    return object : FileBasedStorage(file, fileSpec, effectiveRoamingType, getMacroSubstitutor(fileSpec), rootTagName, this@StateStorageManagerImpl, createStorageTopicListener(), myStreamProvider) {
+      override fun createStorageData() = this@StateStorageManagerImpl.createStorageData(myFileSpec, getFilePath())
 
-      @Override
-      protected boolean isUseXmlProlog() {
-        return StateStorageManagerImpl.this.isUseXmlProlog();
-      }
-    };
+      override fun isUseXmlProlog() = this@StateStorageManagerImpl.isUseXmlProlog()
+    }
   }
 
-  @Override
-  public void clearStateStorage(@NotNull String file) {
-    myStorageLock.lock();
+  override fun clearStateStorage(file: String) {
+    myStorageLock.lock()
     try {
-      myStorages.remove(file);
+      myStorages.remove(file)
     }
     finally {
-      myStorageLock.unlock();
+      myStorageLock.unlock()
     }
   }
 
-  @Nullable
-  protected StateStorage.Listener createStorageTopicListener() {
-    return null;
-  }
-
-  protected boolean isUseXmlProlog() {
-    return true;
+  protected open fun createStorageTopicListener(): StateStorage.Listener? {
+    return null
   }
 
-  protected void beforeFileBasedStorageCreate() {
-  }
+  protected open fun isUseXmlProlog(): Boolean = true
 
-  @Nullable
-  @Override
-  public final StreamProvider getStreamProvider() {
-    return myStreamProvider;
+  protected open fun beforeFileBasedStorageCreate() {
   }
 
-  protected TrackingPathMacroSubstitutor getMacroSubstitutor(@NotNull String fileSpec) {
-    return myPathMacroSubstitutor;
+  override fun getStreamProvider(): StreamProvider? {
+    return myStreamProvider
   }
 
-  @NotNull
-  protected abstract StorageData createStorageData(@NotNull String fileSpec, @NotNull String filePath);
+  protected open fun getMacroSubstitutor(fileSpec: String): TrackingPathMacroSubstitutor? = myPathMacroSubstitutor
 
-  private static final Pattern MACRO_PATTERN = Pattern.compile("(\\$[^\\$]*\\$)");
+  protected abstract fun createStorageData(fileSpec: String, filePath: String): StorageData
 
-  @Override
-  @NotNull
-  public synchronized String expandMacros(@NotNull String file) {
-    Matcher matcher = MACRO_PATTERN.matcher(file);
+  synchronized override fun expandMacros(file: String): String {
+    val matcher = MACRO_PATTERN.matcher(file)
     while (matcher.find()) {
-      String m = matcher.group(1);
+      val m = matcher.group(1)
       if (!myMacros.containsKey(m)) {
-        throw new IllegalArgumentException("Unknown macro: " + m + " in storage file spec: " + file);
+        throw IllegalArgumentException("Unknown macro: " + m + " in storage file spec: " + file)
       }
     }
 
-    String expanded = file;
-    for (Map.Entry<String, String> entry : myMacros.entrySet()) {
-      expanded = StringUtil.replace(expanded, entry.getKey(), entry.getValue());
+    var expanded = file
+    for (entry in myMacros.entrySet()) {
+      expanded = StringUtil.replace(expanded, entry.getKey(), entry.getValue())
     }
-    return expanded;
+    return expanded
   }
 
-  @NotNull
-  @Override
-  public String collapseMacros(@NotNull String path) {
-    String result = path;
-    for (Map.Entry<String, String> entry : myMacros.entrySet()) {
-      result = StringUtil.replace(result, entry.getValue(), entry.getKey());
+  override fun collapseMacros(path: String): String {
+    var result = path
+    for (entry in myMacros.entrySet()) {
+      result = StringUtil.replace(result, entry.getValue(), entry.getKey())
     }
-    return result;
+    return result
   }
 
-  @NotNull
-  @Override
-  public ExternalizationSession startExternalization() {
-    return new StateStorageManagerExternalizationSession();
-  }
+  override fun startExternalization() = StateStorageManagerExternalizationSession(this)
 
-  protected class StateStorageManagerExternalizationSession implements ExternalizationSession {
-    private final Map<StateStorage, StateStorage.ExternalizationSession> mySessions = new LinkedHashMap<StateStorage, StateStorage.ExternalizationSession>();
+  open class StateStorageManagerExternalizationSession(protected val storageManager: StateStorageManagerImpl) : StateStorageManager.ExternalizationSession {
+    private val mySessions = LinkedHashMap<StateStorage, StateStorage.ExternalizationSession>()
 
-    @Override
-    public void setState(@NotNull Storage[] storageSpecs, @NotNull Object component, @NotNull String componentName, @NotNull Object state) {
-      StateStorageChooserEx stateStorageChooser = component instanceof StateStorageChooserEx ? (StateStorageChooserEx)component : null;
-      for (Storage storageSpec : storageSpecs) {
-        Resolution resolution = stateStorageChooser == null ? Resolution.DO : stateStorageChooser.getResolution(storageSpec, StateStorageOperation.WRITE);
-        if (resolution == Resolution.SKIP) {
-          continue;
+    override fun setState(storageSpecs: Array<Storage>, component: Any, componentName: String, state: Any) {
+      val stateStorageChooser = if (component is StateStorageChooserEx) component else null
+      for (storageSpec in storageSpecs) {
+        val resolution = if (stateStorageChooser == null) Resolution.DO else stateStorageChooser.getResolution(storageSpec, StateStorageOperation.WRITE)
+        if (resolution === Resolution.SKIP) {
+          continue
         }
 
-        StateStorage stateStorage = getStateStorage(storageSpec);
-        StateStorage.ExternalizationSession session = getExternalizationSession(stateStorage);
-        if (session != null) {
-          // empty element as null state, so, will be deleted
-          session.setState(component, componentName, storageSpec.deprecated() || resolution == Resolution.CLEAR ? new Element("empty") : state, storageSpec);
-        }
+        val stateStorage = storageManager.getStateStorage(storageSpec)
+        val session = getExternalizationSession(stateStorage)
+        session?.setState(component, componentName, if (storageSpec.deprecated || resolution === Resolution.CLEAR) Element("empty") else state, storageSpec)
       }
     }
 
-    @Override
-    public void setStateInOldStorage(@NotNull Object component, @NotNull String componentName, @NotNull Object state) {
-      StateStorage stateStorage = getOldStorage(component, componentName, StateStorageOperation.WRITE);
+    override fun setStateInOldStorage(component: Any, componentName: String, state: Any) {
+      val stateStorage = storageManager.getOldStorage(component, componentName, StateStorageOperation.WRITE)
       if (stateStorage != null) {
-        StateStorage.ExternalizationSession session = getExternalizationSession(stateStorage);
-        if (session != null) {
-          session.setState(component, componentName, state, null);
-        }
+        val session = getExternalizationSession(stateStorage)
+        session?.setState(component, componentName, state, null)
       }
     }
 
-    @Nullable
-    protected final StateStorage.ExternalizationSession getExternalizationSession(@NotNull StateStorage stateStorage) {
-      StateStorage.ExternalizationSession session = mySessions.get(stateStorage);
+    protected fun getExternalizationSession(stateStorage: StateStorage): StateStorage.ExternalizationSession? {
+      var session: StateStorage.ExternalizationSession? = mySessions.get(stateStorage)
       if (session == null) {
-        session = stateStorage.startExternalization();
+        session = stateStorage.startExternalization()
         if (session != null) {
-          mySessions.put(stateStorage, session);
+          mySessions.put(stateStorage, session)
         }
       }
-      return session;
+      return session
     }
 
-    @NotNull
-    @Override
-    public List<SaveSession> createSaveSessions() {
+    override fun createSaveSessions(): List<SaveSession> {
       if (mySessions.isEmpty()) {
-        return Collections.emptyList();
+        return emptyList()
       }
 
-      List<SaveSession> saveSessions = null;
-      Collection<StateStorage.ExternalizationSession> externalizationSessions = mySessions.values();
-      for (StateStorage.ExternalizationSession session : externalizationSessions) {
-        SaveSession saveSession = session.createSaveSession();
+      var saveSessions: MutableList<SaveSession>? = null
+      val externalizationSessions = mySessions.values()
+      for (session in externalizationSessions) {
+        val saveSession = session.createSaveSession()
         if (saveSession != null) {
           if (saveSessions == null) {
             if (externalizationSessions.size() == 1) {
-              return Collections.singletonList(saveSession);
+              return listOf(saveSession)
             }
-            saveSessions = new SmartList<SaveSession>();
+            saveSessions = SmartList<SaveSession>()
           }
-          saveSessions.add(saveSession);
+          saveSessions.add(saveSession)
         }
       }
-      return ContainerUtil.notNullize(saveSessions);
+      return ContainerUtil.notNullize(saveSessions)
     }
   }
 
-  @Override
-  @Nullable
-  public StateStorage getOldStorage(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) {
-    String oldStorageSpec = getOldStorageSpec(component, componentName, operation);
-    //noinspection deprecation
-    return oldStorageSpec == null ? null : getStateStorage(oldStorageSpec, component instanceof RoamingTypeDisabled ? RoamingType.DISABLED : RoamingType.PER_USER);
+  override fun getOldStorage(component: Any, componentName: String, operation: StateStorageOperation): StateStorage? {
+    val oldStorageSpec = getOldStorageSpec(component, componentName, operation)
+    @suppress("DEPRECATED_SYMBOL_WITH_MESSAGE")
+    return if (oldStorageSpec == null) null else getStateStorage(oldStorageSpec, if (component is com.intellij.openapi.util.RoamingTypeDisabled) RoamingType.DISABLED else RoamingType.PER_USER)
   }
 
-  @Nullable
-  protected abstract String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation);
+  protected abstract fun getOldStorageSpec(component: Any, componentName: String, operation: StateStorageOperation): String?
 
-  @Override
-  public void dispose() {
+  override fun dispose() {
   }
 
-  @Override
-  public void setStreamProvider(@Nullable StreamProvider streamProvider) {
-    myStreamProvider = streamProvider;
+  override fun setStreamProvider(streamProvider: StreamProvider?) {
+    myStreamProvider = streamProvider
   }
 }
index 92373f89fb91cf9050a05ab3d1998c9ea3c83111..84db0428971ec7ae6aff18662ad19ea442e55673 100644 (file)
@@ -19,13 +19,14 @@ import com.intellij.application.options.PathMacrosImpl
 import com.intellij.openapi.Disposable
 import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.components.*
-import com.intellij.openapi.components.impl.ApplicationPathMacroManager
-import com.intellij.openapi.components.impl.stores.*
+import com.intellij.openapi.components.impl.stores.StateStorageManager
+import com.intellij.openapi.components.impl.stores.StorageData
+import com.intellij.openapi.components.impl.stores.StoreUtil
+import com.intellij.openapi.components.impl.stores.StreamProvider
 import com.intellij.openapi.util.Disposer
 import com.intellij.openapi.util.io.FileUtil
 import com.intellij.openapi.vfs.CharsetToolkit
 import com.intellij.testFramework.LightPlatformTestCase
-import com.intellij.util.messages.MessageBus
 import com.intellij.util.xmlb.XmlSerializerUtil
 import gnu.trove.THashMap
 import org.hamcrest.CoreMatchers.equalTo
@@ -40,7 +41,6 @@ public class ApplicationStoreTest : LightPlatformTestCase() {
   private var testAppConfig: File? = null
   private var componentStore: MyComponentStore? = null
 
-  throws(Exception::class)
   override fun setUp() {
     super.setUp()
 
@@ -56,7 +56,6 @@ public class ApplicationStoreTest : LightPlatformTestCase() {
     componentStore = MyComponentStore(testAppConfig!!.getAbsolutePath())
   }
 
-  throws(Exception::class)
   override fun tearDown() {
     try {
       Disposer.dispose(componentStore!!)
@@ -119,7 +118,6 @@ public class ApplicationStoreTest : LightPlatformTestCase() {
     assertThat(oldFile.exists(), equalTo(false))
   }
 
-  throws(IOException::class)
   private fun saveConfig(fileName: String, Language("XML") data: String): File {
     val file = File(testAppConfig, fileName)
     FileUtil.writeToFile(file, data)
@@ -179,16 +177,12 @@ public class ApplicationStoreTest : LightPlatformTestCase() {
       stateStorageManager.addMacro(StoragePathMacros.APP_CONFIG, testAppConfigPath)
     }
 
-    override fun getStateStorageManager(): StateStorageManager {
-      return stateStorageManager
-    }
+    override fun getStateStorageManager() = stateStorageManager
 
     override fun dispose() {
     }
 
-    override fun getMessageBus(): MessageBus {
-      return ApplicationManager.getApplication().getMessageBus()
-    }
+    override fun getMessageBus() = ApplicationManager.getApplication().getMessageBus()
   }
 
   abstract class Foo {
@@ -208,9 +202,7 @@ public class ApplicationStoreTest : LightPlatformTestCase() {
 
   State(name = "HttpConfigurable", storages = arrayOf(Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml", deprecated = true), Storage(file = StoragePathMacros.APP_CONFIG + "/proxy.settings.xml")))
   class ActualStorageLast : Foo(), PersistentStateComponent<ActualStorageLast> {
-    override fun getState(): ActualStorageLast? {
-      return this
-    }
+    override fun getState() = this
 
     override fun loadState(state: ActualStorageLast) {
       XmlSerializerUtil.copyBean(state, this)
diff --git a/platform/configuration-store-impl/testSrc/com/intellij/openapi/components/impl/StateStorageManagerImplTest.java b/platform/configuration-store-impl/testSrc/com/intellij/openapi/components/impl/StateStorageManagerImplTest.java
deleted file mode 100644 (file)
index 9e0beb7..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2000-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.openapi.components.impl;
-
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.impl.stores.StateStorageManagerImpl;
-import com.intellij.openapi.components.impl.stores.StorageData;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.testFramework.LightPlatformTestCase;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author mike
- */
-public class StateStorageManagerImplTest extends LightPlatformTestCase {
-  private StateStorageManagerImpl myStateStorageManager;
-
-  @Override
-  public final void setUp() throws Exception {
-    super.setUp();
-    TrackingPathMacroSubstitutor substitutor = PathMacroManager.getInstance(getProject()).createTrackingSubstitutor();
-    myStateStorageManager = new StateStorageManagerImpl(substitutor, "foo", myTestRootDisposable, ApplicationManager.getApplication().getPicoContainer()) {
-      @NotNull
-      @Override
-      protected StorageData createStorageData(@NotNull String fileSpec, @NotNull String filePath) {
-        throw new UnsupportedOperationException("Method createStorageData not implemented in " + getClass());
-      }
-
-      @Nullable
-      @Override
-      protected String getOldStorageSpec(@NotNull Object component, @NotNull String componentName, @NotNull StateStorageOperation operation) {
-        throw new UnsupportedOperationException("Method getOldStorageSpec not implemented in " + getClass());
-      }
-    };
-    myStateStorageManager.addMacro("$MACRO1$", "/temp/m1");
-  }
-
-  @Override
-  public void tearDown() throws Exception {
-    Disposer.dispose(myStateStorageManager);
-    super.tearDown();
-  }
-
-  public void testCreateFileStateStorageMacroSubstituted() {
-    StateStorage data = myStateStorageManager.getStateStorage("$MACRO1$/test.xml", RoamingType.PER_USER);
-    assertThat(data, is(notNullValue()));
-  }
-
-  public void testCreateStateStorageAssertionThrownWhenUnknownMacro() {
-    try {
-      myStateStorageManager.getStateStorage("$UNKNOWN_MACRO$/test.xml", RoamingType.PER_USER);
-      fail("Exception expected");
-    }
-    catch (IllegalArgumentException e) {
-      assertEquals("Unknown macro: $UNKNOWN_MACRO$ in storage file spec: $UNKNOWN_MACRO$/test.xml", e.getMessage());
-    }
-  }
-
-  public void testCreateFileStateStorageMacroSubstitutedWhenExpansionHas$() {
-    myStateStorageManager.addMacro("$DOLLAR_MACRO$", "/temp/d$");
-    StateStorage data = myStateStorageManager.getStateStorage("$DOLLAR_MACRO$/test.xml", RoamingType.PER_USER);
-    assertThat(data, is(notNullValue()));
-  }
-}
diff --git a/platform/configuration-store-impl/testSrc/com/intellij/openapi/components/impl/StateStorageManagerImplTest.kt b/platform/configuration-store-impl/testSrc/com/intellij/openapi/components/impl/StateStorageManagerImplTest.kt
new file mode 100644 (file)
index 0000000..7a2fa5d
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.components.impl
+
+import com.intellij.configurationStore.StateStorageManagerImpl
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.components.PathMacroManager
+import com.intellij.openapi.components.RoamingType
+import com.intellij.openapi.components.StateStorage
+import com.intellij.openapi.components.StateStorageOperation
+import com.intellij.openapi.components.impl.stores.StorageData
+import com.intellij.openapi.util.Disposer
+import com.intellij.testFramework.LightPlatformTestCase
+import junit.framework.TestCase
+import org.hamcrest.CoreMatchers.`is`
+import org.hamcrest.CoreMatchers.notNullValue
+import org.junit.Assert.assertThat
+
+/**
+ * @author mike
+ */
+public class StateStorageManagerImplTest : LightPlatformTestCase() {
+  private var myStateStorageManager: StateStorageManagerImpl? = null
+
+  override fun setUp() {
+    super.setUp()
+    val substitutor = PathMacroManager.getInstance(LightPlatformTestCase.getProject()).createTrackingSubstitutor()
+    myStateStorageManager = object : StateStorageManagerImpl(substitutor, "foo", myTestRootDisposable, ApplicationManager.getApplication().getPicoContainer()) {
+      override fun createStorageData(fileSpec: String, filePath: String): StorageData {
+        throw UnsupportedOperationException("Method createStorageData not implemented in " + javaClass)
+      }
+
+      override fun getOldStorageSpec(component: Any, componentName: String, operation: StateStorageOperation): String? {
+        throw UnsupportedOperationException("Method getOldStorageSpec not implemented in " + javaClass)
+      }
+    }
+    myStateStorageManager!!.addMacro("\$MACRO1$", "/temp/m1")
+  }
+
+  override fun tearDown() {
+    try {
+      val storageManager = myStateStorageManager
+      if (storageManager != null) {
+        Disposer.dispose(storageManager)
+      }
+    }
+    finally {
+      super.tearDown()
+    }
+  }
+
+  public fun testCreateFileStateStorageMacroSubstituted() {
+    val data = myStateStorageManager!!.getStateStorage("\$MACRO1$/test.xml", RoamingType.PER_USER)
+    assertThat<StateStorage>(data, `is`(notNullValue()))
+  }
+
+  public fun testCreateStateStorageAssertionThrownWhenUnknownMacro() {
+    try {
+      myStateStorageManager!!.getStateStorage("\$UNKNOWN_MACRO$/test.xml", RoamingType.PER_USER)
+      TestCase.fail("Exception expected")
+    }
+    catch (e: IllegalArgumentException) {
+      TestCase.assertEquals("Unknown macro: \$UNKNOWN_MACRO$ in storage file spec: \$UNKNOWN_MACRO$/test.xml", e.getMessage())
+    }
+
+  }
+
+  public fun `testCreateFileStateStorageMacroSubstitutedWhenExpansionHas$`() {
+    myStateStorageManager!!.addMacro("\$DOLLAR_MACRO$", "/temp/d$")
+    val data = myStateStorageManager!!.getStateStorage("\$DOLLAR_MACRO$/test.xml", RoamingType.PER_USER)
+    assertThat<StateStorage>(data, `is`(notNullValue()))
+  }
+}
index 97208bb9feda9aa526bcb98a44411b9cc2e9473d..d484b268c58e4e1b74c16297d87da4404ad13a18 100644 (file)
@@ -1003,9 +1003,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt
   @Override
   public void loadState(Element state) {
     myDefaultProjectRootElement = state.getChild("defaultProject");
-    if (myDefaultProjectRootElement != null) {
-      myDefaultProjectRootElement.detach();
-    }
+    if (myDefaultProjectRootElement != null) myDefaultProjectRootElement.detach();
     myDefaultProjectConfigurationChanged = false;
   }
 
index f137a0fdea50fa722f0c4d828a0dde601227ff05..e61038b86e601df1ed36e2e6505816d4b412d2a3 100644 (file)
     <projectService serviceInterface="com.intellij.openapi.roots.impl.LibraryScopeCache"
                     serviceImplementation="com.intellij.openapi.roots.impl.LibraryScopeCache"/>
 
-    <moduleService serviceInterface="com.intellij.openapi.components.impl.stores.IComponentStore" serviceImplementation="com.intellij.openapi.components.impl.stores.ModuleStoreImpl"/>
+    <moduleService serviceInterface="com.intellij.openapi.components.impl.stores.IComponentStore" serviceImplementation="com.intellij.configurationStore.ModuleStoreImpl"/>
     <moduleService serviceInterface="com.intellij.openapi.components.PathMacroManager" serviceImplementation="com.intellij.openapi.components.impl.ModulePathMacroManager"/>
 
     <projectViewPane implementation="com.intellij.ide.scratch.ScratchProjectViewPane"/>
index 2aa9f08d34bccd7c15b6e5ad950f95cab8538897..f7085b0139c9f179fc1daebdd9b612f6f9a31930 100644 (file)
@@ -7,9 +7,9 @@
     <appStarter implementation="com.intellij.help.impl.KeymapGenerator"/>
 
     <applicationService serviceInterface="com.intellij.openapi.components.impl.stores.IComponentStore"
-                        serviceImplementation="com.intellij.openapi.components.impl.stores.ApplicationStoreImpl"/>
+                        serviceImplementation="com.intellij.configurationStore.ApplicationStoreImpl"/>
     <applicationService serviceInterface="com.intellij.openapi.components.PathMacroManager"
-                        serviceImplementation="com.intellij.openapi.components.impl.ApplicationPathMacroManager"/>
+                        serviceImplementation="com.intellij.configurationStore.ApplicationPathMacroManager"/>
 
     <applicationService serviceImplementation="com.intellij.ide.GeneralSettings"/>
     <applicationService serviceInterface="com.intellij.ide.util.PropertiesComponent"
index 8aa305c4c939dccedd70ca030e19e4477458893b..4902b107dc2132815e09b78c9ec648b46936ebe0 100644 (file)
@@ -13,7 +13,7 @@
     </component>
     <component>
       <interface-class>com.intellij.openapi.project.impl.ProjectStoreClassProvider</interface-class>
-      <implementation-class>com.intellij.openapi.components.impl.stores.PlatformProjectStoreClassProvider</implementation-class>
+      <implementation-class>com.intellij.configurationStore.PlatformProjectStoreClassProvider</implementation-class>
     </component>
   </application-components>
   <project-components>
index dc70e3968008ef144f34af420c3fbb16d6f13dd9..71a06a1b1b8fb6338d6c807dfcd4c711a8af18d3 100644 (file)
@@ -13,7 +13,7 @@
     </component>
     <component>
       <interface-class>com.intellij.openapi.project.impl.ProjectStoreClassProvider</interface-class>
-      <implementation-class>com.intellij.openapi.components.impl.stores.PlatformLangProjectStoreClassProvider</implementation-class>
+      <implementation-class>com.intellij.configurationStore.PlatformLangProjectStoreClassProvider</implementation-class>
     </component>
   </application-components>
   <project-components>
index 02eccd2fad3e1c4d99bbcd884370ab878a5a8e32..7b99fb2a1d8b3daf2516b9ac59ed9d7ffbfcb0e9 100644 (file)
@@ -55,7 +55,7 @@ public class StorageData extends StorageDataBase {
     myRootElementName = rootElementName;
   }
 
-  StorageData(@NotNull StorageData storageData) {
+  protected StorageData(@NotNull StorageData storageData) {
     myRootElementName = storageData.myRootElementName;
     myStates = new StateMap(storageData.myStates);
   }
index 15d65183610a1d5303d3ee17fc0eaa6b77fb4041..51772d3cd4f2f86df18d3d61a879847c7bda2adf 100644 (file)
  */
 package org.jetbrains.settingsRepository
 
+import com.intellij.configurationStore.ComponentStoreImpl
 import com.intellij.configurationStore.SchemeManagerFactoryBase
 import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.application.WriteAction
 import com.intellij.openapi.application.impl.ApplicationImpl
-import com.intellij.openapi.components.impl.stores.ComponentStoreImpl
 import com.intellij.openapi.components.impl.stores.FileBasedStorage
 import com.intellij.openapi.components.impl.stores.IComponentStore
 import com.intellij.openapi.components.impl.stores.StoreUtil
index 919f5befbe424ad1de0cd972695f5d98781081ed..028753cb3a35ad37d0d2c53d302062514ea6f81a 100644 (file)
@@ -16,7 +16,7 @@
     </component>
     <component>
       <interface-class>com.intellij.openapi.project.impl.ProjectStoreClassProvider</interface-class>
-      <implementation-class>com.intellij.openapi.components.impl.stores.PlatformLangProjectStoreClassProvider</implementation-class>
+      <implementation-class>com.intellij.configurationStore.PlatformLangProjectStoreClassProvider</implementation-class>
     </component>
   </application-components>
   <project-components>