use of com.intellij.codeInsight.intention.AbstractIntentionAction in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testLightBulbDoesNotUpdateIntentionsInEDT.
public void testLightBulbDoesNotUpdateIntentionsInEDT() throws Exception {
final IntentionAction longLongUpdate = new AbstractIntentionAction() {
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
}
@Nls
@NotNull
@Override
public String getText() {
return "LongAction";
}
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (ApplicationManager.getApplication().isDispatchThread()) {
throw new RuntimeException("Must not update actions in EDT");
}
return true;
}
};
IntentionManager.getInstance().addAction(longLongUpdate);
Disposer.register(getTestRootDisposable(), () -> IntentionManager.getInstance().unregisterIntention(longLongUpdate));
configureByText(JavaFileType.INSTANCE, "class X { <caret> }");
makeEditorWindowVisible(new Point(0, 0), myEditor);
doHighlighting();
myDaemonCodeAnalyzer.restart();
executeWithReparseDelay(() -> {
for (int i = 0; i < 1000; i++) {
caretRight();
UIUtil.dispatchAllInvocationEvents();
caretLeft();
DaemonProgressIndicator updateProgress = myDaemonCodeAnalyzer.getUpdateProgress();
while (myDaemonCodeAnalyzer.getUpdateProgress() == updateProgress) {
// wait until daemon started
UIUtil.dispatchAllInvocationEvents();
}
long start = System.currentTimeMillis();
while (myDaemonCodeAnalyzer.isRunning() && System.currentTimeMillis() < start + 500) {
// wait for a bit more until ShowIntentionsPass.doApplyInformationToEditor() called
UIUtil.dispatchAllInvocationEvents();
}
}
});
}
Aggregations