This commit is contained in:
Alexey Kudravtsev
2016-11-10 15:59:29 +03:00
parent fc71870d63
commit 3b87fd22bd
7 changed files with 26 additions and 39 deletions
@@ -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 {
@@ -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)}"
}
}
@@ -46,9 +46,9 @@ public abstract class VirtualFileManager implements ModificationTracker {
}
/**
* Gets the instance of <code>VirtualFileManager</code>.
* Gets the instance of {@code VirtualFileManager}.
*
* @return <code>VirtualFileManager</code>
* @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 <code>{@link VirtualFile}</code> if the file was found, <code>null</code> otherwise
* @return <code>{@link VirtualFile}</code> 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 <code>{@link VirtualFile}</code> if the file was found, <code>null</code> otherwise
* @return <code>{@link VirtualFile}</code> 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 <code>null</code> if there is no "://" in the URL
* @return protocol or {@code null} if there is no "://" in the URL
* @see VirtualFileSystem#getProtocol
*/
@Nullable
@@ -52,7 +52,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
private final List<VirtualFileSystem> myPhysicalFileSystems = new ArrayList<VirtualFileSystem>();
private final EventDispatcher<VirtualFileListener> myVirtualFileListenerMulticaster = EventDispatcher.create(VirtualFileListener.class);
private final List<VirtualFileManagerListener> myVirtualFileManagerListeners = ContainerUtil.createLockFreeCopyOnWriteList();
private int myRefreshCount = 0;
private int myRefreshCount;
public VirtualFileManagerImpl(@NotNull VirtualFileSystem[] fileSystems, @NotNull MessageBus bus) {
for (VirtualFileSystem fileSystem : fileSystems) {
@@ -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<String> unknownMacros,
@NotNull Map<TrackingPathMacroSubstitutor, IComponentStore> 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<String> 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;
@@ -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()) {
@@ -187,9 +187,9 @@ public class JobUtilTest extends PlatformTestCase {
private static class MyException extends RuntimeException {}
public void testExceptionalCompletion() throws Throwable {
final List<Object> objects = Collections.nCopies(100000000, null);
COUNT.set(0);
try {
final List<Object> objects = Collections.nCopies(100000000, null);
JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, o -> {
if (COUNT.incrementAndGet() == 100000) {
System.out.println("PCE");
@@ -204,8 +204,8 @@ public class JobUtilTest extends PlatformTestCase {
}
}
public void testNotNormalCompletion() throws Throwable {
final List<Object> objects = Collections.nCopies(100000000, null);
COUNT.set(0);
final List<Object> objects = Collections.nCopies(100000000, null);
boolean success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, o -> {
if (COUNT.incrementAndGet() == 100000) {
System.out.println("PCE");
@@ -217,8 +217,8 @@ public class JobUtilTest extends PlatformTestCase {
}
public void testJobUtilCompletesEvenIfCannotGrabReadAction() throws Throwable {
final List<Object> objects = Collections.nCopies(1000000, null);
COUNT.set(0);
final List<Object> objects = Collections.nCopies(1000000, null);
ApplicationManager.getApplication().runWriteAction(() -> {
boolean success = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(objects, null, true, false, o -> {
COUNT.incrementAndGet();