do not check if only format changed for non-roamable storage and default project

This commit is contained in:
Vladimir Krivosheev
2015-09-03 12:32:42 +02:00
parent ecfff82dc0
commit 710f03c333
5 changed files with 8 additions and 11 deletions
@@ -248,7 +248,7 @@ abstract class ComponentStoreImpl : IComponentStore {
}
val storage = storageManager.getStateStorage(storageSpec)
var stateGetter = if (isUseLoadedStateAsExisting(storageSpec) && (ApplicationManager.getApplication().isUnitTestMode() || Registry.`is`("use.loaded.state.as.existing", false))) {
var stateGetter = if (isUseLoadedStateAsExisting(storage) && (ApplicationManager.getApplication().isUnitTestMode() || Registry.`is`("use.loaded.state.as.existing", false))) {
(storage as? StorageBaseEx<*>)?.createGetSession(component, name, stateClass)
}
else {
@@ -281,7 +281,7 @@ abstract class ComponentStoreImpl : IComponentStore {
return name
}
protected open fun isUseLoadedStateAsExisting(storageSpec: Storage): Boolean = true
protected open fun isUseLoadedStateAsExisting(storage: StateStorage): Boolean = (storage as? XmlElementStorage)?.roamingType != RoamingType.DISABLED
protected open fun getPathMacroManagerForDefaults(): PathMacroManager? = null
@@ -77,6 +77,8 @@ class DefaultProjectStoreImpl(override val project: ProjectImpl, private val pat
override fun getOldStorage(component: Any, componentName: String, operation: StateStorageOperation) = storage
}
override fun isUseLoadedStateAsExisting(storage: StateStorage) = false
// don't want to optimize and use already loaded data - it will add unnecessary complexity and implementation-lock (currently we store loaded archived state in memory, but later implementation can be changed)
fun getStateCopy() = storage.loadLocalData()
@@ -288,8 +288,6 @@ open class ProjectStoreImpl(override val project: ProjectImpl, private val pathM
}
override fun selectDefaultStorages(storages: Array<Storage>, operation: StateStorageOperation) = selectDefaultStorages(storages, operation, scheme)
override fun isUseLoadedStateAsExisting(storageSpec: Storage) = storageSpec.file != StoragePathMacros.WORKSPACE_FILE
}
fun selectDefaultStorages(storages: Array<Storage>, operation: StateStorageOperation, scheme: StorageScheme): Array<Storage> {
@@ -32,7 +32,7 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S
protected val pathMacroSubstitutor: TrackingPathMacroSubstitutor?,
roamingType: RoamingType? = RoamingType.DEFAULT,
provider: StreamProvider? = null) : StorageBaseEx<StateMap>() {
protected val roamingType: RoamingType = roamingType ?: RoamingType.DEFAULT
val roamingType: RoamingType = roamingType ?: RoamingType.DEFAULT
private val provider: StreamProvider? = if (provider == null || roamingType == RoamingType.DISABLED || !provider.isApplicable(fileSpec, this.roamingType)) null else provider
protected abstract fun loadLocalData(): Element?
@@ -144,12 +144,12 @@ class ApplicationStoreTest {
assertThat(file).hasContent("<application>\n <component name=\"A\" foo=\"1\" bar=\"2\" />\n</application>")
}
@Test fun `do not apply to workspace storage - do not save if only format is changed`() {
@State(name = "A", storages = arrayOf(Storage(file = StoragePathMacros.WORKSPACE_FILE)))
@Test fun `do not check if only format changed for non-roamable storage`() {
@State(name = "A", storages = arrayOf(Storage(file = "b.xml", roamingType = RoamingType.DISABLED)))
class AWorkspace : A()
val oldContent = "<application><component name=\"A\" foo=\"old\" deprecated=\"old\"/></application>"
val file = writeConfig("workspace.xml", oldContent)
val file = writeConfig("b.xml", oldContent)
val oldModificationTime = file.getLastModifiedTime()
testAppConfig.refreshVfs()
@@ -206,10 +206,7 @@ class ApplicationStoreTest {
override fun setPath(path: String) {
storageManager.addMacro(StoragePathMacros.APP_CONFIG, path)
storageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, "$path/workspace.xml")
}
override fun isUseLoadedStateAsExisting(storageSpec: Storage) = storageSpec.file != StoragePathMacros.WORKSPACE_FILE
}
abstract class Foo {