Move: Fix top-level declaration detection for scripts

#KT-25858 Fixed
This commit is contained in:
Alexey Sedunov
2018-08-03 14:13:48 +03:00
parent 1797a50fc9
commit 1b15ce3ddc
6 changed files with 35 additions and 1 deletions
@@ -62,7 +62,7 @@ class MoveKotlinDeclarationsHandler : MoveHandlerDelegate() {
return elements.mapNotNullTo(LinkedHashSet(), getContainer).singleOrNull()
}
private fun KtNamedDeclaration.canMove() = if (this is KtClassOrObject) !isLocal else parent is KtFile
private fun KtNamedDeclaration.canMove() = if (this is KtClassOrObject) !isLocal else isTopLevelInFileOrScript(this)
private fun doMoveWithCheck(
project: Project, elements: Array<out PsiElement>, targetContainer: PsiElement?, callback: MoveCallback?, editor: Editor?