summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java')
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java
index 73aea37d6444..bd732705446a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java
+++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java
@@ -113,19 +113,25 @@ public class StorageUtil {
@Nullable
static VirtualFile save(@NotNull IFile file, Parent element, Object requestor) throws StateStorageException {
try {
- VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(file);
- Couple<String> pair = loadFile(vFile);
- String text = JDOMUtil.writeParent(element, pair.second);
-
+ String lineSeparator;
+ String oldText;
if (file.exists()) {
- if (text.equals(pair.first)) {
- return null;
- }
+ VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(file);
+ Couple<String> pair = loadFile(vFile);
+ lineSeparator = pair.second;
+ oldText = pair.first;
}
else {
+ oldText = null;
+ lineSeparator = SystemProperties.getLineSeparator();
file.createParentDirs();
}
+ String text = JDOMUtil.writeParent(element, lineSeparator);
+ if (text.equals(oldText)) {
+ return null;
+ }
+
// mark this action as modifying the file which daemon analyzer should ignore
AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(DocumentRunnable.IgnoreDocumentRunnable.class);
try {
@@ -245,6 +251,7 @@ public class StorageUtil {
}
}
+ @NotNull
public static BufferExposingByteArrayOutputStream documentToBytes(@NotNull Document document, boolean useSystemLineSeparator) throws IOException {
BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(512);
OutputStreamWriter writer = new OutputStreamWriter(out, CharsetToolkit.UTF8_CHARSET);
@@ -271,9 +278,9 @@ public class StorageUtil {
}
}
- public static void deleteContent(@NotNull StreamProvider provider, @NotNull String fileSpec, @NotNull RoamingType type) {
+ public static void delete(@NotNull StreamProvider provider, @NotNull String fileSpec, @NotNull RoamingType type) {
if (provider.isApplicable(fileSpec, type)) {
- provider.deleteFile(fileSpec, type);
+ provider.delete(fileSpec, type);
}
}