classpath jar: support optional plugin dependencies (IDEA-144134)
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Thu, 20 Aug 2015 08:54:56 +0000 (10:54 +0200)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Thu, 20 Aug 2015 09:00:59 +0000 (11:00 +0200)
platform/lang-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveDirectoryWithClassesProcessor.java

index 8617a33fb4bbf56b7c0ff89c523aba202dfd6c11..2c930306b75260c53a3885bf2b386e69000dd685 100644 (file)
@@ -198,7 +198,7 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
       for (PsiDirectory directory : myDirectories) {
         final TargetDirectoryWrapper wrapper = myNestedDirsToMove.get(directory);
         final PsiDirectory targetDirectory = wrapper.getTargetDirectory();
-        if (targetDirectory == null || !PsiTreeUtil.isAncestor(directory, targetDirectory, false)) {
+        if (targetDirectory == null || !PsiTreeUtil.isAncestor(directory, targetDirectory, false) && !isNestedTarget(directory)) {
           directory.delete();
         }
       }
@@ -209,6 +209,15 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
     }
   }
 
+  private boolean isNestedTarget(PsiDirectory directory) {
+    for (TargetDirectoryWrapper wrapper : myNestedDirsToMove.values()) {
+      if (directory == wrapper.getTargetDirectory()) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   @Nullable
   @Override
   protected String getRefactoringId() {