From d81fe6158e0a778701d0b83f5867f26a5c2bb8a0 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 5 Apr 2016 13:42:07 +0200 Subject: [PATCH] try to finish dumb mode in the same context as it started --- .../src/com/intellij/openapi/project/DumbServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 9ff983c57c9f..2aea85777a30 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -60,6 +60,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica private static Throwable ourForcedTrace; private volatile boolean myDumb = false; private volatile Throwable myDumbStart; + private volatile TransactionId myDumbStartTransaction; private boolean myUpdateFinishedQueued; private final DumbModeListener myPublisher; private long myModificationCount; @@ -158,6 +159,8 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica @Override public void queueTask(@NotNull final DumbModeTask task) { + TransactionId contextTransaction = TransactionGuard.getInstance().getContextTransaction(); + final Throwable trace = ourForcedTrace != null ? ourForcedTrace : new Throwable(); // please report exceptions here to peter final DumbModePermission schedulerPermission = getExplicitPermission(); if (LOG.isDebugEnabled()) LOG.debug("Scheduling task " + task, trace); @@ -218,6 +221,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica myDumb = true; } myDumbStart = trace; + myDumbStartTransaction = contextTransaction; myModificationCount++; if (!myUpdateFinishedQueued) { try { @@ -539,7 +543,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica return result.get(); } - private static void invokeAndWaitIfNeeded(Runnable runnable) { + private void invokeAndWaitIfNeeded(Runnable runnable) { Application app = ApplicationManager.getApplication(); if (app.isDispatchThread()) { runnable.run(); @@ -551,7 +555,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica //todo remove invokeLater when transactions are executed in "any" modality state //noinspection SSBasedInspection SwingUtilities.invokeLater( - () -> TransactionGuard.submitTransaction(app, () -> { + () -> TransactionGuard.getInstance().submitMergeableTransaction(app, myDumbStartTransaction, () -> { try { runnable.run(); } finally {