Do not use methods which may show UI dialog in write action in refactorings

#KT-33082 fixed
This commit is contained in:
Ilya Kirillov
2019-08-01 12:59:59 +03:00
parent 474a8850b3
commit 6b0c1da42c
2 changed files with 6 additions and 3 deletions
@@ -327,7 +327,7 @@ fun <T> chooseContainerElement(
toPsi: (T) -> PsiElement, toPsi: (T) -> PsiElement,
onSelect: (T) -> Unit onSelect: (T) -> Unit
) { ) {
return getPsiElementPopup( val popup = getPsiElementPopup(
editor, editor,
containers, containers,
object : PsiElementListCellRenderer<PsiElement>() { object : PsiElementListCellRenderer<PsiElement>() {
@@ -392,7 +392,10 @@ fun <T> chooseContainerElement(
onSelect(it) onSelect(it)
true true
} }
).showInBestPositionFor(editor) )
ApplicationManager.getApplication().invokeLater {
popup.showInBestPositionFor(editor)
}
} }
fun <T> chooseContainerElementIfNecessary( fun <T> chooseContainerElementIfNecessary(
@@ -57,7 +57,7 @@ fun invokeMoveFilesOrDirectoriesRefactoring(
val elementsToMove = elements val elementsToMove = elements
.filterNot { .filterNot {
it is PsiFile it is PsiFile
&& runWriteAction { CopyFilesOrDirectoriesHandler.checkFileExist(selectedDir, choice, it, it.name, "Move") } && CopyFilesOrDirectoriesHandler.checkFileExist(selectedDir, choice, it, it.name, "Move")
} }
.sortedWith( // process Kotlin files first so that light classes are updated before changing references in Java files .sortedWith( // process Kotlin files first so that light classes are updated before changing references in Java files
java.util.Comparator { o1, o2 -> java.util.Comparator { o1, o2 ->