ProjectInspectionProfileManagerImpl — isUseOldFileNameSanitize because directory...
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 24 Jun 2016 15:49:51 +0000 (17:49 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 24 Jun 2016 15:49:51 +0000 (17:49 +0200)
enable saving.state.in.new.format.is.allowed

18 files changed:
java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java
java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelProjectExtensionImpl.java
java/java-tests/java-tests.iml
java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt [new file with mode: 0644]
jps/model-serialization/src/org/jetbrains/jps/model/serialization/java/compiler/AnnotationProcessorProfileSerializer.java
platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java
platform/analysis-api/src/com/intellij/psi/search/scope/packageSet/NamedScopesHolder.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java
platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManagerImpl.kt
platform/configuration-store-impl/src/DirectoryBasedStorage.kt
platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt
platform/configuration-store-impl/src/SchemeManagerImpl.kt
platform/configuration-store-impl/testSrc/ProjectStoreTest.kt
platform/core-api/src/com/intellij/openapi/options/scheme.kt
platform/testFramework/src/com/intellij/testFramework/MockSchemeManagerFactory.java
platform/util/resources/misc/registry.properties
platform/util/src/com/intellij/openapi/util/io/FileUtil.java
platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/ProjectLevelVcsManagerSerialization.java

index 4d8bd26f32eeebf4e4d846cd27f9dc7646679b83..6dbe74da781d61401ebbdecb133e8887596114a1 100644 (file)
@@ -139,7 +139,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
 
   @Override
   public Element getState() {
-    final boolean savingStateInNewFormatAllowed = Registry.is("saving.state.in.new.format.is.allowed", false);
+    final boolean savingStateInNewFormatAllowed = Registry.is("saving.state.in.new.format.is.allowed", true);
 
     Element state = new Element("state");
     XmlSerializer.serializeInto(myState, state, new SkipDefaultValuesSerializationFilters() {
index 76ef138fa2dad408af554022f0770d5cffe8b6f3..21f6ebcaa1c123f30607d67fc3a4f55f22397bc1 100644 (file)
@@ -54,7 +54,7 @@ public class LanguageLevelProjectExtensionImpl extends LanguageLevelProjectExten
   private void readExternal(final Element element) {
     String level = element.getAttributeValue(LANGUAGE_LEVEL);
     if (level == null) {
-      myLanguageLevel = Registry.is("saving.state.in.new.format.is.allowed", false) ? null : migrateFromIdea7(element);
+      myLanguageLevel = Registry.is("saving.state.in.new.format.is.allowed", true) ? null : migrateFromIdea7(element);
     }
     else {
       myLanguageLevel = LanguageLevel.valueOf(level);
@@ -86,7 +86,7 @@ public class LanguageLevelProjectExtensionImpl extends LanguageLevelProjectExten
       element.setAttribute(DEFAULT_ATTRIBUTE, Boolean.toString(aBoolean));
     }
 
-    if (!Registry.is("saving.state.in.new.format.is.allowed", false)) {
+    if (!Registry.is("saving.state.in.new.format.is.allowed", true)) {
       writeAttributesForIdea7(element);
     }
   }
index 8636261ec2588db3ac101c2c20a2cb9e9253b7c7..1f39eba6946c1c26c012f67d73fdfc73eb15684f 100644 (file)
@@ -55,5 +55,6 @@
     <orderEntry type="module" module-name="built-in-server-api" scope="TEST" />
     <orderEntry type="module" module-name="configuration-store-impl" scope="TEST" />
     <orderEntry type="library" scope="TEST" name="memoryfilesystem" level="project" />
+    <orderEntry type="module" module-name="configuration-store-tests" scope="TEST" />
   </component>
 </module>
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt b/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt
new file mode 100644 (file)
index 0000000..4a25269
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2000-2016 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.codeInspection.ex
+
+import com.intellij.configurationStore.PROJECT_CONFIG_DIR
+import com.intellij.configurationStore.StoreAwareProjectManager
+import com.intellij.configurationStore.loadAndUseProject
+import com.intellij.configurationStore.saveStore
+import com.intellij.openapi.components.stateStore
+import com.intellij.openapi.project.ProjectManager
+import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImpl
+import com.intellij.testFramework.Assertions.assertThat
+import com.intellij.testFramework.ProjectRule
+import com.intellij.testFramework.RuleChain
+import com.intellij.testFramework.TemporaryDirectory
+import com.intellij.util.delete
+import com.intellij.util.readText
+import com.intellij.util.write
+import org.junit.ClassRule
+import org.junit.Rule
+import org.junit.Test
+import java.nio.file.Paths
+
+internal class ProjectInspectionManagerTest {
+  companion object {
+    @JvmField
+    @ClassRule
+    val projectRule = ProjectRule()
+  }
+
+  val tempDirManager = TemporaryDirectory()
+
+  private val ruleChain = RuleChain(tempDirManager)
+  @Rule fun getChain() = ruleChain
+
+  @Test fun `component`() {
+    loadAndUseProject(tempDirManager, {
+      it.path
+    }) { project ->
+      val projectInspectionProfileManager = ProjectInspectionProfileManagerImpl.getInstanceImpl(project)
+
+      assertThat(projectInspectionProfileManager.state).isEmpty()
+
+      projectInspectionProfileManager.currentProfile
+
+      assertThat(projectInspectionProfileManager.state).isEmpty()
+
+      // cause to use app profile
+      projectInspectionProfileManager.setRootProfile(null)
+      val doNotUseProjectProfileState = """
+      <state>
+        <option name="USE_PROJECT_PROFILE" value="false" />
+        <version value="1.0" />
+      </state>""".trimIndent()
+      assertThat(projectInspectionProfileManager.state).isEqualTo(doNotUseProjectProfileState)
+
+      val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles")
+      val file = inspectionDir.resolve("profiles_settings.xml")
+      project.saveStore()
+      assertThat(file).exists()
+      val doNotUseProjectProfileData = """
+      <component name="InspectionProjectProfileManager">
+        <option name="USE_PROJECT_PROFILE" value="false" />
+        <version value="1.0" />
+      </component>""".trimIndent()
+      assertThat(file.readText()).isEqualTo(doNotUseProjectProfileData)
+
+      // test load
+      file.delete()
+
+      project.baseDir.refresh(false, true)
+      (ProjectManager.getInstance() as StoreAwareProjectManager).flushChangedAlarm()
+      assertThat(projectInspectionProfileManager.state).isEmpty()
+
+      file.write(doNotUseProjectProfileData)
+      project.baseDir.refresh(false, true)
+      (ProjectManager.getInstance() as StoreAwareProjectManager).flushChangedAlarm()
+      assertThat(projectInspectionProfileManager.state).isEqualTo(doNotUseProjectProfileState)
+    }
+  }
+
+  @Test fun `profiles`() {
+    loadAndUseProject(tempDirManager, {
+      it.path
+    }) { project ->
+      val projectInspectionProfileManager = ProjectInspectionProfileManagerImpl.getInstanceImpl(project)
+
+      assertThat(projectInspectionProfileManager.state).isEmpty()
+
+      // cause to use app profile
+      val currentProfile = projectInspectionProfileManager.currentProfile
+      assertThat(currentProfile.isProjectLevel).isTrue()
+      InspectionProfileImpl.initAndDo {
+        currentProfile.disableTool("Convert2Diamond", project)
+      }
+
+      project.saveStore()
+
+      val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles")
+      val file = inspectionDir.resolve("profiles_settings.xml")
+
+      assertThat(file).doesNotExist()
+      assertThat(inspectionDir.resolve("Project_Default.xml").readText()).isEqualTo("""
+      <inspections profile_name="Project Default" version="1.0">
+        <option name="myName" value="Project Default" />
+        <inspection_tool class="Convert2Diamond" enabled="false" level="WARNING" enabled_by_default="false" />
+      </inspections>""".trimIndent())
+    }
+  }
+}
\ No newline at end of file
index d4b94d3db6ac48e40a29966cd0f238c88498b9c4..e4125584eaa0a3de4ca66c65e18b94eb5dc90cb6 100644 (file)
@@ -104,7 +104,7 @@ public class AnnotationProcessorProfileSerializer {
 
   public static void writeExternal(@NotNull ProcessorConfigProfile profile, @NotNull Element element) {
     element.setAttribute(NAME, profile.getName());
-    if (!Registry.is("saving.state.in.new.format.is.allowed", false) || profile.isEnabled()) {
+    if (!Registry.is("saving.state.in.new.format.is.allowed", true) || profile.isEnabled()) {
       element.setAttribute(ENABLED, Boolean.toString(profile.isEnabled()));
     }
 
@@ -141,7 +141,7 @@ public class AnnotationProcessorProfileSerializer {
 
 
     Element pathElement = null;
-    if (!Registry.is("saving.state.in.new.format.is.allowed", false) || !profile.isObtainProcessorsFromClasspath()) {
+    if (!Registry.is("saving.state.in.new.format.is.allowed", true) || !profile.isObtainProcessorsFromClasspath()) {
       pathElement = addChild(element, "processorPath");
       pathElement.setAttribute("useClasspath", Boolean.toString(profile.isObtainProcessorsFromClasspath()));
     }
index 187350f69e36baf4d68b098a0205f799bcbcd853..77f4e2fbd859c401afe9108dab7ebd29920e5b79 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -64,7 +64,7 @@ public class ScopeToolState {
   }
 
   @Nullable
-  public NamedScope getScope(Project project) {
+  public NamedScope getScope(@Nullable Project project) {
     if (myScope == null && project != null) {
       myScope = NamedScopesHolder.getScope(project, myScopeName);
     }
index af943460bbe4addd37a62b013f1705b4054b72eb..4b94254b636a05c0dca334ea8c98906b2d39e9c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -102,8 +102,7 @@ public abstract class NamedScopesHolder implements PersistentStateComponent<Elem
 
   @Nullable
   public static NamedScope getScope(@NotNull Project project, final String scopeName) {
-    final NamedScopesHolder[] holders = getAllNamedScopeHolders(project);
-    for (NamedScopesHolder holder : holders) {
+    for (NamedScopesHolder holder : getAllNamedScopeHolders(project)) {
       final NamedScope scope = holder.getScope(scopeName);
       if (scope != null) {
         return scope;
index 4d807c2e957ae359da5dfc75106dc9b20dc904ec..e984505cfb3c53e29f31f4ff897ca57da75c5ddf 100644 (file)
@@ -523,14 +523,14 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
     getTools(toolId, element.getProject()).disableTool(element);
   }
 
-  public void disableToolByDefault(@NotNull List<String> toolIds, Project project) {
+  public void disableToolByDefault(@NotNull List<String> toolIds, @Nullable Project project) {
     for (final String toolId : toolIds) {
       getToolDefaultState(toolId, project).setEnabled(false);
     }
   }
 
   @NotNull
-  public ScopeToolState getToolDefaultState(@NotNull String toolId, Project project) {
+  public ScopeToolState getToolDefaultState(@NotNull String toolId, @Nullable Project project) {
     return getTools(toolId, project).getDefaultState();
   }
 
@@ -612,7 +612,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
     HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
     if (key == null) {
       final InspectionEP extension = toolWrapper.getExtension();
-      Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<String>(toolWrapper.getDisplayName()) : (Computable<String>)extension::getDisplayName;
+      Computable<String> computable = extension == null ? new Computable.PredefinedValueComputable<String>(toolWrapper.getDisplayName()) : extension::getDisplayName;
       if (toolWrapper instanceof LocalInspectionToolWrapper) {
         key = HighlightDisplayKey.register(shortName, computable, toolWrapper.getID(),
                                            ((LocalInspectionToolWrapper)toolWrapper).getAlternativeID());
@@ -667,14 +667,14 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
   }
 
   @NotNull
-  private List<InspectionToolWrapper> createTools(Project project) {
+  private List<InspectionToolWrapper> createTools(@Nullable Project project) {
     if (mySource != null) {
       return ContainerUtil.map(mySource.getDefaultStates(project), ScopeToolState::getTool);
     }
     return myRegistrar.createTools();
   }
 
-  private HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, Project project) {
+  private HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key, @Nullable Project project) {
     final ToolsImpl tools = getTools(key.toString(), project);
     LOG.assertTrue(tools != null, "profile name: " + myName +  " base profile: " + (myBaseProfile != null ? myBaseProfile.getName() : "-") + " key: " + key);
     return tools.getLevel();
@@ -896,7 +896,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
   }
 
   @NotNull
-  public List<ScopeToolState> getDefaultStates(Project project) {
+  public List<ScopeToolState> getDefaultStates(@Nullable Project project) {
     initInspectionTools(project);
     final List<ScopeToolState> result = new ArrayList<>();
     for (Tools tools : myTools.values()) {
index 2cff9fa5d7b4e3681e87bbe54e9caabd41a947fe..56a347ca28ee200910feb5928b8ef43276940d9f 100644 (file)
@@ -94,7 +94,7 @@ class ProjectInspectionProfileManagerImpl(val project: Project,
         profile.isProjectLevel = true
         return profile
       }
-    })
+    }, isUseOldFileNameSanitize = true)
 
     project.messageBus.connect().subscribe(ProjectManager.TOPIC, object: ProjectManagerListener {
       override fun projectClosed(project: Project) {
index 81b09e8d6281c3610efb24845cce43485bee827a..d8d2531a487b4b17c050c51425a4c93557771d0e 100644 (file)
@@ -23,16 +23,11 @@ import com.intellij.openapi.components.TrackingPathMacroSubstitutor
 import com.intellij.openapi.components.impl.stores.DirectoryStorageUtil
 import com.intellij.openapi.components.impl.stores.FileStorageCoreUtil
 import com.intellij.openapi.components.impl.stores.StateStorageBase
-import com.intellij.openapi.util.JDOMUtil
 import com.intellij.openapi.util.Pair
-import com.intellij.openapi.vfs.CharsetToolkit
 import com.intellij.openapi.vfs.LocalFileSystem
 import com.intellij.openapi.vfs.VirtualFile
-import com.intellij.util.LineSeparator
-import com.intellij.util.SmartList
-import com.intellij.util.SystemProperties
+import com.intellij.util.*
 import com.intellij.util.containers.SmartHashSet
-import com.intellij.util.systemIndependentPath
 import gnu.trove.THashMap
 import org.jdom.Element
 import java.io.IOException
@@ -119,7 +114,7 @@ open class DirectoryBasedStorage(private val dir: Path,
     override fun setSerializedState(componentName: String, element: Element?) {
       storage.componentName = componentName
 
-      if (JDOMUtil.isEmpty(element)) {
+      if (element.isEmpty()) {
         if (copiedStorageData != null) {
           copiedStorageData!!.clear()
         }
@@ -254,9 +249,6 @@ private fun loadFile(file: VirtualFile?): Pair<ByteArray, String> {
   }
 
   val bytes = file.contentsToByteArray()
-  var lineSeparator: String? = file.detectedLineSeparator
-  if (lineSeparator == null) {
-    lineSeparator = detectLineSeparators(CharsetToolkit.UTF8_CHARSET.decode(ByteBuffer.wrap(bytes)), null).separatorString
-  }
+  val lineSeparator = file.detectedLineSeparator ?: detectLineSeparators(Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)), null).separatorString
   return Pair.create<ByteArray, String>(bytes, lineSeparator)
 }
\ No newline at end of file
index 9ce81c430ae912b00f7cfc8764ff35ce625717c6..f6d46bbf6603e0a547ad153a3b1d76b88aa8e341 100644 (file)
@@ -40,10 +40,10 @@ sealed class SchemeManagerFactoryBase : SchemeManagerFactory(), SettingsSavingCo
 
   protected open val componentManager: ComponentManager? = null
 
-  override final fun <T : Scheme, MutableT : T> create(directoryName: String, processor: SchemeProcessor<T, MutableT>, presentableName: String?, roamingType: RoamingType): SchemeManager<T> {
+  override final fun <T : Scheme, MutableT : T> create(directoryName: String, processor: SchemeProcessor<T, MutableT>, presentableName: String?, roamingType: RoamingType, isUseOldFileNameSanitize: Boolean): SchemeManager<T> {
     val path = checkPath(directoryName)
-    val manager = SchemeManagerImpl(path, processor, (componentManager?.stateStore?.stateStorageManager as? StateStorageManagerImpl)?.streamProvider, pathToFile(path), roamingType, componentManager, presentableName)
-    @Suppress("CAST_NEVER_SUCCEEDS")
+    val manager = SchemeManagerImpl(path, processor, (componentManager?.stateStore?.stateStorageManager as? StateStorageManagerImpl)?.streamProvider, pathToFile(path), roamingType, componentManager, presentableName, isUseOldFileNameSanitize)
+    @Suppress("UNCHECKED_CAST")
     managers.add(manager as SchemeManagerImpl<Scheme, out Scheme>)
     return manager
   }
@@ -103,18 +103,18 @@ sealed class SchemeManagerFactoryBase : SchemeManagerFactory(), SettingsSavingCo
       return path
     }
 
-    override fun pathToFile(path: String) = Paths.get(ApplicationManager.getApplication().stateStore.stateStorageManager.expandMacros(ROOT_CONFIG), path)
+    override fun pathToFile(path: String) = Paths.get(ApplicationManager.getApplication().stateStore.stateStorageManager.expandMacros(ROOT_CONFIG), path)!!
   }
 
   @Suppress("unused")
   private class ProjectSchemeManagerFactory(private val project: Project) : SchemeManagerFactoryBase() {
     override val componentManager = project
 
-    override fun pathToFile(path: String) = Paths.get(project.basePath, if (ProjectUtil.isDirectoryBased(project)) "${Project.DIRECTORY_STORE_FOLDER}/$path" else ".$path")
+    override fun pathToFile(path: String) = Paths.get(project.basePath, if (ProjectUtil.isDirectoryBased(project)) "${Project.DIRECTORY_STORE_FOLDER}/$path" else ".$path")!!
   }
 
   @TestOnly
   class TestSchemeManagerFactory(private val basePath: Path) : SchemeManagerFactoryBase() {
-    override fun pathToFile(path: String) = basePath.resolve(path)
+    override fun pathToFile(path: String) = basePath.resolve(path)!!
   }
 }
\ No newline at end of file
index b4141213c8fe3f5e06298534decb9b69ad23dd0f..157bdfcb3d573d54b71771f43118dad46ec84180 100644 (file)
@@ -62,7 +62,8 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
                                                         private val ioDirectory: Path,
                                                         val roamingType: RoamingType = RoamingType.DEFAULT,
                                                         virtualFileTrackerDisposable: Disposable? = null,
-                                                        val presentableName: String? = null) : SchemeManager<T>(), SafeWriteRequestor {
+                                                        val presentableName: String? = null,
+                                                        private val isUseOldFileNameSanitize: Boolean = false) : SchemeManager<T>(), SafeWriteRequestor {
   private val schemes = ArrayList<T>()
   private val readOnlyExternalizableSchemes = THashMap<String, T>()
 
@@ -559,7 +560,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
   }
 
   private fun saveScheme(scheme: MUTABLE_SCHEME, nameGenerator: UniqueNameGenerator) {
-    var externalInfo: ExternalInfo? = schemeToInfo[scheme]
+    var externalInfo: ExternalInfo? = schemeToInfo.get(scheme)
     val currentFileNameWithoutExtension = externalInfo?.fileNameWithoutExtension
     val parent = processor.writeScheme(scheme)
     val element = if (parent is Element) parent else (parent as Document).detachRootElement()
@@ -570,7 +571,7 @@ class SchemeManagerImpl<T : Scheme, MUTABLE_SCHEME : T>(val fileSpec: String,
 
     var fileNameWithoutExtension = currentFileNameWithoutExtension
     if (fileNameWithoutExtension == null || isRenamed(scheme)) {
-      fileNameWithoutExtension = nameGenerator.generateUniqueName(FileUtil.sanitizeFileName(scheme.name, false))
+      fileNameWithoutExtension = nameGenerator.generateUniqueName(FileUtil.sanitizeFileName(scheme.name, isUseOldFileNameSanitize))
     }
 
     val newDigest = element!!.digest()
index 5baf8fb0cb07607fd6f63c806d6e718467e4cc3e..cdbbf5eac8d9ccd317f9da6c2af52fe4f42f1337 100644 (file)
@@ -27,10 +27,12 @@ import com.intellij.openapi.project.ex.ProjectEx
 import com.intellij.openapi.project.ex.ProjectManagerEx
 import com.intellij.openapi.project.impl.ProjectImpl
 import com.intellij.openapi.vfs.VirtualFile
-import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImpl
 import com.intellij.testFramework.*
 import com.intellij.testFramework.Assertions.assertThat
-import com.intellij.util.*
+import com.intellij.util.PathUtil
+import com.intellij.util.readText
+import com.intellij.util.systemIndependentPath
+import com.intellij.util.write
 import org.intellij.lang.annotations.Language
 import org.junit.ClassRule
 import org.junit.Rule
@@ -111,53 +113,6 @@ internal class ProjectStoreTest {
     }
   }
 
-  @Test fun `project inspection`() {
-    loadAndUseProject(tempDirManager, {
-      it.writeChild("${Project.DIRECTORY_STORE_FOLDER}/misc.xml", iprFileContent)
-      it.path
-    }) { project ->
-      val projectInspectionProfileManager = ProjectInspectionProfileManagerImpl.getInstanceImpl(project)
-
-      assertThat(projectInspectionProfileManager.state).isEmpty()
-
-      projectInspectionProfileManager.currentProfile
-
-      assertThat(projectInspectionProfileManager.state).isEmpty()
-
-      // cause to use app profile
-      projectInspectionProfileManager.setRootProfile(null)
-      val doNotUseProjectProfileState = """
-      <state>
-        <option name="USE_PROJECT_PROFILE" value="false" />
-        <version value="1.0" />
-      </state>""".trimIndent()
-      assertThat(projectInspectionProfileManager.state).isEqualTo(doNotUseProjectProfileState)
-
-      val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles")
-      val file = inspectionDir.resolve("profiles_settings.xml")
-      project.saveStore()
-      assertThat(file).exists()
-      val doNotUseProjectProfileData = """
-      <component name="InspectionProjectProfileManager">
-        <option name="USE_PROJECT_PROFILE" value="false" />
-        <version value="1.0" />
-      </component>""".trimIndent()
-      assertThat(file.readText()).isEqualTo(doNotUseProjectProfileData)
-
-      // test load
-      file.delete()
-
-      project.baseDir.refresh(false, true)
-      (ProjectManager.getInstance() as StoreAwareProjectManager).flushChangedAlarm()
-      assertThat(projectInspectionProfileManager.state).isEmpty()
-
-      file.write(doNotUseProjectProfileData)
-      project.baseDir.refresh(false, true)
-      (ProjectManager.getInstance() as StoreAwareProjectManager).flushChangedAlarm()
-      assertThat(projectInspectionProfileManager.state).isEqualTo(doNotUseProjectProfileState)
-    }
-  }
-
   @Test fun fileBasedStorage() {
     loadAndUseProject(tempDirManager, { it.writeChild("test${ProjectFileType.DOT_DEFAULT_EXTENSION}", iprFileContent).path }) { project ->
       test(project)
index f70f7030dc0e1d31712dcb7051ee9330bd78a97e..f52fb9a68ece47117f3cbe149499d0ad83babb29 100644 (file)
@@ -32,26 +32,26 @@ interface ExternalizableScheme : Scheme {
 abstract class SchemeManagerFactory {
   companion object {
     @JvmStatic
-    fun getInstance() = ServiceManager.getService(SchemeManagerFactory::class.java)
+    fun getInstance() = ServiceManager.getService(SchemeManagerFactory::class.java)!!
 
     @JvmStatic
-    fun getInstance(project: Project) = ServiceManager.getService(project, SchemeManagerFactory::class.java)
+    fun getInstance(project: Project) = ServiceManager.getService(project, SchemeManagerFactory::class.java)!!
   }
 
   /**
    * directoryName — like "keymaps".
    */
   @JvmOverloads
-  fun <SCHEME : Scheme, MUTABLE_SCHEME: SCHEME> create(directoryName: String, processor: SchemeProcessor<SCHEME, MUTABLE_SCHEME>, presentableName: String? = null): SchemeManager<SCHEME> = create(directoryName, processor, presentableName, RoamingType.DEFAULT)
+  fun <SCHEME : Scheme, MUTABLE_SCHEME: SCHEME> create(directoryName: String, processor: SchemeProcessor<SCHEME, MUTABLE_SCHEME>, presentableName: String? = null, isUseOldFileNameSanitize: Boolean = false): SchemeManager<SCHEME> = create(directoryName, processor, presentableName, RoamingType.DEFAULT, isUseOldFileNameSanitize)
 
-  protected abstract fun <SCHEME : Scheme, MUTABLE_SCHEME: SCHEME> create(directoryName: String, processor: SchemeProcessor<SCHEME, MUTABLE_SCHEME>, presentableName: String? = null, roamingType: RoamingType = RoamingType.DEFAULT): SchemeManager<SCHEME>
+  protected abstract fun <SCHEME : Scheme, MUTABLE_SCHEME: SCHEME> create(directoryName: String, processor: SchemeProcessor<SCHEME, MUTABLE_SCHEME>, presentableName: String? = null, roamingType: RoamingType = RoamingType.DEFAULT, isUseOldFileNameSanitize: Boolean = false): SchemeManager<SCHEME>
 }
 
 enum class SchemeState {
   UNCHANGED, NON_PERSISTENT, POSSIBLY_CHANGED
 }
 
-abstract class SchemeProcessor<SCHEME : Scheme, MUTABLE_SCHEME: SCHEME> {
+abstract class SchemeProcessor<SCHEME : Scheme, in MUTABLE_SCHEME: SCHEME> {
   open fun isExternalizable(scheme: SCHEME) = scheme is ExternalizableScheme
 
   /**
index ea2df0ed58dda13fd42e9e15a8742bdbebae6848..7d80304dfd80e1271c06962c47674182f26364b5 100644 (file)
@@ -26,9 +26,10 @@ public class MockSchemeManagerFactory extends SchemeManagerFactory {
   @NotNull
   @Override
   protected <SCHEME extends Scheme, MUTABLE_SCHEME extends SCHEME> SchemeManager<SCHEME> create(@NotNull String directoryName,
-                                                                                                @NotNull SchemeProcessor<SCHEME, MUTABLE_SCHEME> processor,
+                                                                                                @NotNull SchemeProcessor<SCHEME, ? super MUTABLE_SCHEME> processor,
                                                                                                 @Nullable String presentableName,
-                                                                                                @NotNull RoamingType roamingType) {
+                                                                                                @NotNull RoamingType roamingType,
+                                                                                                boolean isUseOldFileNameSanitize) {
     //noinspection unchecked
     return EMPTY;
   }
index 0b44bc1b2df2d76c6b9b9227777e15aaf8db8f9d..023b0c0e439d8ea7755e9c5049d8f177bbd417c6 100644 (file)
@@ -749,7 +749,7 @@ testDiscovery.enabled=false
 ruby.remote.debugger.supports.catchpoint.removal=true
 
 use.read.action.to.init.service=false
-saving.state.in.new.format.is.allowed=false
+saving.state.in.new.format.is.allowed=true
 
 ide.mac.new.color.picker=false
 
index fe1d2f71c628b0b68f788c38f7761c9f6aea705e..e34aa12c724b164e0450f656dff5c7f4e9bd1f99 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -1674,10 +1674,6 @@ public class FileUtil extends FileUtilRt {
     return map;
   }
 
-  public static boolean isRootPath(@NotNull File file) {
-    return isRootPath(file.getPath());
-  }
-
   public static boolean isRootPath(@NotNull String path) {
     return path.equals("/") || path.matches("[a-zA-Z]:[/\\\\]");
   }
index 4dcd86f5e9b67887676e5b645c225f85db6a76ef..377027b109103e8e66cc0e1412d58571d1e73852 100644 (file)
@@ -80,7 +80,7 @@ public class ProjectLevelVcsManagerSerialization {
     final Map<String, VcsShowConfirmationOptionImpl> confirmations = optionsAndConfirmations.getConfirmations();
     
     for (VcsShowOptionsSettingImpl setting : options.values()) {
-      if (!Registry.is("saving.state.in.new.format.is.allowed", false) || !setting.getValue()) {
+      if (!Registry.is("saving.state.in.new.format.is.allowed", true) || !setting.getValue()) {
         Element settingElement = new Element(OPTIONS_SETTING);
         element.addContent(settingElement);
         settingElement.setAttribute(VALUE_ATTTIBUTE, Boolean.toString(setting.getValue()));
@@ -89,7 +89,7 @@ public class ProjectLevelVcsManagerSerialization {
     }
 
     for (VcsShowConfirmationOptionImpl setting : confirmations.values()) {
-      if (!Registry.is("saving.state.in.new.format.is.allowed", false) || setting.getValue() != VcsShowConfirmationOption.Value.SHOW_CONFIRMATION) {
+      if (!Registry.is("saving.state.in.new.format.is.allowed", true) || setting.getValue() != VcsShowConfirmationOption.Value.SHOW_CONFIRMATION) {
         final Element settingElement = new Element(CONFIRMATIONS_SETTING);
         element.addContent(settingElement);
         settingElement.setAttribute(VALUE_ATTTIBUTE, setting.getValue().toString());