mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
additional assertion in tests
This commit is contained in:
+3
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -46,7 +47,8 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
DaemonCodeAnalyzer.getInstance(getProject()).projectClosed();
|
||||
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
|
||||
codeAnalyzer.projectClosed();
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
+5
-1
@@ -361,7 +361,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
|
||||
if (myUpdateProgress != null) {
|
||||
myUpdateProgress.cancel();
|
||||
myPassExecutorService.cancelAll();
|
||||
myPassExecutorService.cancelAll(false);
|
||||
cancelVisibleProgress();
|
||||
myUpdateProgress = null;
|
||||
}
|
||||
@@ -626,4 +626,8 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
return UpdateHighlightersUtil.getFileLeveleHighlights(project, file);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void clearPasses() {
|
||||
myPassExecutorService.cancelAll(true);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-13
@@ -61,7 +61,7 @@ public abstract class PassExecutorService implements Disposable {
|
||||
|
||||
private final Map<ScheduledPass, Job<Void>> mySubmittedPasses = new ConcurrentHashMap<ScheduledPass, Job<Void>>();
|
||||
private final Project myProject;
|
||||
private boolean isDisposed;
|
||||
private volatile boolean isDisposed;
|
||||
private final AtomicInteger nextPassId = new AtomicInteger(100);
|
||||
|
||||
public PassExecutorService(Project project) {
|
||||
@@ -70,28 +70,29 @@ public abstract class PassExecutorService implements Disposable {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for (Job<Void> submittedPass : mySubmittedPasses.values()) {
|
||||
submittedPass.cancel();
|
||||
}
|
||||
for (Job<Void> job : mySubmittedPasses.values()) {
|
||||
try {
|
||||
if (!job.isDone()) ((JobImpl)job).waitForTermination();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
LOG.error(throwable);
|
||||
}
|
||||
}
|
||||
cancelAll(true);
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
public void cancelAll() {
|
||||
public void cancelAll(boolean waitForTermination) {
|
||||
for (Job<Void> submittedPass : mySubmittedPasses.values()) {
|
||||
submittedPass.cancel();
|
||||
}
|
||||
if (waitForTermination) {
|
||||
for (Job<Void> job : mySubmittedPasses.values()) {
|
||||
try {
|
||||
if (!job.isDone()) ((JobImpl)job).waitForTermination();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
LOG.error(throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
mySubmittedPasses.clear();
|
||||
}
|
||||
|
||||
public void submitPasses(Map<FileEditor, HighlightingPass[]> passesMap, DaemonProgressIndicator updateProgress, final int jobPriority) {
|
||||
if (isDisposed()) return;
|
||||
int id = 1;
|
||||
|
||||
// (doc, passId) -> created pass
|
||||
|
||||
+3
-1
@@ -1086,7 +1086,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
public static List<HighlightInfo> instantiateAndRun(PsiFile file, Editor editor, int[] toIgnore, boolean allowDirt) {
|
||||
Project project = file.getProject();
|
||||
ensureIndexesUpToDate(project);
|
||||
FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project)).getFileStatusMap();
|
||||
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
|
||||
FileStatusMap fileStatusMap = codeAnalyzer.getFileStatusMap();
|
||||
for (int ignoreId : toIgnore) {
|
||||
fileStatusMap.markFileUpToDate(editor.getDocument(), file, ignoreId);
|
||||
}
|
||||
@@ -1108,6 +1109,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
}
|
||||
finally {
|
||||
fileStatusMap.allowDirt(true);
|
||||
codeAnalyzer.clearPasses();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user