Cleanup (moving shared stuff out of XmlElementStorage)

GitOrigin-RevId: c5033becbef57a45d3a603f1b9a04a8305083825
This commit is contained in:
Roman Shevchenko
2024-02-20 01:05:49 +01:00
committed by intellij-monorepo-bot
parent d13327bb5f
commit f30ff3d248
2 changed files with 17 additions and 20 deletions

View File

@@ -8,7 +8,6 @@ import com.intellij.openapi.components.PathMacroManager
import com.intellij.openapi.components.PathMacroSubstitutor
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.RoamingType
import com.intellij.openapi.components.StoragePathMacros
import com.intellij.openapi.components.impl.stores.ComponentStorageUtil
import com.intellij.openapi.diagnostic.debug
import com.intellij.openapi.extensions.PluginId
@@ -28,7 +27,6 @@ import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import org.jdom.Attribute
import org.jdom.Element
import org.jdom.JDOMException
import org.jetbrains.annotations.ApiStatus.Internal
import java.io.FileNotFoundException
import java.io.InputStream
import java.io.Writer
@@ -476,7 +474,7 @@ internal class XmlDataWriter(
}
}
internal fun Element.normalizeRootName(): Element {
private fun Element.normalizeRootName(): Element {
if (org.jdom.JDOMInterner.isInterned(this)) {
if (name == ComponentStorageUtil.COMPONENT) {
return this
@@ -496,20 +494,3 @@ internal fun Element.normalizeRootName(): Element {
return this
}
}
@Internal
enum class DataStateChanged {
LOADED, SAVED
}
internal fun getEffectiveRoamingType(roamingType: RoamingType, collapsedPath: String): RoamingType {
if (roamingType != RoamingType.DISABLED &&
(collapsedPath == StoragePathMacros.WORKSPACE_FILE ||
collapsedPath == StoragePathMacros.NON_ROAMABLE_FILE ||
isSpecialStorage(collapsedPath))) {
return RoamingType.DISABLED
}
else {
return roamingType
}
}

View File

@@ -2,6 +2,7 @@
package com.intellij.configurationStore
import com.intellij.openapi.application.EDT
import com.intellij.openapi.components.RoamingType
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.StoragePathMacros
import com.intellij.openapi.components.impl.stores.ComponentStorageUtil
@@ -33,9 +34,24 @@ interface StateGetter<S : Any> {
fun archiveState(): S?
}
@ApiStatus.Internal
enum class DataStateChanged { LOADED, SAVED }
internal fun isSpecialStorage(collapsedPath: String): Boolean =
collapsedPath == StoragePathMacros.CACHE_FILE || collapsedPath == StoragePathMacros.PRODUCT_WORKSPACE_FILE
internal fun getEffectiveRoamingType(roamingType: RoamingType, collapsedPath: String): RoamingType {
if (roamingType != RoamingType.DISABLED &&
(collapsedPath == StoragePathMacros.WORKSPACE_FILE ||
collapsedPath == StoragePathMacros.NON_ROAMABLE_FILE ||
isSpecialStorage(collapsedPath))) {
return RoamingType.DISABLED
}
else {
return roamingType
}
}
@CalledInAny
internal suspend fun ensureFilesWritable(project: Project, files: Collection<VirtualFile>): ReadonlyStatusHandler.OperationStatus =
withContext(Dispatchers.EDT) {