do not show SOE after exception in tests

This commit is contained in:
Alexey Kudravtsev
2010-12-27 17:00:20 +03:00
parent 709cc518d4
commit 446a2aa33f
2 changed files with 31 additions and 13 deletions
@@ -197,16 +197,18 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
myPassExecutorService.submitPasses(Collections.singletonMap((FileEditor)textEditor, array), progress, Job.DEFAULT_PRIORITY);
try {
while (progress.isRunning()) {
try {
if (progress.isCanceled() && progress.isRunning()) {
// write action sneaked in the AWT. restart
waitForTermination();
Throwable savedException = PassExecutorService.getSavedException(progress);
if (savedException != null) throw savedException;
return runPasses(file, document, textEditor, toIgnore, canChangeDocument,callbackWhileWaiting);
}
if (callbackWhileWaiting != null) {
callbackWhileWaiting.run();
}
progress.waitFor(100);
try {
UIUtil.dispatchAllInvocationEvents();
}
catch (RuntimeException e) {
@@ -501,11 +503,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
if (!isOffsetInsideHighlightInfo(offset, info, includeFixRange)) return true;
int compare = info.getSeverity().compareTo(minSeverity);
if (compare < 0) {
return true;
}
return processor.process(info);
return compare < 0 || processor.process(info);
}
});
}
@@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.impl;
import com.intellij.codeHighlighting.HighlightingPass;
import com.intellij.codeHighlighting.TextEditorHighlightingPass;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.concurrency.Job;
import com.intellij.concurrency.JobImpl;
import com.intellij.concurrency.JobUtil;
@@ -39,10 +38,9 @@ import com.intellij.openapi.progress.impl.ProgressManagerImpl;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.Consumer;
import com.intellij.util.SmartList;
@@ -299,10 +297,10 @@ public abstract class PassExecutorService implements Disposable {
private final DaemonProgressIndicator myUpdateProgress;
private ScheduledPass(@NotNull List<FileEditor> fileEditors,
@NotNull TextEditorHighlightingPass pass,
@NotNull DaemonProgressIndicator progressIndicator,
@NotNull AtomicInteger threadsToStartCountdown,
int jobPriority) {
@NotNull TextEditorHighlightingPass pass,
@NotNull DaemonProgressIndicator progressIndicator,
@NotNull AtomicInteger threadsToStartCountdown,
int jobPriority) {
myFileEditors = fileEditors;
myPass = pass;
myThreadsToStartCountdown = threadsToStartCountdown;
@@ -312,6 +310,20 @@ public abstract class PassExecutorService implements Disposable {
}
public void run() {
try {
doRun();
}
catch (RuntimeException e) {
saveException(e,myUpdateProgress);
throw e;
}
catch (Error e) {
saveException(e,myUpdateProgress);
throw e;
}
}
private void doRun() {
if (myUpdateProgress.isCanceled()) return;
log(myUpdateProgress, myPass, "Started. ");
@@ -479,4 +491,12 @@ public abstract class PassExecutorService implements Disposable {
}
}
}
private static final Key<Throwable> THROWABLE_KEY = Key.create("THROWABLE_KEY");
private static void saveException(Throwable e, DaemonProgressIndicator indicator) {
indicator.putUserDataIfAbsent(THROWABLE_KEY, e);
}
public static Throwable getSavedException(DaemonProgressIndicator indicator) {
return indicator.getUserData(THROWABLE_KEY);
}
}