diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index 508170b22209..770cae8cc091 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -136,7 +136,7 @@ open class FileBasedStorage(file: File, private fun processReadException(e: Exception?) { val contentTruncated = e == null - blockSavingTheContent = !contentTruncated && (isProjectOrModuleFile(fileSpec) || fileSpec == StoragePathMacros.WORKSPACE_FILE) + blockSavingTheContent = !contentTruncated && (PROJECT_FILE == fileSpec || fileSpec.startsWith(PROJECT_CONFIG_DIR) || fileSpec == StoragePathMacros.MODULE_FILE || fileSpec == StoragePathMacros.WORKSPACE_FILE) if (!ApplicationManager.getApplication().isUnitTestMode && !ApplicationManager.getApplication().isHeadlessEnvironment) { if (e != null) { LOG.info(e) @@ -225,15 +225,13 @@ private fun doWrite(requestor: Any, file: VirtualFile, content: Any, lineSeparat } } -fun Parent.toBufferExposingByteArray(lineSeparator: String = "\n"): BufferExposingByteArrayOutputStream { +internal fun Parent.toBufferExposingByteArray(lineSeparator: String = "\n"): BufferExposingByteArrayOutputStream { val out = BufferExposingByteArrayOutputStream(512) JDOMUtil.writeParent(this, out, lineSeparator) return out } -fun isProjectOrModuleFile(fileSpec: String): Boolean = PROJECT_FILE == fileSpec || fileSpec.startsWith(PROJECT_CONFIG_DIR) || fileSpec == StoragePathMacros.MODULE_FILE - -fun detectLineSeparators(chars: CharSequence, defaultSeparator: LineSeparator?): LineSeparator { +internal fun detectLineSeparators(chars: CharSequence, defaultSeparator: LineSeparator?): LineSeparator { for (c in chars) { if (c == '\r') { return LineSeparator.CRLF diff --git a/platform/configuration-store-impl/src/StateStorageManagerImpl.kt b/platform/configuration-store-impl/src/StateStorageManagerImpl.kt index e0c72a8ab4e4..2d1af6710f58 100644 --- a/platform/configuration-store-impl/src/StateStorageManagerImpl.kt +++ b/platform/configuration-store-impl/src/StateStorageManagerImpl.kt @@ -41,6 +41,8 @@ import java.util.concurrent.locks.ReentrantLock import java.util.regex.Pattern import kotlin.concurrent.withLock +private val MACRO_PATTERN = Pattern.compile("(\\$[^\\$]*\\$)") + /** * If componentManager not specified, storage will not add file tracker (see VirtualFileTracker) */ @@ -61,9 +63,7 @@ open class StateStorageManagerImpl(private val rootTagName: String, get() = true companion object { - private val MACRO_PATTERN = Pattern.compile("(\\$[^\\$]*\\$)") - - fun createDefaultVirtualTracker(componentManager: ComponentManager?) = when (componentManager) { + private fun createDefaultVirtualTracker(componentManager: ComponentManager?) = when (componentManager) { null -> { null } @@ -401,5 +401,5 @@ private fun String.startsWithMacro(macro: String): Boolean { fun removeMacroIfStartsWith(path: String, macro: String) = if (path.startsWithMacro(macro)) path.substring(macro.length + 1) else path @Suppress("DEPRECATION") -val Storage.path: String +internal val Storage.path: String get() = if (value.isNullOrEmpty()) file else value \ No newline at end of file