diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt b/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt index 6f575c97f8c3..fdfe4a216d33 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/ProjectInspectionManagerTest.kt @@ -1,22 +1,9 @@ /* - * Copyright 2000-2017 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.codeInspection.ex import com.intellij.codeHighlighting.HighlightDisplayLevel -import com.intellij.configurationStore.PROJECT_CONFIG_DIR import com.intellij.configurationStore.StoreAwareProjectManager import com.intellij.ide.highlighter.ProjectFileType import com.intellij.openapi.project.ProjectManager @@ -39,7 +26,7 @@ class ProjectInspectionManagerTest { val projectRule = ProjectRule() } - val tempDirManager = TemporaryDirectory() + private val tempDirManager = TemporaryDirectory() @Rule @JvmField @@ -68,7 +55,7 @@ class ProjectInspectionManagerTest { """.trimIndent() assertThat(projectInspectionProfileManager.state).isEqualTo(doNotUseProjectProfileState) - val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles") + val inspectionDir = Paths.get(project.stateStore.projectConfigDir, "inspectionProfiles") val file = inspectionDir.resolve("profiles_settings.xml") project.saveStore() assertThat(file).exists() @@ -99,7 +86,7 @@ class ProjectInspectionManagerTest { loadAndUseProject(tempDirManager, { it.path }) { project -> - val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles") + val inspectionDir = Paths.get(project.stateStore.projectConfigDir, "inspectionProfiles") val profileFile = inspectionDir.resolve("Project_Default.xml") assertThat(profileFile).doesNotExist() @@ -132,7 +119,7 @@ class ProjectInspectionManagerTest { project.saveStore() - val inspectionDir = Paths.get(project.stateStore.stateStorageManager.expandMacros(PROJECT_CONFIG_DIR), "inspectionProfiles") + val inspectionDir = Paths.get(project.stateStore.projectConfigDir, "inspectionProfiles") val file = inspectionDir.resolve("profiles_settings.xml") assertThat(file).doesNotExist() diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index 19481a81a76f..afcf8036e9f7 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -55,8 +55,8 @@ import java.io.IOException import java.nio.file.Path import java.nio.file.Paths -const val PROJECT_FILE = "\$PROJECT_FILE$" -const val PROJECT_CONFIG_DIR = "\$PROJECT_CONFIG_DIR$" +internal const val PROJECT_FILE = "\$PROJECT_FILE$" +internal const val PROJECT_CONFIG_DIR = "\$PROJECT_CONFIG_DIR$" val IProjectStore.nameFile: Path get() = Paths.get(directoryStorePath, ProjectImpl.NAME_FILE) @@ -64,7 +64,7 @@ val IProjectStore.nameFile: Path internal val PROJECT_FILE_STORAGE_ANNOTATION = FileStorageAnnotation(PROJECT_FILE, false) internal val DEPRECATED_PROJECT_FILE_STORAGE_ANNOTATION = FileStorageAnnotation(PROJECT_FILE, true) -abstract class ProjectStoreBase(override final val project: ProjectImpl) : ComponentStoreImpl(), IProjectStore { +internal abstract class ProjectStoreBase(override final val project: ProjectImpl) : ComponentStoreImpl(), IProjectStore { // protected setter used in upsource // Zelix KlassMaster - ERROR: Could not find method 'getScheme()' var scheme = StorageScheme.DEFAULT @@ -89,6 +89,11 @@ abstract class ProjectStoreBase(override final val project: ProjectImpl) : Compo override fun getProjectFilePath() = storageManager.expandMacro(PROJECT_FILE) + /** + * `null` for default or non-directory based project. + */ + override fun getProjectConfigDir() = if (isDirectoryBased) storageManager.expandMacro(PROJECT_CONFIG_DIR) else null + override final fun getWorkspaceFilePath() = storageManager.expandMacro(StoragePathMacros.WORKSPACE_FILE) override final fun clearStorages() { diff --git a/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt b/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt index 7184be1904e2..c32522f26502 100644 --- a/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt +++ b/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt @@ -19,13 +19,13 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.ComponentManager import com.intellij.openapi.components.RoamingType import com.intellij.openapi.components.SettingsSavingComponent +import com.intellij.openapi.components.impl.stores.IProjectStore import com.intellij.openapi.components.stateStore import com.intellij.openapi.options.Scheme import com.intellij.openapi.options.SchemeManager import com.intellij.openapi.options.SchemeManagerFactory import com.intellij.openapi.options.SchemeProcessor import com.intellij.openapi.project.Project -import com.intellij.project.isDirectoryBased import com.intellij.util.SmartList import com.intellij.util.containers.ContainerUtil import com.intellij.util.lang.CompoundRuntimeException @@ -129,7 +129,15 @@ sealed class SchemeManagerFactoryBase : SchemeManagerFactory(), SettingsSavingCo private class ProjectSchemeManagerFactory(private val project: Project) : SchemeManagerFactoryBase() { override val componentManager = project - override fun pathToFile(path: String) = Paths.get(project.basePath, if (project.isDirectoryBased) "${Project.DIRECTORY_STORE_FOLDER}/$path" else ".$path")!! + override fun pathToFile(path: String): Path { + val projectFileDir = (project.stateStore as? IProjectStore)?.projectConfigDir + if (projectFileDir == null) { + return Paths.get(project.basePath, ".$path") + } + else { + return Paths.get(projectFileDir, path) + } + } } @TestOnly diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java index 2a3152c71292..f8383fcb7d74 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.openapi.components.impl.stores; @@ -37,6 +25,13 @@ public interface IProjectStore extends IComponentStore { @NotNull String getProjectFilePath(); + /** + * `null` for default or non-directory based project. + */ + @SystemIndependent + @Nullable + String getProjectConfigDir(); + /** * System-independent path. */