use DumbService#completeJustSumbittedTasks in some places between VFS changes and...
authorpeter <peter@jetbrains.com>
Mon, 14 Nov 2016 19:31:22 +0000 (20:31 +0100)
committerpeter <peter@jetbrains.com>
Mon, 14 Nov 2016 19:32:34 +0000 (20:32 +0100)
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesUtil.java
platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java
platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesProcessor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassHandler.java

index a61a5c97bddf4df27a9f1fbcc93c5276223b0a83..a9f6dbb2a44ebd0625f8e225cc00ffee590afb5b 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.ide.util.DirectoryChooserUtil;
 import com.intellij.lang.java.JavaFindUsagesProvider;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.JavaProjectRootsUtil;
 import com.intellij.openapi.roots.ProjectFileIndex;
@@ -236,9 +237,12 @@ public class MoveClassesOrPackagesUtil {
     if (!Comparing.equal(moveDestination.getVirtualFile(), containingDirectory != null ? containingDirectory.getVirtualFile() : null)) {
       LOG.assertTrue(file.getVirtualFile() != null, aClass);
 
+      Project project = file.getProject();
       MoveFilesOrDirectoriesUtil.doMoveFile(file, moveDestination);
       file = moveDestination.findFile(file.getName());
 
+      DumbService.getInstance(project).completeJustSubmittedTasks();
+
       if (newPackage != null && file instanceof PsiClassOwner && !FileTypeUtils.isInServerPageFile(file) && !PsiUtil.isModuleFile(file)) {
         // Do not rely on class instance identity retention after setPackageName (Scala)
         String aClassName = aClass.getName();
index 485cabe5768cf626750e11a3cc8eac604e4b659c..8563d63b6553a8edeb97a89059b2ff38d33ecaae 100644 (file)
@@ -25,6 +25,7 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
 import com.intellij.openapi.progress.ProgressIndicatorProvider;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.ui.Queryable;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.TextRange;
@@ -366,6 +367,8 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
       }
       if (copyVFile == null) throw new IncorrectOperationException("File was not copied: " + vFile);
 
+      DumbService.getInstance(getProject()).completeJustSubmittedTasks();
+
       final PsiFile copyPsi = myManager.findFile(copyVFile);
       if (copyPsi == null) throw new IncorrectOperationException("Could not find file " + copyVFile + " after copying " + vFile);
       updateAddedFile(copyPsi);
index 3a67137e7ece6294975b30fe82e65350f44431cc..24a016633df99eda82d7493c687f2ba3d3007f11 100644 (file)
@@ -64,7 +64,6 @@ import com.intellij.util.Processor;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashSet;
 import com.intellij.util.containers.MultiMap;
-import com.intellij.util.ui.UIUtil;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -479,6 +478,8 @@ public abstract class BaseRefactoringProcessor implements Runnable {
         }
       });
 
+      DumbService.getInstance(myProject).completeJustSubmittedTasks();
+
       for(Map.Entry<RefactoringHelper, Object> e: preparedData.entrySet()) {
         //noinspection unchecked
         e.getKey().performOperation(myProject, e.getValue());
index f7158cb7dcfad470259681bd4f1a0b4766be406f..cf7ed622bf003c5ed539898fc76815d35ea14ef0 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.ide.util.EditorHelper;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.paths.PsiDynaReference;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.PsiDirectory;
@@ -181,6 +182,8 @@ public class MoveFilesOrDirectoriesProcessor extends BaseRefactoringProcessor {
       // sort by offset descending to process correctly several usages in one PsiElement [IDEADEV-33013]
       CommonRefactoringUtil.sortDepthFirstRightLeftOrder(usages);
 
+      DumbService.getInstance(myProject).completeJustSubmittedTasks();
+
       // fix references in moved files to outer files
       for (PsiFile movedFile : movedFiles) {
         MoveFileHandler.forElement(movedFile).updateMovedFile(movedFile);
index 035fecd5b531c75586ee1c2066d1a86908289727..e8904a8ade2b5b8437fbe7f531ad0b57eec08fea 100644 (file)
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.refactoring.move;
 
 import com.intellij.lang.FileASTNode;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.source.tree.Factory;
@@ -77,6 +78,8 @@ public class MoveGroovyClassHandler implements MoveClassHandler {
         if (!moveDestination.equals(file.getContainingDirectory())) {
           MoveFilesOrDirectoriesUtil.doMoveFile(file, moveDestination);
           file = moveDestination.findFile(file.getName());
+          assert file != null;
+          DumbService.getInstance(file.getProject()).completeJustSubmittedTasks();
           ((PsiClassOwner)file).setPackageName(newPackageName);
         }
         return ((GroovyFile)file).getScriptClass();