Move: Do not create target directory outside of write-action
This commit is contained in:
+4
-4
@@ -489,7 +489,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
PsiDirectory sourceDirectory = getSourceDirectory(sourceFiles);
|
PsiDirectory sourceDirectory = getSourceDirectory(sourceFiles);
|
||||||
|
|
||||||
if (isMoveToPackage()) {
|
if (isMoveToPackage()) {
|
||||||
MoveDestination moveDestination = selectPackageBasedMoveDestination(true);
|
final MoveDestination moveDestination = selectPackageBasedMoveDestination(true);
|
||||||
if (moveDestination == null) return null;
|
if (moveDestination == null) return null;
|
||||||
|
|
||||||
final String targetFileName = sourceFiles.size() > 1 ? null : tfFileNameInPackage.getText();
|
final String targetFileName = sourceFiles.size() > 1 ? null : tfFileNameInPackage.getText();
|
||||||
@@ -533,15 +533,15 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All source files must be in the same directory
|
// All source files must be in the same directory
|
||||||
final PsiDirectory targetDir = moveDestination.getTargetDirectory(sourceFiles.get(0));
|
|
||||||
return new KotlinMoveTargetForDeferredFile(
|
return new KotlinMoveTargetForDeferredFile(
|
||||||
new FqName(getTargetPackage()),
|
new FqName(getTargetPackage()),
|
||||||
targetDir,
|
moveDestination.getTargetIfExists(sourceFiles.get(0)),
|
||||||
new Function1<KtFile, KtFile>() {
|
new Function1<KtFile, KtFile>() {
|
||||||
@Override
|
@Override
|
||||||
public KtFile invoke(@NotNull KtFile originalFile) {
|
public KtFile invoke(@NotNull KtFile originalFile) {
|
||||||
return JetRefactoringUtilKt.getOrCreateKotlinFile(
|
return JetRefactoringUtilKt.getOrCreateKotlinFile(
|
||||||
targetFileName != null ? targetFileName : originalFile.getName(), targetDir
|
targetFileName != null ? targetFileName : originalFile.getName(),
|
||||||
|
moveDestination.getTargetDirectory(originalFile)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user