From 6055933258455d6f2db24e9769993d31ec625c07 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 19 Jun 2015 21:01:30 +0300 Subject: [PATCH] Copy: CopyFileHandler must support all elements inside of Kotlin file (in the absence of more specific handlers) #KT-8175 Fixed --- .../idea/refactoring/copy/CopyKotlinFileHandler.kt | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt index adef942ad8a..d97b4582796 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinFileHandler.kt @@ -18,27 +18,17 @@ package org.jetbrains.kotlin.idea.refactoring.copy import com.intellij.psi.PsiDirectory import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile import com.intellij.refactoring.copy.CopyFilesOrDirectoriesHandler import com.intellij.refactoring.copy.CopyHandlerDelegateBase -import org.jetbrains.kotlin.psi.JetClassOrObject import org.jetbrains.kotlin.psi.JetFile public class CopyKotlinFileHandler : CopyHandlerDelegateBase() { private val delegate = CopyFilesOrDirectoriesHandler() private fun adjustElements(elements: Array): Array? { - val adjustedElements = elements - .map { - val file = it.getContainingFile() - when { - it is JetFile -> it - it is JetClassOrObject && it.isTopLevel() && (file as JetFile).getDeclarations().size() == 1 -> file - else -> return null - } - } + return elements + .map { it.getContainingFile() as? JetFile ?: return null } .toTypedArray() - return adjustedElements } override fun canCopy(elements: Array, fromUpdate: Boolean): Boolean {