From f830ac51c5a904f5b5dbf197e131cf4d49ccf57d Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 29 Jun 2015 19:19:53 +0300 Subject: [PATCH] Cleanup (formatting; typos) --- .../impl/FileDocumentManagerImpl.java | 10 ++--- .../util/io/SafeFileOutputStream.java | 40 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java index 7066698d535c..61b79be2e869 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java @@ -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 LINE_SEPARATOR_KEY = Key.create("LINE_SEPARATOR_KEY"); public static final Key HARD_REF_TO_DOCUMENT_KEY = Key.create("HARD_REF_TO_DOCUMENT_KEY"); + + private static final Key LINE_SEPARATOR_KEY = Key.create("LINE_SEPARATOR_KEY"); private static final Key FILE_KEY = Key.create("FILE_KEY"); private static final Key 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 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); } diff --git a/platform/util/src/com/intellij/util/io/SafeFileOutputStream.java b/platform/util/src/com/intellij/util/io/SafeFileOutputStream.java index 204848f8c546..6596b54a0982 100644 --- a/platform/util/src/com/intellij/util/io/SafeFileOutputStream.java +++ b/platform/util/src/com/intellij/util/io/SafeFileOutputStream.java @@ -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) {