Commit all documents after J2K (KT-13584, EA-82451)

New Kotlin file will be generated after converting, they are created for virtual files that were renamed from Java.
The exception happens when Java file was previously opened in editor, in that case text is restored through getLastCommittedText(document) where
document is resored for virtual file.

See: SingleRootFileViewProvider.VirtualFileContent.getText()

Exception descriptions also mention "Create Test" action as a problem source. The issue was reproduced when J2K convertion was performed
on test creation.

(cherry picked from commit e44260a)

 #KT-13584 Fixed
This commit is contained in:
Nikolay Krasko
2016-10-17 22:16:54 +03:00
committed by Nikolay Krasko
parent c5e8139236
commit a30d0d0f1e
@@ -89,7 +89,7 @@ class JavaToKotlinAction : AnAction() {
}
}
catch (e: IOException) {
MessagesEx.error(psiFile.project, e.message).showLater()
MessagesEx.error(psiFile.project, e.message ?: "").showLater()
}
}
return result
@@ -138,6 +138,8 @@ class JavaToKotlinAction : AnAction() {
externalCodeUpdate?.invoke()
PsiDocumentManager.getInstance(project).commitAllDocuments()
newFiles.singleOrNull()?.let {
FileEditorManager.getInstance(project).openFile(it, true)
}