SchemeManagerFactory — ability to pass directoryPath

This commit is contained in:
Vladimir Krivosheev
2017-01-25 12:43:43 +01:00
parent e4d3ecba8a
commit a38eb765bb
3 changed files with 13 additions and 8 deletions
@@ -45,12 +45,13 @@ sealed class SchemeManagerFactoryBase : SchemeManagerFactory(), SettingsSavingCo
presentableName: String?,
roamingType: RoamingType,
isUseOldFileNameSanitize: Boolean,
streamProvider: StreamProvider?): SchemeManager<T> {
streamProvider: StreamProvider?,
directoryPath: Path?): SchemeManager<T> {
val path = checkPath(directoryName)
val manager = SchemeManagerImpl(path,
processor,
streamProvider ?: (componentManager?.stateStore?.stateStorageManager as? StateStorageManagerImpl)?.streamProvider,
pathToFile(path),
directoryPath ?: pathToFile(path),
roamingType,
presentableName,
isUseOldFileNameSanitize,
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* 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.
@@ -20,6 +20,7 @@ import com.intellij.openapi.components.RoamingType
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import org.jdom.Parent
import java.nio.file.Path
@Deprecated("Please use SchemeManager")
abstract class SchemesManager<T : Scheme> : SchemeManager<T>()
@@ -41,8 +42,8 @@ abstract class SchemeManagerFactory {
* directoryName — like "keymaps".
*/
@JvmOverloads
fun <SCHEME : Scheme, MUTABLE_SCHEME : SCHEME> create(directoryName: String, processor: SchemeProcessor<SCHEME, MUTABLE_SCHEME>, presentableName: String? = null): SchemeManager<SCHEME> {
return create(directoryName, processor, presentableName, RoamingType.DEFAULT)
fun <SCHEME : Scheme, MUTABLE_SCHEME : SCHEME> create(directoryName: String, processor: SchemeProcessor<SCHEME, MUTABLE_SCHEME>, presentableName: String? = null, directoryPath: Path? = null): SchemeManager<SCHEME> {
return create(directoryName, processor, presentableName, RoamingType.DEFAULT, directoryPath = directoryPath)
}
abstract fun <SCHEME : Scheme, MUTABLE_SCHEME : SCHEME> create(directoryName: String,
@@ -50,7 +51,8 @@ abstract class SchemeManagerFactory {
presentableName: String? = null,
roamingType: RoamingType = RoamingType.DEFAULT,
isUseOldFileNameSanitize: Boolean = false,
streamProvider: StreamProvider? = null): SchemeManager<SCHEME>
streamProvider: StreamProvider? = null,
directoryPath: Path? = null): SchemeManager<SCHEME>
}
enum class SchemeState {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package com.intellij.testFramework
import com.intellij.configurationStore.StreamProvider
import com.intellij.openapi.components.RoamingType
import com.intellij.openapi.options.*
import java.nio.file.Path
private val EMPTY = EmptySchemesManager()
@@ -27,7 +28,8 @@ class MockSchemeManagerFactory : SchemeManagerFactory() {
presentableName: String?,
roamingType: RoamingType,
isUseOldFileNameSanitize: Boolean,
streamProvider: StreamProvider?): SchemeManager<SCHEME> {
streamProvider: StreamProvider?,
directoryPath: Path?): SchemeManager<SCHEME> {
@Suppress("UNCHECKED_CAST")
return EMPTY as SchemeManager<SCHEME>
}