mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (formatting; typos)
This commit is contained in:
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -84,12 +84,12 @@ import java.lang.reflect.Proxy;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class FileDocumentManagerImpl extends FileDocumentManager implements VirtualFileListener,
|
||||
ProjectManagerListener, SafeWriteRequestor {
|
||||
public class FileDocumentManagerImpl extends FileDocumentManager implements VirtualFileListener, ProjectManagerListener, SafeWriteRequestor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl");
|
||||
|
||||
private static final Key<String> LINE_SEPARATOR_KEY = Key.create("LINE_SEPARATOR_KEY");
|
||||
public static final Key<Document> HARD_REF_TO_DOCUMENT_KEY = Key.create("HARD_REF_TO_DOCUMENT_KEY");
|
||||
|
||||
private static final Key<String> LINE_SEPARATOR_KEY = Key.create("LINE_SEPARATOR_KEY");
|
||||
private static final Key<VirtualFile> FILE_KEY = Key.create("FILE_KEY");
|
||||
private static final Key<Boolean> MUST_RECOMPUTE_FILE_TYPE = Key.create("Must recompute file type");
|
||||
|
||||
@@ -857,7 +857,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
|
||||
|
||||
private void handleErrorsOnSave(@NotNull Map<Document, IOException> failures) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
IOException ioException = failures.isEmpty() ? null : failures.values().iterator().next();
|
||||
IOException ioException = ContainerUtil.getFirstItem(failures.values());
|
||||
if (ioException != null) {
|
||||
throw new RuntimeException(ioException);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
|
||||
private final File myTargetFile;
|
||||
private final boolean myPreserveAttributes;
|
||||
private final File myBackDoorFile;
|
||||
private final OutputStream myBackDoorStream;
|
||||
private boolean failed = false;
|
||||
private final File myBackupFile;
|
||||
private final OutputStream myBackupStream;
|
||||
private boolean myFailed = false;
|
||||
|
||||
public SafeFileOutputStream(File target) throws FileNotFoundException {
|
||||
this(target, false);
|
||||
@@ -44,19 +44,19 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
public SafeFileOutputStream(File target, boolean preserveAttributes) throws FileNotFoundException {
|
||||
myTargetFile = target;
|
||||
myPreserveAttributes = preserveAttributes;
|
||||
myBackDoorFile = new File(myTargetFile.getParentFile(), myTargetFile.getName() + EXTENSION_BAK);
|
||||
myBackupFile = new File(myTargetFile.getParentFile(), myTargetFile.getName() + EXTENSION_BAK);
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
myBackDoorStream = new FileOutputStream(myBackDoorFile);
|
||||
myBackupStream = new FileOutputStream(myBackupFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
try {
|
||||
myBackDoorStream.write(b);
|
||||
myBackupStream.write(b);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
failed = true;
|
||||
myFailed = true;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -64,11 +64,11 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
try {
|
||||
myBackDoorStream.write(b);
|
||||
myBackupStream.write(b);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
failed = true;
|
||||
myFailed = true;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -76,11 +76,11 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
try {
|
||||
myBackDoorStream.write(b, off, len);
|
||||
myBackupStream.write(b, off, len);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
failed = true;
|
||||
myFailed = true;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -88,11 +88,11 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
try {
|
||||
myBackDoorStream.flush();
|
||||
myBackupStream.flush();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
failed = true;
|
||||
myFailed = true;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -100,16 +100,16 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
myBackDoorStream.close();
|
||||
myBackupStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
FileUtil.delete(myBackDoorFile);
|
||||
FileUtil.delete(myBackupFile);
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
throw new IOException(CommonBundle.message("safe.write.failed", myTargetFile, myBackDoorFile.getName()));
|
||||
if (myFailed) {
|
||||
throw new IOException(CommonBundle.message("safe.write.failed", myTargetFile, myBackupFile.getName()));
|
||||
}
|
||||
|
||||
final File oldFile = new File(myTargetFile.getParent(), myTargetFile.getName() + EXTENSION_OLD);
|
||||
@@ -118,15 +118,15 @@ public class SafeFileOutputStream extends OutputStream {
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
throw new IOException(CommonBundle.message("safe.write.rename.original", myTargetFile, myBackDoorFile.getName()));
|
||||
throw new IOException(CommonBundle.message("safe.write.rename.original", myTargetFile, myBackupFile.getName()));
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtil.rename(myBackDoorFile, myTargetFile);
|
||||
FileUtil.rename(myBackupFile, myTargetFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
throw new IOException(CommonBundle.message("safe.write.rename.backup", myTargetFile, oldFile.getName(), myBackDoorFile.getName()));
|
||||
throw new IOException(CommonBundle.message("safe.write.rename.backup", myTargetFile, oldFile.getName(), myBackupFile.getName()));
|
||||
}
|
||||
|
||||
if (myPreserveAttributes) {
|
||||
|
||||
Reference in New Issue
Block a user