Copy: Filter out invalid elements to prevent PsiInvalidElementAccessException

#KT-12747 Fixed
(cherry picked from commit 4a0a440)
This commit is contained in:
Alexey Sedunov
2016-06-16 12:54:26 +03:00
parent 69704c017f
commit 296c7a16d3
2 changed files with 2 additions and 1 deletions
@@ -27,7 +27,7 @@ class CopyKotlinFileHandler : CopyHandlerDelegateBase() {
private fun adjustElements(elements: Array<out PsiElement>): Array<PsiElement>? {
return elements
.map { it.containingFile as? KtFile ?: return null }
.map { (if (it.isValid) it.containingFile as? KtFile else null) ?: return null }
.toTypedArray()
}