IDEA-143309 Throwable on safe delete of a project file clion/142.3619
authorpeter <peter@jetbrains.com>
Thu, 30 Jul 2015 14:34:58 +0000 (16:34 +0200)
committerpeter <peter@jetbrains.com>
Thu, 30 Jul 2015 14:34:58 +0000 (16:34 +0200)
platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java

index 7a421846daf70dca4c762b39c6b3f0705dc5fca4..de10452ebac6ad84a066cb3fe02ed763967c3355 100644 (file)
@@ -23,7 +23,10 @@ import com.intellij.lang.refactoring.RefactoringSupportProvider;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.project.DumbModePermission;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
@@ -394,15 +397,20 @@ public class SafeDeleteProcessor extends BaseRefactoringProcessor {
         }
       }
 
-      for (PsiElement element : myElements) {
-        for(SafeDeleteProcessorDelegate delegate: Extensions.getExtensions(SafeDeleteProcessorDelegate.EP_NAME)) {
-          if (delegate.handlesElement(element)) {
-            delegate.prepareForDeletion(element);
+      DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, ProjectManager.getInstance().getOpenProjects(), new Runnable() {
+        @Override
+        public void run() {
+          for (PsiElement element : myElements) {
+            for (SafeDeleteProcessorDelegate delegate : Extensions.getExtensions(SafeDeleteProcessorDelegate.EP_NAME)) {
+              if (delegate.handlesElement(element)) {
+                delegate.prepareForDeletion(element);
+              }
+            }
+
+            element.delete();
           }
         }
-
-        element.delete();
-      }
+      });
     } catch (IncorrectOperationException e) {
       RefactoringUIUtil.processIncorrectOperation(myProject, e);
     }