diff --git a/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java b/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java index dfe723269290..5ebbb608bf1a 100644 --- a/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java +++ b/java/java-impl/src/com/intellij/codeInspection/inferNullity/InferNullityAnnotationsAction.java @@ -275,7 +275,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction { protected void restartAnalysis(final Project project, final AnalysisScope scope) { TransactionGuard guard = TransactionGuard.getInstance(); - TransactionId id = guard.getCurrentMergeableTransaction(); + TransactionId id = guard.getContextTransaction(); DumbService.getInstance(project).smartInvokeLater( () -> TransactionGuard.getInstance().submitMergeableTransaction(project, id, () -> { if (DumbService.isDumb(project)) { diff --git a/platform/core-api/src/com/intellij/openapi/application/TransactionGuard.java b/platform/core-api/src/com/intellij/openapi/application/TransactionGuard.java index 0a4835cbcafd..ed918995908e 100644 --- a/platform/core-api/src/com/intellij/openapi/application/TransactionGuard.java +++ b/platform/core-api/src/com/intellij/openapi/application/TransactionGuard.java @@ -174,7 +174,7 @@ public abstract class TransactionGuard { * and so it won't be run after it has been disposed. * @param mergeInto an optional id of another transaction, to allow execution inside that transaction if it's still running * @param transaction code to execute inside a transaction. - * @see #getCurrentMergeableTransaction() + * @see #getContextTransaction() */ public abstract void submitMergeableTransaction(@NotNull Disposable parentDisposable, @Nullable TransactionId mergeInto, @NotNull Runnable transaction); @@ -203,5 +203,5 @@ public abstract class TransactionGuard { * @return the id of the currently running transaction for using in {@link #submitMergeableTransaction(Disposable, TransactionId, Runnable)}, * or null if there's no transaction running or merging is not allowed in the callee context (e.g. from invokeLater). */ - public abstract TransactionId getCurrentMergeableTransaction(); + public abstract TransactionId getContextTransaction(); } diff --git a/platform/core-api/src/com/intellij/openapi/application/TransactionId.java b/platform/core-api/src/com/intellij/openapi/application/TransactionId.java index c42233849a6f..eefda0daddb0 100644 --- a/platform/core-api/src/com/intellij/openapi/application/TransactionId.java +++ b/platform/core-api/src/com/intellij/openapi/application/TransactionId.java @@ -3,7 +3,7 @@ package com.intellij.openapi.application; import com.intellij.openapi.Disposable; /** - * A unique object identifying each running transaction. Can be retrieved from {@link TransactionGuard#getCurrentMergeableTransaction()} + * A unique object identifying each running transaction. Can be retrieved from {@link TransactionGuard#getContextTransaction()} * while inside a transaction, and used to merge other transactions into it via * {@link TransactionGuard#submitMergeableTransaction(Disposable, TransactionId, Runnable)}. * diff --git a/platform/core-impl/src/com/intellij/openapi/application/TransactionGuardImpl.java b/platform/core-impl/src/com/intellij/openapi/application/TransactionGuardImpl.java index 1e22f661a12c..1002f305b867 100644 --- a/platform/core-impl/src/com/intellij/openapi/application/TransactionGuardImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/application/TransactionGuardImpl.java @@ -121,7 +121,7 @@ public class TransactionGuardImpl extends TransactionGuard { @Override public void submitMergeableTransaction(@NotNull final Disposable parentDisposable, @NotNull final TransactionKind kind, @NotNull final Runnable _transaction) { - submitMergeableTransaction(parentDisposable, kind, getCurrentMergeableTransaction(), _transaction); + submitMergeableTransaction(parentDisposable, kind, getContextTransaction(), _transaction); } @Override @@ -204,7 +204,7 @@ public class TransactionGuardImpl extends TransactionGuard { public void submitTransactionAndWait(@NotNull final Runnable runnable) throws ProcessCanceledException { Application app = ApplicationManager.getApplication(); if (app.isDispatchThread()) { - Transaction transaction = new Transaction(runnable, getCurrentMergeableTransaction(), TransactionKind.ANY_CHANGE, app); + Transaction transaction = new Transaction(runnable, getContextTransaction(), TransactionKind.ANY_CHANGE, app); if (!canRunTransactionNow(transaction, true)) { throw new AssertionError("Cannot run synchronous submitTransactionAndWait from invokeLater. " + "Please use asynchronous submit*Transaction. " + @@ -285,7 +285,7 @@ public class TransactionGuardImpl extends TransactionGuard { @Override public void submitTransactionLater(@NotNull final Disposable parentDisposable, @NotNull final Runnable transaction) { - final TransactionIdImpl id = getCurrentMergeableTransaction(); + final TransactionIdImpl id = getContextTransaction(); Application app = ApplicationManager.getApplication(); app.invokeLater(new Runnable() { @Override @@ -296,7 +296,7 @@ public class TransactionGuardImpl extends TransactionGuard { } @Override - public TransactionIdImpl getCurrentMergeableTransaction() { + public TransactionIdImpl getContextTransaction() { if (!ApplicationManager.getApplication().isDispatchThread()) { ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator(); return indicator != null ? myProgresses.get(indicator) : null; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java b/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java index b2705bdccf84..ca30c748e082 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java @@ -222,7 +222,7 @@ public class AutoPopupController implements Disposable { } public static void runTransactionWithEverythingCommitted(@NotNull final Project project, @NotNull final Runnable runnable) { TransactionGuard guard = TransactionGuard.getInstance(); - TransactionId id = guard.getCurrentMergeableTransaction(); + TransactionId id = guard.getContextTransaction(); ModalityState modalityState = ModalityState.current(); final PsiDocumentManager pdm = PsiDocumentManager.getInstance(project); pdm.performWhenAllCommitted(() -> { diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java index 9b6500f42bea..0b64aa73953e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressWindow.java @@ -96,7 +96,7 @@ public class ProgressWindow extends ProgressIndicatorBase implements BlockingPro myCancelText = cancelText; setModalityProgress(shouldShowBackground ? null : this); TransactionGuardImpl guard = (TransactionGuardImpl)TransactionGuard.getInstance(); - guard.registerProgress(this, guard.getCurrentMergeableTransaction()); + guard.registerProgress(this, guard.getContextTransaction()); myFocusTrackback = new FocusTrackback(this, WindowManager.getInstance().suggestParentWindow(project), false); diff --git a/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.groovy b/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.groovy index 1465e8aed36f..13bc5d246db6 100644 --- a/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.groovy +++ b/platform/platform-tests/testSrc/com/intellij/application/TransactionTest.groovy @@ -73,7 +73,7 @@ class TransactionTest extends LightPlatformTestCase { public void "test no current id inside invokeLater"() { SwingUtilities.invokeLater { log << '2' - assert !guard.currentMergeableTransaction + assert !guard.contextTransaction } TransactionGuard.submitTransaction testRootDisposable, { log << '1' @@ -86,12 +86,12 @@ class TransactionTest extends LightPlatformTestCase { public void "test has id inside nested transaction"() { TransactionGuard.submitTransaction testRootDisposable, { log << '1' - def id = guard.currentMergeableTransaction + def id = guard.contextTransaction assert id TransactionGuard.submitTransaction testRootDisposable, { log << '2' - assert guard.currentMergeableTransaction - assert id != guard.currentMergeableTransaction + assert guard.contextTransaction + assert id != guard.contextTransaction } assert log == ['1', '2'] } @@ -101,11 +101,11 @@ class TransactionTest extends LightPlatformTestCase { public void "test modal progress started from inside a transaction has the same id"() { TransactionGuard.submitTransaction testRootDisposable, { log << '1' - def id = guard.currentMergeableTransaction + def id = guard.contextTransaction assert id ProgressManager.instance.runProcessWithProgressSynchronously({ assert !ApplicationManager.application.dispatchThread - assert id == guard.currentMergeableTransaction + assert id == guard.contextTransaction log << '2' }, 'title', true, project) } @@ -116,7 +116,7 @@ class TransactionTest extends LightPlatformTestCase { log << '1' ApplicationManager.application.executeOnPooledThread({ assert !ApplicationManager.application.dispatchThread - assert !guard.currentMergeableTransaction + assert !guard.contextTransaction log << '2' }).get() } @@ -138,7 +138,7 @@ class TransactionTest extends LightPlatformTestCase { public void "test do not merge into newly started nested transactions"() { TransactionGuard.submitTransaction testRootDisposable, { log << '1' - def id = guard.currentMergeableTransaction + def id = guard.contextTransaction SwingUtilities.invokeLater { guard.submitMergeableTransaction testRootDisposable, id, { log << '4' } } @@ -147,7 +147,7 @@ class TransactionTest extends LightPlatformTestCase { log << '2' UIUtil.dispatchAllInvocationEvents() guard.submitMergeableTransaction testRootDisposable, id, { log << '5' } - def nestedId = guard.currentMergeableTransaction + def nestedId = guard.contextTransaction SwingUtilities.invokeLater { guard.submitMergeableTransaction testRootDisposable, nestedId, { log << '3' } assert log == ['1', '2']