From 9406cb098e1fa2667a348100df77d54fe0325207 Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sat, 28 Sep 2024 09:39:31 +0400 Subject: [PATCH] Update mojo project structure under non blocking read action --- .../lang/mojolicious/model/MojoProjectManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java b/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java index 674744f5d4..b8b8066595 100644 --- a/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java +++ b/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java @@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiUtilCore; +import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.ui.update.MergingUpdateQueue; @@ -45,7 +46,6 @@ import org.jetbrains.annotations.TestOnly; import java.util.*; -import com.intellij.util.concurrency.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BooleanSupplier; @@ -132,7 +132,8 @@ private void updateModel() { LOG.debug("Attempting to update"); if (!myUpdatingModel.getAndSet(true)) { try { - ReadAction.run(() -> { + //noinspection deprecation + ReadAction.nonBlocking(() -> { if (myProject.isDisposed()) { LOG.warn("Project is disposed"); return; @@ -142,18 +143,18 @@ private void updateModel() { scheduleUpdate(); } else { - try{ + try { LOG.debug("Performing model update"); doUpdateModel(); } finally { - if( myTestSemaphore != null) { + if (myTestSemaphore != null) { myTestSemaphore.up(); myTestSemaphore = null; } } } - }); + }).executeSynchronously(); } catch (ProcessCanceledException e) { LOG.debug("Update was cancelled, rescheduling");