diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
index 81f17e2b0dcb..492b99efaf67 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
@@ -440,8 +440,10 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
new DaemonCodeAnalyzer.DaemonListenerAdapter() {
@Override
public void daemonCancelEventOccurred(@NotNull String reason) {
- stopDaemonReason.compareAndSet(null, new RuntimeException("Some bastard's restarted daemon: " + reason + "\nStorage write log: "+
- StorageUtil.DEBUG_LOG));
+ RuntimeException e = new RuntimeException("Some bastard's restarted daemon: " + reason +
+ "\nStorage write log: ----------\n" +
+ StorageUtil.DEBUG_LOG +"\n--------------");
+ stopDaemonReason.compareAndSet(null, e);
}
});
try {
diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt
index e79258927e63..53525f7addef 100644
--- a/platform/configuration-store-impl/src/FileBasedStorage.kt
+++ b/platform/configuration-store-impl/src/FileBasedStorage.kt
@@ -180,7 +180,7 @@ fun writeFile(file: Path?, requestor: Any, virtualFile: VirtualFile?, element: E
throw IllegalStateException("Content equals, but it must be handled not on this level: ${result.name}")
}
else if (StorageUtil.DEBUG_LOG != null && ApplicationManager.getApplication().isUnitTestMode) {
- StorageUtil.DEBUG_LOG = "${result.path}:\n$content\nOld Content:\n${LoadTextUtil.loadText(result)}\n---------"
+ StorageUtil.DEBUG_LOG = "${result.path}:\n$content\nOld Content:\n${LoadTextUtil.loadText(result)}"
}
}
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManager.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManager.java
index 532d9c76f1cc..70b960a55e26 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManager.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFileManager.java
@@ -46,9 +46,9 @@ public abstract class VirtualFileManager implements ModificationTracker {
}
/**
- * Gets the instance of VirtualFileManager.
+ * Gets the instance of {@code VirtualFileManager}.
*
- * @return VirtualFileManager
+ * @return {@code VirtualFileManager}
*/
@NotNull
public static VirtualFileManager getInstance() {
@@ -89,7 +89,7 @@ public abstract class VirtualFileManager implements ModificationTracker {
* file systems.
*
* @param url the URL to find file by
- * @return {@link VirtualFile} if the file was found, null otherwise
+ * @return {@link VirtualFile} if the file was found, {@code null} otherwise
* @see VirtualFile#getUrl
* @see VirtualFileSystem#findFileByPath
* @see #refreshAndFindFileByUrl
@@ -107,7 +107,7 @@ public abstract class VirtualFileManager implements ModificationTracker {
* If this method is invoked not from Swing event dispatch thread, then it must not happen inside a read action.
*
* @param url the URL
- * @return {@link VirtualFile} if the file was found, null otherwise
+ * @return {@link VirtualFile} if the file was found, {@code null} otherwise
* @see VirtualFileSystem#findFileByPath
* @see VirtualFileSystem#refreshAndFindFileByPath
*/
@@ -148,7 +148,7 @@ public abstract class VirtualFileManager implements ModificationTracker {
* Extracts protocol from the given URL. Protocol is a substring from the beginning of the URL till "://".
*
* @param url the URL
- * @return protocol or null if there is no "://" in the URL
+ * @return protocol or {@code null} if there is no "://" in the URL
* @see VirtualFileSystem#getProtocol
*/
@Nullable
diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java
index 149babd50e50..054e4833cbd3 100644
--- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java
+++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/VirtualFileManagerImpl.java
@@ -52,7 +52,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
private final List myPhysicalFileSystems = new ArrayList();
private final EventDispatcher myVirtualFileListenerMulticaster = EventDispatcher.create(VirtualFileListener.class);
private final List myVirtualFileManagerListeners = ContainerUtil.createLockFreeCopyOnWriteList();
- private int myRefreshCount = 0;
+ private int myRefreshCount;
public VirtualFileManagerImpl(@NotNull VirtualFileSystem[] fileSystems, @NotNull MessageBus bus) {
for (VirtualFileSystem fileSystem : fileSystems) {
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 95df4253b62f..504d46ab2a5e 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
@@ -15,11 +15,12 @@
*/
package com.intellij.openapi.components.impl.stores;
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.NotificationsManager;
-import com.intellij.openapi.application.*;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ApplicationNamesInfo;
+import com.intellij.openapi.application.PathMacros;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.components.ComponentManager;
import com.intellij.openapi.components.ServiceKt;
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
@@ -40,11 +41,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
-import javax.swing.event.HyperlinkEvent;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@@ -53,7 +52,7 @@ public class StorageUtil {
public static final String NOTIFICATION_GROUP_ID = "Load Error";
@TestOnly
- public static String DEBUG_LOG = null;
+ public static String DEBUG_LOG;
private StorageUtil() { }
@@ -68,12 +67,7 @@ public class StorageUtil {
"Some of the files describing the current project settings contain unknown path variables " +
"and " + productName + " cannot restore those paths.";
new UnknownMacroNotification(NOTIFICATION_GROUP_ID, "Load error: undefined path variables", content, NotificationType.ERROR,
- new NotificationListener() {
- @Override
- public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
- checkUnknownMacros(project, true, macros, substitutorToStore);
- }
- }, macros).notify(project);
+ (notification, event) -> checkUnknownMacros(project, true, macros, substitutorToStore), macros).notify(project);
}
public static void checkUnknownMacros(@NotNull Project project, boolean notify) {
@@ -101,17 +95,12 @@ public class StorageUtil {
boolean showDialog,
@NotNull Set unknownMacros,
@NotNull Map substitutorToStore) {
- if (unknownMacros.isEmpty() || (showDialog && !ProjectMacrosUtil.checkMacros(project, new THashSet<>(unknownMacros)))) {
+ if (unknownMacros.isEmpty() || showDialog && !ProjectMacrosUtil.checkMacros(project, new THashSet<>(unknownMacros))) {
return;
}
PathMacros pathMacros = PathMacros.getInstance();
- for (Iterator it = unknownMacros.iterator(); it.hasNext(); ) {
- String macro = it.next();
- if (StringUtil.isEmptyOrSpaces(pathMacros.getValue(macro)) && !pathMacros.isIgnoredMacroName(macro)) {
- it.remove();
- }
- }
+ unknownMacros.removeIf(macro -> StringUtil.isEmptyOrSpaces(pathMacros.getValue(macro)) && !pathMacros.isIgnoredMacroName(macro));
if (unknownMacros.isEmpty()) {
return;
diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
index 39f6f99809c8..9f66afd27215 100644
--- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
@@ -96,13 +96,9 @@ public class ProgressManagerImpl extends CoreProgressManager implements Disposab
@Override
@NotNull
public Future> runProcessWithProgressAsynchronously(@NotNull Task.Backgroundable task) {
- final ProgressIndicator progressIndicator;
- if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
- progressIndicator = new EmptyProgressIndicator();
- }
- else {
- progressIndicator = new BackgroundableProcessIndicator(task);
- }
+ ProgressIndicator progressIndicator = ApplicationManager.getApplication().isHeadlessEnvironment() ?
+ new EmptyProgressIndicator() :
+ new BackgroundableProcessIndicator(task);
return runProcessWithProgressAsynchronously(task, progressIndicator, null);
}
@@ -135,13 +131,13 @@ public class ProgressManagerImpl extends CoreProgressManager implements Disposab
exception = e;
}
final long end = System.currentTimeMillis();
- final long time = end - start;
final boolean finalCanceled = processCanceled || progressIndicator.isCanceled();
final Throwable finalException = exception;
if (!finalCanceled) {
final Task.NotificationInfo notificationInfo = task.notifyFinished();
+ final long time = end - start;
if (notificationInfo != null && time > 5000) { // snow notification if process took more than 5 secs
final Component window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
if (window == null || notificationInfo.isShowWhenFocused()) {
diff --git a/platform/platform-tests/testSrc/com/intellij/concurrency/JobUtilTest.java b/platform/platform-tests/testSrc/com/intellij/concurrency/JobUtilTest.java
index 7e08e891433e..b75591c4ade0 100644
--- a/platform/platform-tests/testSrc/com/intellij/concurrency/JobUtilTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/concurrency/JobUtilTest.java
@@ -187,9 +187,9 @@ public class JobUtilTest extends PlatformTestCase {
private static class MyException extends RuntimeException {}
public void testExceptionalCompletion() throws Throwable {
- final List