mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ICS: saveContent -> write
This commit is contained in:
@@ -583,7 +583,7 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
|
||||
if (renamed) {
|
||||
externalInfo!!.scheduleDelete()
|
||||
}
|
||||
provider!!.saveContent(providerPath, byteOut.getInternalBuffer(), byteOut.size(), roamingType)
|
||||
provider!!.write(providerPath, byteOut.getInternalBuffer(), byteOut.size(), roamingType)
|
||||
}
|
||||
|
||||
if (externalInfo == null) {
|
||||
|
||||
@@ -139,7 +139,7 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S
|
||||
else {
|
||||
// we should use standard line-separator (\n) - stream provider can share file content on any OS
|
||||
val content = StorageUtil.writeToBytes(element, "\n")
|
||||
provider.saveContent(storage.fileSpec, content.getInternalBuffer(), content.size(), storage.roamingType)
|
||||
provider.write(storage.fileSpec, content.getInternalBuffer(), content.size(), storage.roamingType)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -111,7 +111,7 @@ class ApplicationStoreTest {
|
||||
private class MyStreamProvider : StreamProvider {
|
||||
public val data: MutableMap<RoamingType, MutableMap<String, String>> = THashMap()
|
||||
|
||||
override fun saveContent(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) {
|
||||
override fun write(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) {
|
||||
getMap(roamingType).put(fileSpec, String(content, 0, size, CharsetToolkit.UTF8_CHARSET))
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.FileInputStream
|
||||
import java.io.InputStream
|
||||
|
||||
class MockStreamProvider(private val myBaseDir: File) : StreamProvider {
|
||||
override fun saveContent(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) {
|
||||
override fun write(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) {
|
||||
FileUtil.writeToFile(File(myBaseDir, fileSpec), content, 0, size)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public interface StreamProvider {
|
||||
* @param content bytes of content, size of array is not actual size of data, you must use `size`
|
||||
* @param size actual size of data
|
||||
*/
|
||||
public fun saveContent(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType)
|
||||
public fun write(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType)
|
||||
|
||||
public fun loadContent(fileSpec: String, roamingType: RoamingType): InputStream?
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ class IcsManager(dir: File) {
|
||||
repositoryManager.processChildren(fullPath, filter, { name, input -> processor(name, input, false) })
|
||||
}
|
||||
|
||||
override fun saveContent(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) {
|
||||
override fun write(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) {
|
||||
if (syncManager.writeAndDeleteProhibited) {
|
||||
throw IllegalStateException("Save is prohibited now")
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.jetbrains.settingsRepository.test
|
||||
|
||||
import com.intellij.mock.MockVirtualFileSystem
|
||||
import com.intellij.openapi.components.RoamingType
|
||||
import com.intellij.openapi.components.impl.stores.StreamProvider
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vcs.merge.MergeSession
|
||||
import com.intellij.openapi.vfs.CharsetToolkit
|
||||
@@ -84,7 +83,7 @@ class GitTest : TestCase() {
|
||||
|
||||
private fun addAndCommit(path: String): FileInfo {
|
||||
val data = FileUtil.loadFileBytes(File(testDataPath, PathUtilRt.getFileName(path)))
|
||||
provider.save(path, data)
|
||||
provider.write(path, data)
|
||||
repositoryManager.commit()
|
||||
return FileInfo(path, data)
|
||||
}
|
||||
@@ -92,7 +91,7 @@ class GitTest : TestCase() {
|
||||
Test fun add() {
|
||||
val data = FileUtil.loadFileBytes(File(testDataPath, "remote.xml"))
|
||||
val addedFile = "remote.xml"
|
||||
provider.save(addedFile, data)
|
||||
provider.write(addedFile, data)
|
||||
|
||||
val diff = repository.computeIndexDiff()
|
||||
assertThat(diff.diff()).isTrue()
|
||||
@@ -109,8 +108,8 @@ class GitTest : TestCase() {
|
||||
val data2 = FileUtil.loadFileBytes(File(testDataPath, "local.xml"))
|
||||
val addedFile = "remote.xml"
|
||||
val addedFile2 = "local.xml"
|
||||
provider.save(addedFile, data)
|
||||
provider.save(addedFile2, data2)
|
||||
provider.write(addedFile, data)
|
||||
provider.write(addedFile2, data2)
|
||||
|
||||
val diff = repository.computeIndexDiff()
|
||||
assertThat(diff.diff()).isTrue()
|
||||
@@ -127,7 +126,7 @@ class GitTest : TestCase() {
|
||||
fun delete(data: ByteArray, directory: Boolean) {
|
||||
val dir = "dir"
|
||||
val fullFileSpec = "$dir/$addedFile"
|
||||
provider.save(fullFileSpec, data)
|
||||
provider.write(fullFileSpec, data)
|
||||
provider.delete(if (directory) dir else fullFileSpec, RoamingType.PER_USER)
|
||||
|
||||
val diff = repository.computeIndexDiff()
|
||||
@@ -272,7 +271,7 @@ class GitTest : TestCase() {
|
||||
createLocalRepository(null)
|
||||
|
||||
val data = AM.MARKER_ACCEPT_MY
|
||||
provider.save("remote.xml", data)
|
||||
provider.write("remote.xml", data)
|
||||
|
||||
sync(SyncType.MERGE)
|
||||
|
||||
@@ -286,7 +285,7 @@ class GitTest : TestCase() {
|
||||
sync(SyncType.MERGE)
|
||||
|
||||
val data = AM.MARKER_ACCEPT_THEIRS
|
||||
provider.save("remote.xml", data)
|
||||
provider.write("remote.xml", data)
|
||||
repositoryManager.commit()
|
||||
|
||||
remoteRepository.deletePath("remote.xml")
|
||||
@@ -317,7 +316,7 @@ class GitTest : TestCase() {
|
||||
Test fun `commit if unmerged`() {
|
||||
createLocalRepository(null)
|
||||
|
||||
provider.saveContent("remote.xml", "<foo />")
|
||||
provider.write("remote.xml", "<foo />")
|
||||
|
||||
try {
|
||||
sync(SyncType.MERGE)
|
||||
@@ -379,7 +378,7 @@ class GitTest : TestCase() {
|
||||
|
||||
val path = "local.xml"
|
||||
val data = FileUtil.loadFileBytes(File(testDataPath, PathUtilRt.getFileName(path)))
|
||||
provider.save(path, data)
|
||||
provider.write(path, data)
|
||||
|
||||
sync(syncType)
|
||||
|
||||
@@ -406,9 +405,4 @@ class GitTest : TestCase() {
|
||||
private fun sync(syncType: SyncType) {
|
||||
icsManager.sync(syncType, fixtureManager.projectFixture.getProject())
|
||||
}
|
||||
}
|
||||
|
||||
fun StreamProvider.saveContent(fileSpec: String, content: String) {
|
||||
val data = content.toByteArray()
|
||||
saveContent(fileSpec, data, data.size(), RoamingType.PER_USER)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class LoadTest : TestCase() {
|
||||
public Test fun `load scheme`() {
|
||||
val localScheme = TestScheme("local")
|
||||
val data = localScheme.serialize().toByteArray()
|
||||
provider.save("$dirPath/local.xml", data)
|
||||
provider.write("$dirPath/local.xml", data)
|
||||
|
||||
val schemesManager = createSchemeManager(dirPath)
|
||||
schemesManager.loadSchemes()
|
||||
@@ -47,8 +47,8 @@ class LoadTest : TestCase() {
|
||||
public Test fun `load scheme with the same names`() {
|
||||
val localScheme = TestScheme("local")
|
||||
val data = localScheme.serialize().toByteArray()
|
||||
provider.save("$dirPath/local.xml", data)
|
||||
provider.save("$dirPath/local2.xml", data)
|
||||
provider.write("$dirPath/local.xml", data)
|
||||
provider.write("$dirPath/local2.xml", data)
|
||||
|
||||
val schemesManager = createSchemeManager(dirPath)
|
||||
schemesManager.loadSchemes()
|
||||
@@ -58,7 +58,7 @@ class LoadTest : TestCase() {
|
||||
public Test fun `load scheme from repo and read-only repo`() {
|
||||
val localScheme = TestScheme("local")
|
||||
|
||||
provider.save("$dirPath/local.xml", localScheme.serialize().toByteArray())
|
||||
provider.write("$dirPath/local.xml", localScheme.serialize().toByteArray())
|
||||
|
||||
val remoteScheme = TestScheme("remote")
|
||||
val remoteRepository = tempDirManager.createRepository()
|
||||
@@ -79,7 +79,7 @@ class LoadTest : TestCase() {
|
||||
val schemeName = "Emacs"
|
||||
val localScheme = TestScheme(schemeName, "local")
|
||||
|
||||
provider.save("$dirPath/$schemeName.xml", localScheme.serialize().toByteArray())
|
||||
provider.write("$dirPath/$schemeName.xml", localScheme.serialize().toByteArray())
|
||||
|
||||
val remoteScheme = TestScheme(schemeName, "remote")
|
||||
val remoteRepository = tempDirManager.createRepository("remote")
|
||||
|
||||
@@ -33,8 +33,13 @@ import kotlin.properties.Delegates
|
||||
|
||||
val testDataPath: String = "${PlatformTestUtil.getCommunityPath()}/plugins/settings-repository/testData"
|
||||
|
||||
fun StreamProvider.save(path: String, data: ByteArray) {
|
||||
saveContent(path, data, data.size(), RoamingType.PER_USER)
|
||||
fun StreamProvider.write(path: String, data: ByteArray) {
|
||||
write(path, data, data.size(), RoamingType.PER_USER)
|
||||
}
|
||||
|
||||
fun StreamProvider.write(fileSpec: String, content: String) {
|
||||
val data = content.toByteArray()
|
||||
write(fileSpec, data, data.size(), RoamingType.PER_USER)
|
||||
}
|
||||
|
||||
fun Repository.add(data: ByteArray, path: String): Repository {
|
||||
|
||||
Reference in New Issue
Block a user