mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prepare to "don't save if only format is changed"
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<root>
|
||||
<item name='java.nio.file.Files java.nio.file.attribute.FileTime getLastModifiedTime(java.nio.file.Path, java.nio.file.LinkOption...)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -62,7 +62,7 @@ open class DirectoryBasedStorage(private val myPathMacroSubstitutor: TrackingPat
|
||||
}
|
||||
}
|
||||
|
||||
override fun getStateAndArchive(storageData: Map<String, StateMap>, component: Any, componentName: String) = getCompositeStateAndArchive(storageData, componentName, mySplitter)
|
||||
override fun getState(storageData: Map<String, StateMap>, component: Any?, componentName: String) = getCompositeStateAndArchive(storageData, componentName, mySplitter)
|
||||
|
||||
override fun loadData(): MutableMap<String, StateMap> {
|
||||
return fromMap(DirectoryStorageUtil.loadFrom(getVirtualFile(), myPathMacroSubstitutor))
|
||||
|
||||
@@ -66,6 +66,7 @@ class ModuleStoreTest {
|
||||
assertThat(getOptionValue("foo")).isEqualTo("not bar")
|
||||
|
||||
setOption("foo", "not bar")
|
||||
// ensure that save the same data will not lead to any problems (like "Content equals, but it must be handled not on this level")
|
||||
saveStore()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,27 +17,26 @@ package com.intellij.configurationStore
|
||||
|
||||
import com.intellij.openapi.util.JDOMBuilder.attr
|
||||
import com.intellij.openapi.util.JDOMBuilder.tag
|
||||
import junit.framework.TestCase
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.jdom.Element
|
||||
import org.junit.Test
|
||||
|
||||
class XmlElementStorageTest {
|
||||
public Test fun testGetStateSucceeded() {
|
||||
@Test fun testGetStateSucceeded() {
|
||||
val storage = MyXmlElementStorage(tag("root", tag("component", attr("name", "test"), tag("foo"))))
|
||||
val state = storage.getState(this, "test", javaClass<Element>())
|
||||
TestCase.assertNotNull(state)
|
||||
TestCase.assertEquals("component", state.getName())
|
||||
TestCase.assertNotNull(state.getChild("foo"))
|
||||
val state = storage.getState(this, "test", javaClass<Element>(), null, false)
|
||||
assertThat(state).isNotNull()
|
||||
assertThat(state!!.getName()).isEqualTo("component")
|
||||
assertThat(state.getChild("foo")).isNotNull()
|
||||
}
|
||||
|
||||
public Test fun testGetStateNotSucceeded() {
|
||||
@Test fun `get state not succeeded`() {
|
||||
val storage = MyXmlElementStorage(tag("root"))
|
||||
val state = storage.getState(this, "test", javaClass<Element>())
|
||||
val state = storage.getState(this, "test", javaClass<Element>(), null, false)
|
||||
assertThat(state).isNull()
|
||||
}
|
||||
|
||||
public Test fun `set state overrides old state`() {
|
||||
@Test fun `set state overrides old state`() {
|
||||
val storage = MyXmlElementStorage(tag("root", tag("component", attr("name", "test"), tag("foo"))))
|
||||
val newState = tag("component", attr("name", "test"), tag("bar"))
|
||||
val externalizationSession = storage.startExternalization()!!
|
||||
|
||||
@@ -30,8 +30,6 @@ public interface StateStorage {
|
||||
@Nullable
|
||||
<T> T getState(@Nullable Object component, @NotNull String componentName, @NotNull Class<T> stateClass, @Nullable T mergeInto, boolean reload);
|
||||
|
||||
<T> T getState(@Nullable Object component, @NotNull String componentName, @NotNull Class<T> stateClass);
|
||||
|
||||
boolean hasState(@NotNull String componentName, boolean reloadData);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.nio.file.attribute.FileTime
|
||||
|
||||
public class TemporaryDirectory : ExternalResource() {
|
||||
private val paths = SmartList<Path>()
|
||||
@@ -110,6 +111,8 @@ public fun Path.deleteRecursively(): Path = if (exists()) Files.walkFileTree(thi
|
||||
}
|
||||
}) else this
|
||||
|
||||
public fun Path.getLastModifiedTime(): FileTime? = Files.getLastModifiedTime(this)
|
||||
|
||||
public val Path.systemIndependentPath: String
|
||||
get() = toString().replace(File.separatorChar, '/')
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ class IcsManager(dir: File) {
|
||||
|
||||
private fun registerProjectLevelProviders(project: Project) {
|
||||
val storageManager = project.stateStore.getStateStorageManager()
|
||||
val projectId = storageManager.getStateStorage(StoragePathMacros.WORKSPACE_FILE, RoamingType.DISABLED).getState(ProjectId(), "IcsProjectId", javaClass<ProjectId>())
|
||||
val projectId = storageManager.getStateStorage(StoragePathMacros.WORKSPACE_FILE, RoamingType.DISABLED).getState(ProjectId(), "IcsProjectId", javaClass<ProjectId>(), null, false)
|
||||
if (projectId == null || projectId.uid == null) {
|
||||
// not mapped, if user wants, he can map explicitly, we don't suggest
|
||||
// we cannot suggest "map to ICS" for any project that user opens, it will be annoying
|
||||
|
||||
Reference in New Issue
Block a user