diff --git a/annotations/com/intellij/refactoring/annotations.xml b/annotations/com/intellij/refactoring/annotations.xml
index e2d931e952d..df013310544 100644
--- a/annotations/com/intellij/refactoring/annotations.xml
+++ b/annotations/com/intellij/refactoring/annotations.xml
@@ -1,4 +1,13 @@
+ -
+
+
+
+
+ -
+
+
-
diff --git a/annotations/com/intellij/refactoring/listeners/impl/annotations.xml b/annotations/com/intellij/refactoring/listeners/impl/annotations.xml
new file mode 100644
index 00000000000..a5a12512696
--- /dev/null
+++ b/annotations/com/intellij/refactoring/listeners/impl/annotations.xml
@@ -0,0 +1,6 @@
+
+
-
+
+
+
diff --git a/annotations/com/intellij/usageView/annotations.xml b/annotations/com/intellij/usageView/annotations.xml
index ac5915627cc..5a44a43f80f 100644
--- a/annotations/com/intellij/usageView/annotations.xml
+++ b/annotations/com/intellij/usageView/annotations.xml
@@ -5,4 +5,8 @@
-
+ -
+
+
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/psiUtil/jetPsiUtil.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/psiUtil/jetPsiUtil.kt
index 883e247b4ae..e092dfd589e 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/psiUtil/jetPsiUtil.kt
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/psiUtil/jetPsiUtil.kt
@@ -262,4 +262,8 @@ public fun JetSimpleNameExpression.getOutermostNonInterleavingQualifiedElement()
}
}
-public fun PsiDirectory.getPackage(): PsiPackage? = JavaDirectoryService.getInstance()!!.getPackage(this)
\ No newline at end of file
+public fun PsiDirectory.getPackage(): PsiPackage? = JavaDirectoryService.getInstance()!!.getPackage(this)
+
+public fun JetModifierListOwner.isPrivate(): Boolean = hasModifier(JetTokens.PRIVATE_KEYWORD)
+
+public fun PsiElement.isInsideOf(elements: Iterable): Boolean = elements.any { it.isAncestor(this) }
\ No newline at end of file
diff --git a/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/lightClassUtils.kt b/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/lightClassUtils.kt
index de39b1ea68a..e24766091f6 100644
--- a/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/lightClassUtils.kt
+++ b/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/lightClassUtils.kt
@@ -41,15 +41,15 @@ import org.jetbrains.jet.lang.psi.JetCallableDeclaration
import org.jetbrains.jet.lang.psi.psiUtil.isExtensionDeclaration
import com.intellij.psi.PsiClass
-fun JetClassOrObject.toLightClass(): PsiClass? = LightClassUtil.getPsiClass(this)
+fun JetClassOrObject.toLightClass(): KotlinLightClass? = LightClassUtil.getPsiClass(this) as KotlinLightClass?
-public fun JetDeclaration.toLightElements(): List =
+public fun JetDeclaration.toLightElements(): List =
when (this) {
is JetClassOrObject -> Collections.singletonList(LightClassUtil.getPsiClass(this))
is JetNamedFunction -> Collections.singletonList(LightClassUtil.getLightClassMethod(this))
is JetProperty -> LightClassUtil.getLightClassPropertyMethods(this).toList()
is JetPropertyAccessor -> Collections.singletonList(LightClassUtil.getLightClassAccessorMethod(this))
- is JetParameter -> ArrayList().let { elements ->
+ is JetParameter -> ArrayList().let { elements ->
toPsiParameter()?.let { psiParameter -> elements.add(psiParameter) }
LightClassUtil.getLightClassPropertyMethods(this).toCollection(elements)
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/JetFileReferencesResolver.kt b/idea/src/org/jetbrains/jet/plugin/codeInsight/JetFileReferencesResolver.kt
index 7fd0e842ef1..4acb59ce4e9 100644
--- a/idea/src/org/jetbrains/jet/plugin/codeInsight/JetFileReferencesResolver.kt
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/JetFileReferencesResolver.kt
@@ -28,8 +28,19 @@ import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
import org.jetbrains.jet.lang.psi.JetExpression
import org.jetbrains.jet.lang.psi.JetCallExpression
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
+import java.util.Collections
object JetFileReferencesResolver {
+ fun resolve(
+ element: JetElement,
+ visitReceivers: Boolean = true,
+ visitShortNames: Boolean = true
+ ): Map {
+ return (element.getContainingFile() as? JetFile)?.let { file ->
+ resolve(file, listOf(element), visitReceivers, visitShortNames)
+ } ?: Collections.emptyMap()
+ }
+
fun resolve(
file: JetFile,
elements: Iterable? = null,
diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinShortenReferencesRefactoringHelper.kt b/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinShortenReferencesRefactoringHelper.kt
index 5fb23b3db54..3a33384a8f1 100644
--- a/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinShortenReferencesRefactoringHelper.kt
+++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/KotlinShortenReferencesRefactoringHelper.kt
@@ -72,7 +72,6 @@ private fun Project.clearElementsToShorten() {
}
public fun JetElement.addToShorteningWaitSet() {
- assert (this is JetQualifiedExpression || this is JetSimpleNameExpression || this is JetUserType, "Unexpected element type: ${getClass()}: ${getText()}")
assert (ApplicationManager.getApplication()!!.isWriteAccessAllowed(), "Write access needed")
val project = getProject()
project.getElementsToShorten(true)!!.add(SmartPointerManager.getInstance(project)!!.createSmartPsiElementPointer(this))
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties
index b1ec05936ea..4da8c73edea 100644
--- a/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/JetRefactoringBundle.properties
@@ -19,3 +19,5 @@ parameter.name.is.invalid=Parameter name ''{0}'' is invalid
parameter.type.is.invalid=Parameter type ''{0}'' is invalid
column.name.val.var=Val/Var
+package.private.0.will.no.longer.be.accessible.from.1=Package-private {0} will no longer be accessible from {1}
+0.uses.package.private.1={0} uses package-private {1}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/jetRefactoringUtil.kt
index ddbc7a529b1..5a710edf8c6 100644
--- a/idea/src/org/jetbrains/jet/plugin/refactoring/jetRefactoringUtil.kt
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/jetRefactoringUtil.kt
@@ -95,4 +95,11 @@ public fun PsiElement.getKotlinFqName(): FqName? {
is JetNamedDeclaration -> JetPsiUtil.getFQName(element)
else -> null
}
+}
+
+public fun PsiElement.getUsageContext(): PsiElement {
+ return when (this) {
+ is JetElement -> PsiTreeUtil.getParentOfType(this, javaClass(), javaClass())!!
+ else -> ConflictsUtil.getContainer(this)
+ }
}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt
new file mode 100644
index 00000000000..b6047ded37d
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2010-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations
+
+import com.intellij.refactoring.BaseRefactoringProcessor
+import com.intellij.openapi.project.Project
+import com.intellij.usageView.UsageInfo
+import com.intellij.usageView.UsageViewDescriptor
+import com.intellij.refactoring.MoveDestination
+import com.intellij.refactoring.move.MoveCallback
+import com.intellij.refactoring.move.MoveMultipleElementsViewDescriptor
+import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesUtil
+import com.intellij.usageView.UsageViewUtil
+import com.intellij.openapi.diagnostic.Logger
+import com.intellij.psi.PsiElement
+import com.intellij.refactoring.util.NonCodeUsageInfo
+import com.intellij.refactoring.move.moveClassesOrPackages.CommonMoveUtil
+import com.intellij.util.IncorrectOperationException
+import com.intellij.refactoring.util.RefactoringUIUtil
+import org.jetbrains.jet.utils.keysToMap
+import com.intellij.refactoring.rename.RenameUtil
+import com.intellij.refactoring.move.MoveClassesOrPackagesCallback
+import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle
+import com.intellij.openapi.util.text.StringUtil
+import com.intellij.psi.PsiDirectory
+import org.jetbrains.jet.lang.psi.psiUtil.getPackage
+import org.jetbrains.jet.lang.psi.JetFile
+import org.jetbrains.jet.plugin.refactoring.move.PackageNameInfo
+import org.jetbrains.jet.lang.psi.JetPsiUtil
+import org.jetbrains.jet.lang.resolve.name.FqName
+import org.jetbrains.jet.plugin.refactoring.createKotlinFile
+import org.jetbrains.jet.plugin.refactoring.move.updateInternalReferencesOnPackageNameChange
+import org.jetbrains.jet.plugin.codeInsight.addToShorteningWaitSet
+import org.jetbrains.jet.plugin.refactoring.move.getFileNameAfterMove
+import org.jetbrains.jet.lang.psi.JetNamedDeclaration
+import org.jetbrains.jet.asJava.toLightElements
+import java.util.HashMap
+import org.jetbrains.jet.utils.flatten
+import java.util.ArrayList
+import java.util.HashSet
+import com.intellij.psi.PsiReference
+import com.intellij.psi.search.searches.ReferencesSearch
+import com.intellij.psi.search.GlobalSearchScope
+import com.intellij.refactoring.util.MoveRenameUsageInfo
+import com.intellij.psi.PsiClass
+import com.intellij.refactoring.util.TextOccurrencesUtil
+import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassHandler
+import com.intellij.util.containers.MultiMap
+import org.jetbrains.jet.asJava.namedUnwrappedElement
+import org.jetbrains.jet.lang.psi.psiUtil.isPrivate
+import org.jetbrains.jet.plugin.refactoring.getUsageContext
+import com.intellij.refactoring.util.CommonRefactoringUtil
+import org.jetbrains.jet.lang.psi.psiUtil.isInsideOf
+import org.jetbrains.jet.plugin.codeInsight.JetFileReferencesResolver
+import org.jetbrains.jet.lang.resolve.BindingContext
+import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
+import org.jetbrains.jet.lang.psi.JetModifierListOwner
+import com.intellij.psi.PsiModifierListOwner
+import com.intellij.psi.PsiModifier
+import com.intellij.util.VisibilityUtil
+import com.intellij.openapi.util.Ref
+import org.jetbrains.jet.plugin.refactoring.getKotlinFqName
+import org.jetbrains.jet.plugin.references.JetSimpleNameReference.ShorteningMode
+
+public class MoveKotlinTopLevelDeclarationsOptions(
+ val elementsToMove: Collection,
+ val moveDestination: MoveDestination,
+ val searchInCommentsAndStrings: Boolean = true,
+ val searchInNonCode: Boolean = true,
+ val moveCallback: MoveCallback? = null
+)
+
+public class MoveKotlinTopLevelDeclarationsProcessor(project: Project, val options: MoveKotlinTopLevelDeclarationsOptions) : BaseRefactoringProcessor(project) {
+ class object {
+ private val LOG: Logger = Logger.getInstance(javaClass())
+
+ private val REFACTORING_NAME: String = JetRefactoringBundle.message("refactoring.move.top.level.declarations")!!
+ }
+
+ private var nonCodeUsages: Array? = null
+ private val kotlinToLightElements = options.elementsToMove.keysToMap { it.toLightElements() }
+ private val conflicts = MultiMap()
+
+ override fun createUsageViewDescriptor(usages: Array?): UsageViewDescriptor {
+ return MoveMultipleElementsViewDescriptor(
+ options.elementsToMove.copyToArray(),
+ MoveClassesOrPackagesUtil.getPackageName(options.moveDestination.getTargetPackage())
+ )
+ }
+
+ override fun findUsages(): Array {
+ val newPackageName = options.moveDestination.getTargetPackage()?.getQualifiedName() ?: ""
+
+ fun collectUsages(): List {
+ return kotlinToLightElements.values().flatten().flatMap { lightElement ->
+ val newFqName = StringUtil.getQualifiedName(newPackageName, lightElement.getName())
+
+ val foundReferences = HashSet()
+ val projectScope = GlobalSearchScope.projectScope(lightElement.getProject())
+ val results = ReferencesSearch
+ .search(lightElement, projectScope, false)
+ .mapTo(ArrayList()) { ref ->
+ if (foundReferences.add(ref)) {
+ val range = ref.getRangeInElement()!!
+ MoveRenameUsageInfo(ref.getElement(), ref, range.getStartOffset(), range.getEndOffset(), lightElement, false)
+ }
+ else null
+ }
+ .filterNotNull()
+
+ val name = lightElement.getKotlinFqName()?.asString()
+ if (name != null) {
+ TextOccurrencesUtil.findNonCodeUsages(
+ lightElement,
+ name,
+ options.searchInCommentsAndStrings,
+ options.searchInNonCode,
+ newFqName,
+ results
+ )
+ }
+
+ MoveClassHandler.EP_NAME.getExtensions().forEach { handler -> handler.preprocessUsages(results) }
+
+ results
+ }
+ }
+
+ /*
+ There must be a conflict if all of the following conditions are satisfied:
+ declaration is package-private
+ usage does not belong to target package
+ usage is not being moved together with declaration
+ */
+
+ fun collectConflictsInUsages(usages: List) {
+ val declarationToContainers = HashMap>()
+ for (usage in usages) {
+ val element = usage.getElement()
+ if (element == null || usage !is MoveRenameUsageInfo || usage is NonCodeUsageInfo) continue
+
+ val declaration = usage.getReferencedElement()?.namedUnwrappedElement as? JetNamedDeclaration
+ if (declaration == null || !declaration.isPrivate()) continue
+
+ if (element.isInsideOf(options.elementsToMove)) continue
+
+ val container = element.getUsageContext()
+ if (!declarationToContainers.getOrPut(declaration) { HashSet() }.add(container)) continue
+
+ val currentPackage = element.getContainingFile()?.getContainingDirectory()?.getPackage()
+ if (currentPackage?.getQualifiedName() == newPackageName) continue
+
+ conflicts.putValue(
+ declaration,
+ JetRefactoringBundle.message(
+ "package.private.0.will.no.longer.be.accessible.from.1",
+ RefactoringUIUtil.getDescription(declaration, true),
+ RefactoringUIUtil.getDescription(container, true)
+ )
+ )
+ }
+ }
+
+ fun collectConflictsInDeclarations() {
+ val declarationToReferenceTargets = HashMap>()
+ for (declaration in options.elementsToMove) {
+ val referenceToContext = JetFileReferencesResolver.resolve(element = declaration, visitReceivers = false)
+ for ((refExpr, bindingContext) in referenceToContext) {
+ val refTarget = bindingContext[BindingContext.REFERENCE_TARGET, refExpr]?.let { descriptor ->
+ DescriptorToDeclarationUtil.getDeclaration(declaration.getProject(), descriptor, bindingContext)
+ }
+ if (refTarget == null || refTarget.isInsideOf(options.elementsToMove)) continue
+
+ val packagePrivate = when(refTarget) {
+ is JetModifierListOwner ->
+ refTarget.isPrivate()
+ is PsiModifierListOwner ->
+ VisibilityUtil.getVisibilityModifier(refTarget.getModifierList()) == PsiModifier.PACKAGE_LOCAL
+ else -> false
+ }
+
+ if (!packagePrivate) continue
+
+ if (!declarationToReferenceTargets.getOrPut(declaration) { HashSet() }.add(refTarget)) continue
+
+ val currentPackage = declaration.getContainingFile()?.getContainingDirectory()?.getPackage()
+ if (currentPackage?.getQualifiedName() == newPackageName) continue
+
+ conflicts.putValue(
+ declaration,
+ JetRefactoringBundle.message(
+ "0.uses.package.private.1",
+ RefactoringUIUtil.getDescription(declaration, true),
+ RefactoringUIUtil.getDescription(refTarget, true)
+ )!!.capitalize()
+ )
+ }
+ }
+ }
+
+ val usages = collectUsages()
+ collectConflictsInUsages(usages)
+ collectConflictsInDeclarations()
+ return UsageViewUtil.removeDuplicatedUsages(usages.copyToArray())
+ }
+
+ override fun preprocessUsages(refUsages: Ref>): Boolean {
+ return showConflicts(conflicts, refUsages.get())
+ }
+
+ override fun performRefactoring(usages: Array?) {
+ fun moveDeclaration(declaration: JetNamedDeclaration, moveDestination: PsiDirectory): JetNamedDeclaration? {
+ val newPackage = moveDestination.getPackage()
+ if (newPackage == null) return null
+
+ val file = declaration.getContainingFile() as? JetFile
+ if (file == null) return null
+
+ val packageNameInfo = PackageNameInfo(JetPsiUtil.getFQName(file), FqName(newPackage.getQualifiedName()))
+
+ val existingFile = if (moveDestination != file.getContainingDirectory()) moveDestination.findFile(file.getName()) else null
+ val newFile = existingFile ?: declaration.getFileNameAfterMove()?.let {
+ fileName -> createKotlinFile(fileName, moveDestination)
+ }
+ assert(newFile != null, "Couldn't create Koltin file for: ${declaration.getClass()}: ${declaration.getText()}")
+
+ declaration.updateInternalReferencesOnPackageNameChange(packageNameInfo, ShorteningMode.NO_SHORTENING)
+ val newElement = newFile!!.add(declaration) as JetNamedDeclaration
+ declaration.delete()
+
+ newElement.addToShorteningWaitSet()
+
+ return newElement
+ }
+
+ try {
+ val oldToNewElementsMapping = HashMap()
+ for ((oldDeclaration, oldLightElements) in kotlinToLightElements) {
+ val targetDirectory = options.moveDestination.getTargetDirectory(oldDeclaration.getContainingFile())
+ if (targetDirectory == null) continue
+
+ val newDeclaration = moveDeclaration(oldDeclaration, targetDirectory)
+ if (newDeclaration == null) continue
+
+ getTransaction()!!.getElementListener(oldDeclaration).elementMoved(newDeclaration)
+ for ((oldElement, newElement) in oldLightElements.iterator() zip newDeclaration.toLightElements().iterator()) {
+ oldToNewElementsMapping[oldElement] = newElement
+ }
+ }
+
+ nonCodeUsages = CommonMoveUtil.retargetUsages(usages, oldToNewElementsMapping)
+ }
+ catch (e: IncorrectOperationException) {
+ nonCodeUsages = null
+ RefactoringUIUtil.processIncorrectOperation(myProject, e)
+ }
+ }
+
+ override fun performPsiSpoilingRefactoring() {
+ nonCodeUsages?.let { nonCodeUsages -> RenameUtil.renameNonCodeUsages(myProject, nonCodeUsages) }
+
+ options.moveCallback?.let { moveCallback ->
+ if (moveCallback is MoveClassesOrPackagesCallback) {
+ moveCallback.classesOrPackagesMoved(options.moveDestination)
+ }
+ moveCallback.refactoringCompleted()
+ }
+ }
+
+ override fun getCommandName(): String = REFACTORING_NAME
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveUtils.kt
index 1ac5a1af63f..4ef32078001 100644
--- a/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveUtils.kt
+++ b/idea/src/org/jetbrains/jet/plugin/refactoring/move/moveUtils.kt
@@ -27,6 +27,11 @@ import org.jetbrains.jet.lang.resolve.name.FqName
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.psi.JetElement
import org.jetbrains.jet.plugin.references.JetSimpleNameReference.ShorteningMode
+import com.intellij.psi.PsiClass
+import org.jetbrains.jet.asJava.KotlinLightClass
+import org.jetbrains.jet.plugin.JetFileType
+import org.jetbrains.jet.lang.psi.JetClassOrObject
+import org.jetbrains.jet.lang.psi.JetNamedDeclaration
public class PackageNameInfo(val oldPackageName: FqName, val newPackageName: FqName)
@@ -59,4 +64,10 @@ public fun JetElement.updateInternalReferencesOnPackageNameChange(
}
}
}
+}
+
+public fun JetNamedDeclaration.getFileNameAfterMove(): String? {
+ return (getContainingFile() as? JetFile)?.let { file ->
+ if (file.getDeclarations().size > 1) "${getName()}.${JetFileType.INSTANCE.getDefaultExtension()}" else file.getName()
+ }
}
\ No newline at end of file
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/_a/noImports.kt
new file mode 100644
index 00000000000..acbf910e155
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/_a/noImports.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..8c0461e0e74
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/_a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/main.kt
new file mode 100644
index 00000000000..fb2fc43b29e
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test
+
+fun test(): Test {
+ return Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/noImports.java
new file mode 100644
index 00000000000..c5fa6db1721
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/noImports.java
@@ -0,0 +1,9 @@
+package a;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/noImports.kt
new file mode 100644
index 00000000000..acbf910e155
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/noImports.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..8c0461e0e74
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/Test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/Test.kt
new file mode 100644
index 00000000000..b3cd9c2badc
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/Test.kt
@@ -0,0 +1,10 @@
+package b
+
+class Test {
+ val aFoo: a.Foo = a.Foo()
+ val bFoo: Foo = Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: a.Foo.Bar = a.Foo.Bar()
+ val bBar: Foo.Bar = Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/noImports.java
new file mode 100644
index 00000000000..2d783a78dc0
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/noImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/noImports.kt
new file mode 100644
index 00000000000..5996754ebd8
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/noImports.kt
@@ -0,0 +1,5 @@
+package b
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/onDemandImport.java
new file mode 100644
index 00000000000..2d783a78dc0
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/onDemandImport.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/onDemandImport.kt
new file mode 100644
index 00000000000..5916652a84f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/onDemandImport.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.*
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImports.java
new file mode 100644
index 00000000000..2d783a78dc0
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImports.kt
new file mode 100644
index 00000000000..912cbbdb0d1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImports.kt
@@ -0,0 +1,7 @@
+package b
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..431f5eda5e5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/b/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package b
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/noImports.java
new file mode 100644
index 00000000000..30b8802d5ed
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/noImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/noImports.kt
new file mode 100644
index 00000000000..5aee576bfa6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/noImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/onDemandImport.java
new file mode 100644
index 00000000000..30b8802d5ed
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/onDemandImport.java
@@ -0,0 +1,9 @@
+package c;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/onDemandImport.kt
new file mode 100644
index 00000000000..7d3b78c3a61
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/onDemandImport.kt
@@ -0,0 +1,8 @@
+package c
+
+import a.*
+import b.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImports.java
new file mode 100644
index 00000000000..30b8802d5ed
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImports.kt
new file mode 100644
index 00000000000..5aee576bfa6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..7be875a249c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/after/c/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/_a/noImports.kt
new file mode 100644
index 00000000000..92ae90f968f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/_a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..14f0a1be487
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/_a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/main.kt
new file mode 100644
index 00000000000..d406a46a313
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/main.kt
@@ -0,0 +1,14 @@
+package a
+
+class Test {
+ val aFoo: Foo = Foo()
+ val bFoo: b.Foo = b.Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: Foo.Bar = Foo.Bar()
+ val bBar: b.Foo.Bar = b.Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+}
+
+fun test(): Test {
+ return Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/noImports.java
new file mode 100644
index 00000000000..315818ca8fd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/noImports.kt
new file mode 100644
index 00000000000..92ae90f968f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..14f0a1be487
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/noImports.java
new file mode 100644
index 00000000000..5e89bacd569
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/noImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ a.Test t = new a.Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/noImports.kt
new file mode 100644
index 00000000000..09d63022357
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/noImports.kt
@@ -0,0 +1,5 @@
+package b
+
+fun bar() {
+ val t: a.Test = a.Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/onDemandImport.java
new file mode 100644
index 00000000000..6db8ed79f30
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/onDemandImport.java
@@ -0,0 +1,9 @@
+package b;
+
+import a.*;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/onDemandImport.kt
new file mode 100644
index 00000000000..5916652a84f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/onDemandImport.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.*
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImports.java
new file mode 100644
index 00000000000..12260b929e7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImports.java
@@ -0,0 +1,9 @@
+package b;
+
+import a.Test;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImports.kt
new file mode 100644
index 00000000000..0f26408b9a3
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImports.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..4146574cb60
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/b/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/noImports.java
new file mode 100644
index 00000000000..46bc1c1af69
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/noImports.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ a.Test t = new a.Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/noImports.kt
new file mode 100644
index 00000000000..9a193d0ddf1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/noImports.kt
@@ -0,0 +1,5 @@
+package c
+
+fun bar() {
+ val t: a.Test = a.Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/onDemandImport.java
new file mode 100644
index 00000000000..b2fcb81f6ca
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/onDemandImport.java
@@ -0,0 +1,9 @@
+package c;
+
+import a.*;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/onDemandImport.kt
new file mode 100644
index 00000000000..1f13e627a2d
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/onDemandImport.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.*
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImports.java
new file mode 100644
index 00000000000..b205abdd409
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import a.Test;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImports.kt
new file mode 100644
index 00000000000..8cafb82d04c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.Test
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..4c707cf47e9
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/before/c/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/moveClass.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/moveClass.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/moveClass.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/main.kt
new file mode 100644
index 00000000000..b4e742eac3d
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+private class Test {
+ fun test {
+ foo(Foo())
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/noImports.java
new file mode 100644
index 00000000000..315818ca8fd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/noImports.kt
new file mode 100644
index 00000000000..92ae90f968f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/after/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/main.kt
new file mode 100644
index 00000000000..5d55fafbf99
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+private class Test {
+ fun test {
+ foo(Foo())
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/noImports.java
new file mode 100644
index 00000000000..315818ca8fd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ Test t = new Test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/noImports.kt
new file mode 100644
index 00000000000..92ae90f968f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/before/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/conflicts.txt
new file mode 100644
index 00000000000..753e162cfb0
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/conflicts.txt
@@ -0,0 +1,4 @@
+Class a.Test uses package-private class a.Foo
+Class a.Test uses package-private function a.foo
+Package-private class a.Test will no longer be accessible from method J.bar()
+Package-private class a.Test will no longer be accessible from property a.bar.t
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/moveClassWithConflicts.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/moveClassWithConflicts.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/moveClassWithConflicts.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/_a/noImports.kt
new file mode 100644
index 00000000000..93d5d1f09de
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/_a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ b.test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..a15828ba0aa
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/_a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/main.kt
new file mode 100644
index 00000000000..f90b20c77b1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+class Test {
+ fun foo() {
+ b.test()
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/noImports.java
new file mode 100644
index 00000000000..d43fc44523a
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/noImports.kt
new file mode 100644
index 00000000000..93d5d1f09de
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ b.test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/onDemandStaticImport.java
new file mode 100644
index 00000000000..d43fc44523a
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/onDemandStaticImport.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..a15828ba0aa
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/specificStaticImports.java
new file mode 100644
index 00000000000..31f7d50216a
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/a/specificStaticImports.java
@@ -0,0 +1,9 @@
+package a;
+
+import static b.BPackage.test;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/noImports.java
new file mode 100644
index 00000000000..377df2c11af
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/noImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/noImports.kt
new file mode 100644
index 00000000000..1222643879a
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/noImports.kt
@@ -0,0 +1,5 @@
+package b
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandImport.java
new file mode 100644
index 00000000000..377df2c11af
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandImport.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandImport.kt
new file mode 100644
index 00000000000..b3a977adfe6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandImport.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.*
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandStaticImport.java
new file mode 100644
index 00000000000..377df2c11af
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/onDemandStaticImport.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImports.java
new file mode 100644
index 00000000000..377df2c11af
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImports.kt
new file mode 100644
index 00000000000..3b8a5e8ae20
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImports.kt
@@ -0,0 +1,7 @@
+package b
+
+import b.test
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..80885a58c31
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package b
+
+import b.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificStaticImports.java
new file mode 100644
index 00000000000..9becc62a457
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/specificStaticImports.java
@@ -0,0 +1,9 @@
+package b;
+
+import static b.BPackage.test;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/test.kt
new file mode 100644
index 00000000000..673a8fc2f38
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/b/test.kt
@@ -0,0 +1,10 @@
+package b
+
+fun test {
+ val aFoo: a.Foo = a.Foo()
+ val bFoo: Foo = Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: a.Foo.Bar = a.Foo.Bar()
+ val bBar: Foo.Bar = Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/noImports.java
new file mode 100644
index 00000000000..fef0d1afe56
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/noImports.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/noImports.kt
new file mode 100644
index 00000000000..a62f1daa823
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/noImports.kt
@@ -0,0 +1,5 @@
+package c
+
+fun bar() {
+ b.test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandImport.java
new file mode 100644
index 00000000000..fef0d1afe56
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandImport.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandImport.kt
new file mode 100644
index 00000000000..132915b6a94
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandImport.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.*
+
+fun bar() {
+ b.test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandStaticImport.java
new file mode 100644
index 00000000000..fef0d1afe56
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/onDemandStaticImport.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImports.java
new file mode 100644
index 00000000000..fef0d1afe56
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImports.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImports.kt
new file mode 100644
index 00000000000..658ae63ed1a
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.test
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..bd75960d0e0
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificStaticImports.java
new file mode 100644
index 00000000000..559a10fedb1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/after/c/specificStaticImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import static b.BPackage.test;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/_a/noImports.kt
new file mode 100644
index 00000000000..4c10813ba46
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/_a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..b212a44ff7f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/_a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import a.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/main.kt
new file mode 100644
index 00000000000..867d2f3d996
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/main.kt
@@ -0,0 +1,16 @@
+package a
+
+fun test {
+ val aFoo: Foo = Foo()
+ val bFoo: b.Foo = b.Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: Foo.Bar = Foo.Bar()
+ val bBar: b.Foo.Bar = b.Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+}
+
+class Test {
+ fun foo() {
+ test()
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/noImports.java
new file mode 100644
index 00000000000..2f22a169eb5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/noImports.kt
new file mode 100644
index 00000000000..4c10813ba46
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/onDemandStaticImport.java
new file mode 100644
index 00000000000..baff27c159c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/onDemandStaticImport.java
@@ -0,0 +1,9 @@
+package a;
+
+import static a.APackage.*;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..b212a44ff7f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import a.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/specificStaticImports.java
new file mode 100644
index 00000000000..b57b7dd7f37
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/a/specificStaticImports.java
@@ -0,0 +1,9 @@
+package a;
+
+import static a.APackage.test;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/noImports.java
new file mode 100644
index 00000000000..6be3c9da729
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/noImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ a.APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/noImports.kt
new file mode 100644
index 00000000000..62870e79d91
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/noImports.kt
@@ -0,0 +1,5 @@
+package b
+
+fun bar() {
+ a.test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandImport.java
new file mode 100644
index 00000000000..9e1ffdd6c43
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandImport.java
@@ -0,0 +1,9 @@
+package b;
+
+import a.*;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandImport.kt
new file mode 100644
index 00000000000..b3a977adfe6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandImport.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.*
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandStaticImport.java
new file mode 100644
index 00000000000..8de3725979d
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/onDemandStaticImport.java
@@ -0,0 +1,9 @@
+package b;
+
+import static a.APackage.*;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImports.java
new file mode 100644
index 00000000000..61c6adf877d
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImports.java
@@ -0,0 +1,9 @@
+package b;
+
+import a.APackage;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImports.kt
new file mode 100644
index 00000000000..819c1edee97
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImports.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.test
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..18f543a5664
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificStaticImports.java
new file mode 100644
index 00000000000..14e299706dd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/b/specificStaticImports.java
@@ -0,0 +1,9 @@
+package b;
+
+import static a.APackage.test;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/noImports.java
new file mode 100644
index 00000000000..39488b60ac6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/noImports.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ a.APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/noImports.kt
new file mode 100644
index 00000000000..71ac08d8e5f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/noImports.kt
@@ -0,0 +1,5 @@
+package c
+
+fun bar() {
+ a.test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandImport.java
new file mode 100644
index 00000000000..c60b20ab683
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandImport.java
@@ -0,0 +1,9 @@
+package c;
+
+import a.*;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandImport.kt
new file mode 100644
index 00000000000..805610b6cd4
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandImport.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.*
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandStaticImport.java
new file mode 100644
index 00000000000..d207bf9688c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/onDemandStaticImport.java
@@ -0,0 +1,9 @@
+package c;
+
+import static a.APackage.*;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImports.java
new file mode 100644
index 00000000000..0ff087f37cf
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import a.APackage;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImports.kt
new file mode 100644
index 00000000000..ea2f3807c53
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.test
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..d9afd8865d1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.test as _test
+
+fun bar() {
+ _test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificStaticImports.java
new file mode 100644
index 00000000000..1fb44fda749
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/before/c/specificStaticImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import static a.APackage.test;
+
+class J {
+ void bar() {
+ test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/moveFunction.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/moveFunction.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/moveFunction.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/main.kt
new file mode 100644
index 00000000000..b7df9ace7e1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/main.kt
@@ -0,0 +1,5 @@
+package a
+
+private fun test {
+ foo(Foo())
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/noImports.java
new file mode 100644
index 00000000000..2f22a169eb5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/noImports.kt
new file mode 100644
index 00000000000..4c10813ba46
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/after/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/main.kt
new file mode 100644
index 00000000000..ba30a0c8f50
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/main.kt
@@ -0,0 +1,5 @@
+package a
+
+private fun test {
+ foo(Foo())
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/noImports.java
new file mode 100644
index 00000000000..2f22a169eb5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ APackage.test();
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/noImports.kt
new file mode 100644
index 00000000000..4c10813ba46
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/before/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/conflicts.txt
new file mode 100644
index 00000000000..0871e3f05a6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/conflicts.txt
@@ -0,0 +1,4 @@
+Function a.test uses package-private class a.Foo
+Function a.test uses package-private function a.foo
+Package-private function a.test will no longer be accessible from function a.bar
+Package-private function a.test will no longer be accessible from method J.bar()
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/moveFunctionWithConflicts.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/moveFunctionWithConflicts.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/moveFunctionWithConflicts.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/_a/noImports.kt
new file mode 100644
index 00000000000..33627bd785b
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/_a/noImports.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..267ec7bd67d
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/_a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/main.kt
new file mode 100644
index 00000000000..fb2fc43b29e
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test
+
+fun test(): Test {
+ return Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/noImports.java
new file mode 100644
index 00000000000..0f8ae714797
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/noImports.java
@@ -0,0 +1,9 @@
+package a;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/noImports.kt
new file mode 100644
index 00000000000..33627bd785b
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/noImports.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..267ec7bd67d
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/Test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/Test.kt
new file mode 100644
index 00000000000..439f5e5e9c2
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/Test.kt
@@ -0,0 +1,10 @@
+package b
+
+object Test {
+ val aFoo: a.Foo = a.Foo()
+ val bFoo: Foo = Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: a.Foo.Bar = a.Foo.Bar()
+ val bBar: Foo.Bar = Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+}
\ No newline at end of file
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/noImports.java
new file mode 100644
index 00000000000..3816fb0abda
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/noImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/noImports.kt
new file mode 100644
index 00000000000..32e72da8b89
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/noImports.kt
@@ -0,0 +1,5 @@
+package b
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/onDemandImport.java
new file mode 100644
index 00000000000..3816fb0abda
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/onDemandImport.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/onDemandImport.kt
new file mode 100644
index 00000000000..0367e6e35a3
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/onDemandImport.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.*
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImports.java
new file mode 100644
index 00000000000..3816fb0abda
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImports.kt
new file mode 100644
index 00000000000..b7f379045a9
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImports.kt
@@ -0,0 +1,7 @@
+package b
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..38cc0b27ff3
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/b/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package b
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/noImports.java
new file mode 100644
index 00000000000..c43110bdc42
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/noImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/noImports.kt
new file mode 100644
index 00000000000..b0866ddf9da
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/noImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/onDemandImport.java
new file mode 100644
index 00000000000..c43110bdc42
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/onDemandImport.java
@@ -0,0 +1,9 @@
+package c;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/onDemandImport.kt
new file mode 100644
index 00000000000..23c30dc6b57
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/onDemandImport.kt
@@ -0,0 +1,8 @@
+package c
+
+import a.*
+import b.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImports.java
new file mode 100644
index 00000000000..c43110bdc42
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import b.Test;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImports.kt
new file mode 100644
index 00000000000..b0866ddf9da
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..900d54f05fd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/after/c/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package c
+
+import b.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/_a/noImports.kt
new file mode 100644
index 00000000000..2fd128dfb13
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/_a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..c90e8622130
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/_a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/main.kt
new file mode 100644
index 00000000000..aba81f03b4f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/main.kt
@@ -0,0 +1,14 @@
+package a
+
+object Test {
+ val aFoo: Foo = Foo()
+ val bFoo: b.Foo = b.Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: Foo.Bar = Foo.Bar()
+ val bBar: b.Foo.Bar = b.Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+}
+
+fun test(): Test {
+ return Test()
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/noImports.java
new file mode 100644
index 00000000000..c4f7954ce65
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/noImports.kt
new file mode 100644
index 00000000000..2fd128dfb13
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..c90e8622130
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/a/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package a
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/noImports.java
new file mode 100644
index 00000000000..62dcb8f569a
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/noImports.java
@@ -0,0 +1,7 @@
+package b;
+
+class J {
+ void bar() {
+ a.Test t = a.Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/noImports.kt
new file mode 100644
index 00000000000..59e747f53bd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/noImports.kt
@@ -0,0 +1,5 @@
+package b
+
+fun bar() {
+ val t: a.Test = a.Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/onDemandImport.java
new file mode 100644
index 00000000000..8df3f06fe1e
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/onDemandImport.java
@@ -0,0 +1,9 @@
+package b;
+
+import a.*;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/onDemandImport.kt
new file mode 100644
index 00000000000..0367e6e35a3
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/onDemandImport.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.*
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImports.java
new file mode 100644
index 00000000000..34f22f3c1f3
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImports.java
@@ -0,0 +1,9 @@
+package b;
+
+import a.Test;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImports.kt
new file mode 100644
index 00000000000..9aa92bda259
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImports.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..36c0e744590
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/b/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package b
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/noImports.java
new file mode 100644
index 00000000000..14242cda197
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/noImports.java
@@ -0,0 +1,7 @@
+package c;
+
+class J {
+ void bar() {
+ a.Test t = a.Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/noImports.kt
new file mode 100644
index 00000000000..24a89b5d280
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/noImports.kt
@@ -0,0 +1,5 @@
+package c
+
+fun bar() {
+ val t: a.Test = a.Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/onDemandImport.java
new file mode 100644
index 00000000000..7cd99b52387
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/onDemandImport.java
@@ -0,0 +1,9 @@
+package c;
+
+import a.*;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/onDemandImport.kt
new file mode 100644
index 00000000000..0d6845f83d9
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/onDemandImport.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.*
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImports.java
new file mode 100644
index 00000000000..57185c2d145
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImports.java
@@ -0,0 +1,9 @@
+package c;
+
+import a.Test;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImports.kt
new file mode 100644
index 00000000000..92c1ec2050f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImports.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.Test
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..297ee3a16af
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/before/c/specificImportsWithAliases.kt
@@ -0,0 +1,7 @@
+package c
+
+import a.Test as _Test
+
+fun bar() {
+ val t: _Test = _Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/moveObject.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/moveObject.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/moveObject.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/main.kt
new file mode 100644
index 00000000000..fcecce027c2
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+private object Test {
+ fun test {
+ foo(Foo())
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/noImports.java
new file mode 100644
index 00000000000..c4f7954ce65
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/noImports.kt
new file mode 100644
index 00000000000..2fd128dfb13
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/after/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/main.kt
new file mode 100644
index 00000000000..ab46aa77424
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+private object Test {
+ fun test {
+ foo(Foo())
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/noImports.java
new file mode 100644
index 00000000000..c4f7954ce65
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/noImports.java
@@ -0,0 +1,7 @@
+package a;
+
+class J {
+ void bar() {
+ Test t = Test.instance$;
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/noImports.kt
new file mode 100644
index 00000000000..2fd128dfb13
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/before/a/noImports.kt
@@ -0,0 +1,5 @@
+package a
+
+fun bar() {
+ val t: Test = Test
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/conflicts.txt
new file mode 100644
index 00000000000..2b35b4c2461
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/conflicts.txt
@@ -0,0 +1,4 @@
+Object a.Test uses package-private class a.Foo
+Object a.Test uses package-private function a.foo
+Package-private object a.Test will no longer be accessible from method J.bar()
+Package-private object a.Test will no longer be accessible from property a.bar.t
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/moveObjectWithConflicts.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/moveObjectWithConflicts.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/moveObjectWithConflicts.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/_a/noImports.kt
new file mode 100644
index 00000000000..1159d9abfef
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/_a/noImports.kt
@@ -0,0 +1,6 @@
+package a
+
+fun bar() {
+ b.test = ""
+ println(b.test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..88c7bb98b5e
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/_a/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package a
+
+import b.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/main.kt
new file mode 100644
index 00000000000..f90b20c77b1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+class Test {
+ fun foo() {
+ b.test()
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/noImports.java
new file mode 100644
index 00000000000..b973de71c0c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/noImports.java
@@ -0,0 +1,8 @@
+package a;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/noImports.kt
new file mode 100644
index 00000000000..1159d9abfef
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/noImports.kt
@@ -0,0 +1,6 @@
+package a
+
+fun bar() {
+ b.test = ""
+ println(b.test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/onDemandStaticImport.java
new file mode 100644
index 00000000000..b973de71c0c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/onDemandStaticImport.java
@@ -0,0 +1,8 @@
+package a;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..88c7bb98b5e
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package a
+
+import b.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/specificStaticImports.java
new file mode 100644
index 00000000000..0d131511d74
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/a/specificStaticImports.java
@@ -0,0 +1,11 @@
+package a;
+
+import static b.BPackage.getTest;
+import static b.BPackage.setTest;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/noImports.java
new file mode 100644
index 00000000000..8648539c9f7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/noImports.java
@@ -0,0 +1,8 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/noImports.kt
new file mode 100644
index 00000000000..8d8f59100de
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/noImports.kt
@@ -0,0 +1,6 @@
+package b
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandImport.java
new file mode 100644
index 00000000000..8648539c9f7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandImport.java
@@ -0,0 +1,8 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandImport.kt
new file mode 100644
index 00000000000..7f05a5ae342
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandImport.kt
@@ -0,0 +1,8 @@
+package b
+
+import a.*
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandStaticImport.java
new file mode 100644
index 00000000000..8648539c9f7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/onDemandStaticImport.java
@@ -0,0 +1,8 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImports.java
new file mode 100644
index 00000000000..8648539c9f7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImports.java
@@ -0,0 +1,8 @@
+package b;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImports.kt
new file mode 100644
index 00000000000..6a531687734
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImports.kt
@@ -0,0 +1,8 @@
+package b
+
+import b.test
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..e93f254e11c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package b
+
+import b.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificStaticImports.java
new file mode 100644
index 00000000000..59ec9aa301f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/specificStaticImports.java
@@ -0,0 +1,11 @@
+package b;
+
+import static b.BPackage.getTest;
+import static b.BPackage.setTest;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/test.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/test.kt
new file mode 100644
index 00000000000..ba3d09436a6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/b/test.kt
@@ -0,0 +1,12 @@
+package b
+
+var test: String
+ get() = ""
+ set(value: String) {
+ val aFoo: a.Foo = a.Foo()
+ val bFoo: Foo = Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: a.Foo.Bar = a.Foo.Bar()
+ val bBar: Foo.Bar = Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+ }
\ No newline at end of file
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/noImports.java
new file mode 100644
index 00000000000..1309a310809
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/noImports.java
@@ -0,0 +1,8 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/noImports.kt
new file mode 100644
index 00000000000..5bfeeb1f712
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/noImports.kt
@@ -0,0 +1,6 @@
+package c
+
+fun bar() {
+ b.test = ""
+ println(b.test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandImport.java
new file mode 100644
index 00000000000..1309a310809
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandImport.java
@@ -0,0 +1,8 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandImport.kt
new file mode 100644
index 00000000000..c1072a9db4b
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandImport.kt
@@ -0,0 +1,8 @@
+package c
+
+import a.*
+
+fun bar() {
+ b.test = ""
+ println(b.test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandStaticImport.java
new file mode 100644
index 00000000000..1309a310809
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/onDemandStaticImport.java
@@ -0,0 +1,8 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImports.java
new file mode 100644
index 00000000000..1309a310809
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImports.java
@@ -0,0 +1,8 @@
+package c;
+
+class J {
+ void bar() {
+ b.BPackage.setTest("");
+ System.out.println(b.BPackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImports.kt
new file mode 100644
index 00000000000..90955bfba8b
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImports.kt
@@ -0,0 +1,8 @@
+package c
+
+import b.test
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..73e3d31d27c
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package c
+
+import b.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificStaticImports.java
new file mode 100644
index 00000000000..8916d698cec
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/after/c/specificStaticImports.java
@@ -0,0 +1,11 @@
+package c;
+
+import static b.BPackage.getTest;
+import static b.BPackage.setTest;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/_a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/_a/noImports.kt
new file mode 100644
index 00000000000..f319c15486f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/_a/noImports.kt
@@ -0,0 +1,6 @@
+package a
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/_a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/_a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..9632e12d312
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/_a/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package a
+
+import a.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/dependency.kt
new file mode 100644
index 00000000000..19e1c2c2fdd
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/dependency.kt
@@ -0,0 +1,7 @@
+package a
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/main.kt
new file mode 100644
index 00000000000..ab655b8d5a5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/main.kt
@@ -0,0 +1,18 @@
+package a
+
+var test: String
+ get() = ""
+ set(value: String) {
+ val aFoo: Foo = Foo()
+ val bFoo: b.Foo = b.Foo()
+ val cFoo: c.Foo = c.Foo()
+ val aBar: Foo.Bar = Foo.Bar()
+ val bBar: b.Foo.Bar = b.Foo.Bar()
+ val cBar: c.Foo.Bar = c.Foo.Bar()
+ }
+
+class Test {
+ fun foo() {
+ test()
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/noImports.java
new file mode 100644
index 00000000000..b42807193c7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/noImports.java
@@ -0,0 +1,8 @@
+package a;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/noImports.kt
new file mode 100644
index 00000000000..f319c15486f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/noImports.kt
@@ -0,0 +1,6 @@
+package a
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/onDemandStaticImport.java
new file mode 100644
index 00000000000..4c7d2b3a428
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/onDemandStaticImport.java
@@ -0,0 +1,10 @@
+package a;
+
+import static a.APackage.*;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..9632e12d312
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package a
+
+import a.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/specificStaticImports.java
new file mode 100644
index 00000000000..5cb271f6685
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/a/specificStaticImports.java
@@ -0,0 +1,11 @@
+package a;
+
+import static a.APackage.getTest;
+import static a.APackage.setTest;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/dependency.kt
new file mode 100644
index 00000000000..dcd1e2cca0f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/dependency.kt
@@ -0,0 +1,7 @@
+package b
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/noImports.java
new file mode 100644
index 00000000000..a2840dbb624
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/noImports.java
@@ -0,0 +1,8 @@
+package b;
+
+class J {
+ void bar() {
+ a.APackage.setTest("");
+ System.out.println(a.APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/noImports.kt
new file mode 100644
index 00000000000..8ebfba88869
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/noImports.kt
@@ -0,0 +1,6 @@
+package b
+
+fun bar() {
+ a.test = ""
+ println(a.test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandImport.java
new file mode 100644
index 00000000000..10af19e0cf0
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandImport.java
@@ -0,0 +1,10 @@
+package b;
+
+import a.*;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandImport.kt
new file mode 100644
index 00000000000..7f05a5ae342
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandImport.kt
@@ -0,0 +1,8 @@
+package b
+
+import a.*
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandStaticImport.java
new file mode 100644
index 00000000000..0f8a1f6ee75
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/onDemandStaticImport.java
@@ -0,0 +1,10 @@
+package b;
+
+import static a.APackage.*;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImports.java
new file mode 100644
index 00000000000..72363a4bea3
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImports.java
@@ -0,0 +1,10 @@
+package b;
+
+import a.APackage;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImports.kt
new file mode 100644
index 00000000000..4d935f61996
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImports.kt
@@ -0,0 +1,8 @@
+package b
+
+import a.test
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..f54a1a27817
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package b
+
+import a.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificStaticImports.java
new file mode 100644
index 00000000000..b896c640b4b
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/b/specificStaticImports.java
@@ -0,0 +1,11 @@
+package b;
+
+import static a.APackage.getTest;
+import static a.APackage.setTest;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/dependency.kt
new file mode 100644
index 00000000000..bde1387bee5
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/dependency.kt
@@ -0,0 +1,7 @@
+package c
+
+open class Foo {
+ open class Bar {
+
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/noImports.java
new file mode 100644
index 00000000000..14722d77fe6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/noImports.java
@@ -0,0 +1,8 @@
+package c;
+
+class J {
+ void bar() {
+ a.APackage.setTest("");
+ System.out.println(a.APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/noImports.kt
new file mode 100644
index 00000000000..0c524b872bb
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/noImports.kt
@@ -0,0 +1,6 @@
+package c
+
+fun bar() {
+ a.test = ""
+ println(a.test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandImport.java
new file mode 100644
index 00000000000..a1342503097
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandImport.java
@@ -0,0 +1,10 @@
+package c;
+
+import a.*;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandImport.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandImport.kt
new file mode 100644
index 00000000000..145340ad9e1
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandImport.kt
@@ -0,0 +1,8 @@
+package c
+
+import a.*
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandStaticImport.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandStaticImport.java
new file mode 100644
index 00000000000..99f9096d76f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/onDemandStaticImport.java
@@ -0,0 +1,10 @@
+package c;
+
+import static a.APackage.*;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImports.java
new file mode 100644
index 00000000000..c294f14dcaf
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImports.java
@@ -0,0 +1,10 @@
+package c;
+
+import a.APackage;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImports.kt
new file mode 100644
index 00000000000..66a22ff6388
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImports.kt
@@ -0,0 +1,8 @@
+package c
+
+import a.test
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImportsWithAliases.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImportsWithAliases.kt
new file mode 100644
index 00000000000..7ae37527ca8
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificImportsWithAliases.kt
@@ -0,0 +1,8 @@
+package c
+
+import a.test as _test
+
+fun bar() {
+ _test = ""
+ println(_test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificStaticImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificStaticImports.java
new file mode 100644
index 00000000000..29ebd4c3b45
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/before/c/specificStaticImports.java
@@ -0,0 +1,11 @@
+package c;
+
+import static a.APackage.getTest;
+import static a.APackage.setTest;
+
+class J {
+ void bar() {
+ setTest("");
+ System.out.println(getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/moveProperty.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/moveProperty.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/moveProperty.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/main.kt
new file mode 100644
index 00000000000..7e671d14d74
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+private var test: String
+ get() = ""
+ set(value: String) {
+ foo(Foo())
+ }
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/noImports.java
new file mode 100644
index 00000000000..b42807193c7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/noImports.java
@@ -0,0 +1,8 @@
+package a;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/noImports.kt
new file mode 100644
index 00000000000..f319c15486f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/after/a/noImports.kt
@@ -0,0 +1,6 @@
+package a
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/dependency.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/dependency.kt
new file mode 100644
index 00000000000..69cbb81abd7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/dependency.kt
@@ -0,0 +1,9 @@
+package a
+
+private class Foo {
+
+}
+
+private fun foo(value: Foo) {
+
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/main.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/main.kt
new file mode 100644
index 00000000000..3371d7f849b
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/main.kt
@@ -0,0 +1,7 @@
+package a
+
+private var test: String
+ get() = ""
+ set(value: String) {
+ foo(Foo())
+ }
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/noImports.java b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/noImports.java
new file mode 100644
index 00000000000..b42807193c7
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/noImports.java
@@ -0,0 +1,8 @@
+package a;
+
+class J {
+ void bar() {
+ APackage.setTest("");
+ System.out.println(APackage.getTest());
+ }
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/noImports.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/noImports.kt
new file mode 100644
index 00000000000..f319c15486f
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/before/a/noImports.kt
@@ -0,0 +1,6 @@
+package a
+
+fun bar() {
+ test = ""
+ println(test)
+}
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/conflicts.txt
new file mode 100644
index 00000000000..933a50ab9e6
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/conflicts.txt
@@ -0,0 +1,4 @@
+Package-private property a.test will no longer be accessible from function a.bar
+Package-private property a.test will no longer be accessible from method J.bar()
+Property a.test uses package-private class a.Foo
+Property a.test uses package-private function a.foo
diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/movePropertyWithConflicts.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/movePropertyWithConflicts.test
new file mode 100644
index 00000000000..10641ec2d49
--- /dev/null
+++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/movePropertyWithConflicts.test
@@ -0,0 +1,5 @@
+{
+ "mainFile": "a/main.kt",
+ "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
+ "targetPackage": "b"
+}
diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt b/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt
index 7ab70eb6290..0b187ffb52f 100644
--- a/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt
+++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt
@@ -51,6 +51,10 @@ import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectori
import com.intellij.refactoring.move.MoveHandler
import org.jetbrains.jet.getString
import org.jetbrains.jet.getNullableString
+import org.jetbrains.jet.lang.psi.JetClassOrObject
+import org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.MoveKotlinTopLevelDeclarationsProcessor
+import org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.MoveKotlinTopLevelDeclarationsOptions
+import org.jetbrains.jet.lang.psi.JetNamedDeclaration
public abstract class AbstractJetMoveTest : MultiFileTestCase() {
protected fun doTest(path: String) {
@@ -246,5 +250,18 @@ enum class MoveAction {
}
}
+ MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS {
+ override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) {
+ val elementToMove = elementAtCaret!!.getParentByType(javaClass())!!
+ val targetPackage = config.getString("targetPackage")
+
+ val options = MoveKotlinTopLevelDeclarationsOptions(
+ elementsToMove = listOf(elementToMove),
+ moveDestination = MultipleRootsMoveDestination(PackageWrapper(mainFile.getManager(), targetPackage))
+ )
+ MoveKotlinTopLevelDeclarationsProcessor(mainFile.getProject(), options).run()
+ }
+ }
+
abstract fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject)
}
diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/move/JetMoveTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/refactoring/move/JetMoveTestGenerated.java
index 54d699151f3..53586fd1658 100644
--- a/idea/tests/org/jetbrains/jet/plugin/refactoring/move/JetMoveTestGenerated.java
+++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/move/JetMoveTestGenerated.java
@@ -191,4 +191,44 @@ public class JetMoveTestGenerated extends AbstractJetMoveTest {
doTest("idea/testData/refactoring/move/kotlin/movePackage/movePackage/movePackage.test");
}
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveClass/moveClass.test")
+ public void testKotlin_moveTopLevelDeclarations_moveClass_MoveClass() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClass/moveClass.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveClassWithConflicts/moveClassWithConflicts.test")
+ public void testKotlin_moveTopLevelDeclarations_moveClassWithConflicts_MoveClassWithConflicts() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveClassWithConflicts/moveClassWithConflicts.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveFunction/moveFunction.test")
+ public void testKotlin_moveTopLevelDeclarations_moveFunction_MoveFunction() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunction/moveFunction.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/moveFunctionWithConflicts.test")
+ public void testKotlin_moveTopLevelDeclarations_moveFunctionWithConflicts_MoveFunctionWithConflicts() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveFunctionWithConflicts/moveFunctionWithConflicts.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveObject/moveObject.test")
+ public void testKotlin_moveTopLevelDeclarations_moveObject_MoveObject() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObject/moveObject.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/moveObjectWithConflicts.test")
+ public void testKotlin_moveTopLevelDeclarations_moveObjectWithConflicts_MoveObjectWithConflicts() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveObjectWithConflicts/moveObjectWithConflicts.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/moveProperty/moveProperty.test")
+ public void testKotlin_moveTopLevelDeclarations_moveProperty_MoveProperty() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveProperty/moveProperty.test");
+ }
+
+ @TestMetadata("kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/movePropertyWithConflicts.test")
+ public void testKotlin_moveTopLevelDeclarations_movePropertyWithConflicts_MovePropertyWithConflicts() throws Exception {
+ doTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyWithConflicts/movePropertyWithConflicts.test");
+ }
+
}