From ee4f459bc7d43d660e225ab09ef78361e9bf998f Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Mon, 11 Jan 2016 19:28:36 +0300 Subject: [PATCH] type migration: wait an answer from dialog even process is finished IDEA-150179 --- .../refactoring/typeMigration/TypeMigrationLabeler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java index 44dddd9642eb..fc11f9133a53 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java @@ -45,6 +45,7 @@ import com.intellij.refactoring.typeMigration.usageInfo.OverriderUsageInfo; import com.intellij.refactoring.typeMigration.usageInfo.TypeMigrationUsageInfo; import com.intellij.usageView.UsageInfo; import com.intellij.util.*; +import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.*; import com.intellij.util.graph.DFSTBuilder; import com.intellij.util.graph.GraphGenerator; @@ -65,6 +66,7 @@ public class TypeMigrationLabeler { private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.typeMigration.TypeMigrationLabeler"); private boolean myShowWarning = true; private volatile MigrateException myException; + private final Semaphore myDialogSemaphore = new Semaphore(); public TypeMigrationRules getRules() { return myRules; @@ -756,6 +758,7 @@ public class TypeMigrationLabeler { boolean addRoot(final TypeMigrationUsageInfo usageInfo, final PsiType type, final PsiElement place, boolean alreadyProcessed) { if (myShowWarning && myMigrationRoots.size() > 10 && !ApplicationManager.getApplication().isUnitTestMode()) { myShowWarning = false; + myDialogSemaphore.down(); try { final Runnable checkTimeToStopRunnable = new Runnable() { public void run() { @@ -763,6 +766,7 @@ public class TypeMigrationLabeler { Messages.getWarningIcon()) == Messages.YES) { myException = new MigrateException(); } + myDialogSemaphore.up(); } }; SwingUtilities.invokeLater(checkTimeToStopRunnable); @@ -1023,6 +1027,11 @@ public class TypeMigrationLabeler { iterate(); } } + + myDialogSemaphore.waitFor(); + if (myException != null) { + throw myException; + } } public TypeEvaluator getTypeEvaluator() {