Move: Allow moving several files represented by their top-level declarations in the Project View (provided there is only one declaration per file)

This commit is contained in:
Alexey Sedunov
2015-05-13 16:08:11 +03:00
parent f08438c53c
commit 2bd21b0f37
@@ -69,8 +69,18 @@ public class MoveKotlinTopLevelDeclarationsHandler : MoveHandlerDelegate() {
[suppress("UNCHECKED_CAST")]
val elementsToSearch = elements.toSet() as Set<JetNamedDeclaration>
val sourceFile = elementsToSearch.mapTo(LinkedHashSet<JetFile>()) { it.getContainingJetFile() }.singleOrNull()
val sourceFiles = elementsToSearch.mapTo(LinkedHashSet<JetFile>()) { it.getContainingJetFile() }
val sourceFile = sourceFiles.singleOrNull()
if (sourceFile == null) {
if (sourceFiles.all { it.getDeclarations().size() == 1 }) {
MoveFilesOrDirectoriesUtil.doMove(project,
sourceFiles.toTypedArray(),
arrayOf(targetContainer),
null)
return true
}
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("move.title"), "All declarations must belong to the same file", null, project)
return false
}