cleanup daemon tests: move TestDaemonCodeAnalyzer up

GitOrigin-RevId: be0c9d8f5f867bd0f640554ad2e4b928a746f872
This commit is contained in:
Alexey Kudravtsev
2026-02-09 15:58:56 +00:00
committed by intellij-monorepo-bot
parent 49c0bc888d
commit b101616dde
4 changed files with 9 additions and 8 deletions
@@ -325,7 +325,7 @@ public class DaemonRespondToChangesPerfTest extends DaemonAnalyzerTestCase {
codeAnalyzer.runPasses(psiFile, editor.getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, true, callbackWhileWaiting);
}
catch (ProcessCanceledException ignored) {
new TestDaemonCodeAnalyzerImpl(myProject).waitForTermination();
myTestDaemonCodeAnalyzer.waitForTermination();
continue;
}
fail("PCE must have been thrown");
@@ -165,13 +165,11 @@ import java.util.stream.Collectors;
@DaemonAnalyzerTestCase.CanChangeDocumentDuringHighlighting
public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/typing/";
private TestDaemonCodeAnalyzerImpl myTestDaemonCodeAnalyzer;
@Override
protected void setUp() throws Exception {
super.setUp();
enableInspectionTool(new UnusedDeclarationInspection());
myTestDaemonCodeAnalyzer = new TestDaemonCodeAnalyzerImpl(getProject());
UndoManager.getInstance(myProject);
myDaemonCodeAnalyzer.setUpdateByTimerEnabled(true);
}
@@ -177,7 +177,7 @@ public class FileStatusMapTest extends DaemonAnalyzerTestCase {
assertEmpty(highlightErrors());
PsiClass psiClass = ((PsiJavaFile)getFile()).getClasses()[0];
new RenameProcessor(myProject, psiClass, "Class2", false, false).run();
new TestDaemonCodeAnalyzerImpl(getProject()).waitForUpdateFileStatusBackgroundQueueInTests();
myTestDaemonCodeAnalyzer.waitForUpdateFileStatusBackgroundQueueInTests();
TextRange dirty = myDaemonCodeAnalyzer.getFileStatusMap().getFileDirtyScope(document, getFile(), Pass.UPDATE_ALL);
assertEquals(getFile().getTextRange(), dirty);
@@ -200,7 +200,7 @@ public class FileStatusMapTest extends DaemonAnalyzerTestCase {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
PsiElement elementAtCaret = myFile.findElementAt(myEditor.getCaretModel().getOffset());
assertTrue(elementAtCaret instanceof PsiWhiteSpace);
new TestDaemonCodeAnalyzerImpl(getProject()).waitForUpdateFileStatusBackgroundQueueInTests();
myTestDaemonCodeAnalyzer.waitForUpdateFileStatusBackgroundQueueInTests();
TextRange dirty = myDaemonCodeAnalyzer.getFileStatusMap().getFileDirtyScope(document, getFile(), Pass.UPDATE_ALL);
assertEquals(elementAtCaret.getTextRange(), dirty);
assertEmpty(highlightErrors());
@@ -272,7 +272,7 @@ public class FileStatusMapTest extends DaemonAnalyzerTestCase {
int offset = myEditor.getCaretModel().getOffset();
type(' ');
PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); // reset "defensively marked"
new TestDaemonCodeAnalyzerImpl(getProject()).waitForUpdateFileStatusBackgroundQueueInTests();
myTestDaemonCodeAnalyzer.waitForUpdateFileStatusBackgroundQueueInTests();
assertEquals(new TextRange(offset-1, offset+1), fileStatusMap.getFileDirtyScope(document, myFile, Pass.LOCAL_INSPECTIONS));
}
@@ -82,6 +82,7 @@ import java.util.List;
public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
private VirtualFileFilter myVirtualFileFilter = new FileTreeAccessFilter();
protected DaemonCodeAnalyzerImpl myDaemonCodeAnalyzer;
protected TestDaemonCodeAnalyzerImpl myTestDaemonCodeAnalyzer;
@Override
protected void setUp() throws Exception {
@@ -91,7 +92,8 @@ public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
InspectionsKt.configureInspections(tools, getProject(), getTestRootDisposable());
new TestDaemonCodeAnalyzerImpl(getProject()).prepareForTest();
myTestDaemonCodeAnalyzer = new TestDaemonCodeAnalyzerImpl(getProject());
myTestDaemonCodeAnalyzer.prepareForTest();
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
myDaemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject());
@@ -127,7 +129,7 @@ public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
((StartupManagerImpl)startupManager).checkCleared();
}
new TestDaemonCodeAnalyzerImpl(getProject()).cleanupAfterTest();
myTestDaemonCodeAnalyzer.cleanupAfterTest();
}
}
catch (Throwable e) {
@@ -139,6 +141,7 @@ public abstract class DaemonAnalyzerTestCase extends JavaCodeInsightTestCase {
}
finally {
myDaemonCodeAnalyzer = null;
myTestDaemonCodeAnalyzer = null;
}
}
}