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();
}
}
}
}
+ private boolean isNestedTarget(PsiDirectory directory) {
+ for (TargetDirectoryWrapper wrapper : myNestedDirsToMove.values()) {
+ if (directory == wrapper.getTargetDirectory()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Nullable
@Override
protected String getRefactoringId() {