Refactor: Introduce MoveSource class
This commit is contained in:
@@ -50,7 +50,7 @@ abstract class MoveMemberOutOfObjectIntention(text: String) : SelfTargetingRange
|
|||||||
if (element is KtClassOrObject) {
|
if (element is KtClassOrObject) {
|
||||||
val moveDescriptor = MoveDeclarationsDescriptor(
|
val moveDescriptor = MoveDeclarationsDescriptor(
|
||||||
project,
|
project,
|
||||||
listOf(element),
|
MoveSource(element),
|
||||||
KotlinMoveTargetForExistingElement(destination),
|
KotlinMoveTargetForExistingElement(destination),
|
||||||
MoveDeclarationsDelegate.NestedClass()
|
MoveDeclarationsDelegate.NestedClass()
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -271,7 +271,7 @@ class MoveMemberToCompanionObjectIntention : SelfTargetingRangeIntention<KtNamed
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val moveDescriptor = MoveDeclarationsDescriptor(project,
|
val moveDescriptor = MoveDeclarationsDescriptor(project,
|
||||||
listOf(element),
|
MoveSource(element),
|
||||||
KotlinMoveTargetForCompanion(containingClass),
|
KotlinMoveTargetForCompanion(containingClass),
|
||||||
MoveDeclarationsDelegate.NestedClass(null, outerInstanceName),
|
MoveDeclarationsDelegate.NestedClass(null, outerInstanceName),
|
||||||
moveCallback = MoveCallback { runTemplateForInstanceParam(movedClass!!, nameSuggestions, editor) })
|
moveCallback = MoveCallback { runTemplateForInstanceParam(movedClass!!, nameSuggestions, editor) })
|
||||||
|
|||||||
+7
-7
@@ -111,13 +111,13 @@ class MoveDeclarationsProcessor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val declarationProcessor = MoveKotlinDeclarationsProcessor(
|
val declarationProcessor = MoveKotlinDeclarationsProcessor(
|
||||||
MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor(
|
||||||
elementsToMove = stubDeclarations,
|
moveSource = MoveSource(stubDeclarations),
|
||||||
moveTarget = KotlinMoveTargetForExistingElement(targetPsiFile),
|
moveTarget = KotlinMoveTargetForExistingElement(targetPsiFile),
|
||||||
delegate = MoveDeclarationsDelegate.TopLevel,
|
delegate = MoveDeclarationsDelegate.TopLevel,
|
||||||
project = project
|
project = project
|
||||||
),
|
),
|
||||||
mover
|
mover
|
||||||
)
|
)
|
||||||
|
|
||||||
val declarationUsages = project.runSynchronouslyWithProgress(RefactoringBundle.message("progress.text"), true) {
|
val declarationUsages = project.runSynchronouslyWithProgress(RefactoringBundle.message("progress.text"), true) {
|
||||||
|
|||||||
+6
-9
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
|||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
|
||||||
|
|
||||||
class KotlinChangePackageRefactoring(val file: KtFile) {
|
class KotlinChangePackageRefactoring(val file: KtFile) {
|
||||||
private val project = file.project
|
private val project = file.project
|
||||||
@@ -39,14 +38,12 @@ class KotlinChangePackageRefactoring(val file: KtFile) {
|
|||||||
val currentFqName = packageDirective.fqName
|
val currentFqName = packageDirective.fqName
|
||||||
|
|
||||||
val declarationProcessor = MoveKotlinDeclarationsProcessor(
|
val declarationProcessor = MoveKotlinDeclarationsProcessor(
|
||||||
MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor(
|
||||||
project = project,
|
project = project,
|
||||||
elementsToMove = file.declarations.filterIsInstance<KtNamedDeclaration>(),
|
moveSource = MoveSource(file),
|
||||||
moveTarget = KotlinDirectoryMoveTarget(newFqName, file.containingDirectory!!),
|
moveTarget = KotlinDirectoryMoveTarget(newFqName, file.containingDirectory!!),
|
||||||
delegate = MoveDeclarationsDelegate.TopLevel,
|
delegate = MoveDeclarationsDelegate.TopLevel
|
||||||
scanEntireFile = true
|
)
|
||||||
),
|
|
||||||
Mover.Idle // we don't need to move any declarations physically
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val declarationUsages = project.runSynchronouslyWithProgress(RefactoringBundle.message("progress.text"), true) {
|
val declarationUsages = project.runSynchronouslyWithProgress(RefactoringBundle.message("progress.text"), true) {
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ class MoveDeclarationToSeparateFileIntention :
|
|||||||
}
|
}
|
||||||
val descriptor = MoveDeclarationsDescriptor(
|
val descriptor = MoveDeclarationsDescriptor(
|
||||||
project = project,
|
project = project,
|
||||||
elementsToMove = listOf(element),
|
moveSource = MoveSource(element),
|
||||||
moveTarget = moveTarget,
|
moveTarget = moveTarget,
|
||||||
delegate = MoveDeclarationsDelegate.TopLevel,
|
delegate = MoveDeclarationsDelegate.TopLevel,
|
||||||
searchInCommentsAndStrings = false,
|
searchInCommentsAndStrings = false,
|
||||||
|
|||||||
+2
-2
@@ -79,7 +79,7 @@ sealed class MoveDeclarationsDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun findInternalUsages(descriptor: MoveDeclarationsDescriptor): List<UsageInfo> {
|
override fun findInternalUsages(descriptor: MoveDeclarationsDescriptor): List<UsageInfo> {
|
||||||
val classToMove = descriptor.elementsToMove.singleOrNull() as? KtClass ?: return emptyList()
|
val classToMove = descriptor.moveSource.elementsToMove.singleOrNull() as? KtClass ?: return emptyList()
|
||||||
return collectOuterInstanceReferences(classToMove)
|
return collectOuterInstanceReferences(classToMove)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ sealed class MoveDeclarationsDelegate {
|
|||||||
if (outerInstanceParameterName == null) return
|
if (outerInstanceParameterName == null) return
|
||||||
val psiFactory = KtPsiFactory(descriptor.project)
|
val psiFactory = KtPsiFactory(descriptor.project)
|
||||||
val newOuterInstanceRef = psiFactory.createExpression(outerInstanceParameterName)
|
val newOuterInstanceRef = psiFactory.createExpression(outerInstanceParameterName)
|
||||||
val classToMove = descriptor.elementsToMove.singleOrNull() as? KtClass
|
val classToMove = descriptor.moveSource.elementsToMove.singleOrNull() as? KtClass
|
||||||
|
|
||||||
for (usage in usages) {
|
for (usage in usages) {
|
||||||
if (usage is MoveRenameUsageInfo) {
|
if (usage is MoveRenameUsageInfo) {
|
||||||
|
|||||||
+2
-2
@@ -79,7 +79,7 @@ sealed class MoveDeclarationsDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun findInternalUsages(descriptor: MoveDeclarationsDescriptor): List<UsageInfo> {
|
override fun findInternalUsages(descriptor: MoveDeclarationsDescriptor): List<UsageInfo> {
|
||||||
val classToMove = descriptor.elementsToMove.singleOrNull() as? KtClass ?: return emptyList()
|
val classToMove = descriptor.moveSource.elementsToMove.singleOrNull() as? KtClass ?: return emptyList()
|
||||||
return collectOuterInstanceReferences(classToMove)
|
return collectOuterInstanceReferences(classToMove)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ sealed class MoveDeclarationsDelegate {
|
|||||||
if (outerInstanceParameterName == null) return
|
if (outerInstanceParameterName == null) return
|
||||||
val psiFactory = KtPsiFactory(descriptor.project)
|
val psiFactory = KtPsiFactory(descriptor.project)
|
||||||
val newOuterInstanceRef = psiFactory.createExpression(outerInstanceParameterName)
|
val newOuterInstanceRef = psiFactory.createExpression(outerInstanceParameterName)
|
||||||
val classToMove = descriptor.elementsToMove.singleOrNull() as? KtClass
|
val classToMove = descriptor.moveSource.elementsToMove.singleOrNull() as? KtClass
|
||||||
|
|
||||||
for (usage in usages) {
|
for (usage in usages) {
|
||||||
if (usage is MoveRenameUsageInfo) {
|
if (usage is MoveRenameUsageInfo) {
|
||||||
|
|||||||
+30
-19
@@ -25,7 +25,6 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.psi.PsiNamedElement
|
import com.intellij.psi.PsiNamedElement
|
||||||
import com.intellij.psi.PsiReference
|
import com.intellij.psi.PsiReference
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import com.intellij.psi.search.SearchScope
|
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch
|
import com.intellij.psi.search.searches.ReferencesSearch
|
||||||
import com.intellij.refactoring.BaseRefactoringProcessor
|
import com.intellij.refactoring.BaseRefactoringProcessor
|
||||||
import com.intellij.refactoring.move.MoveCallback
|
import com.intellij.refactoring.move.MoveCallback
|
||||||
@@ -90,26 +89,36 @@ interface Mover : (KtNamedDeclaration, KtElement) -> KtNamedDeclaration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object Idle : Mover {
|
sealed class MoveSource {
|
||||||
override fun invoke(originalElement: KtNamedDeclaration, targetContainer: KtElement) = originalElement
|
abstract val elementsToMove: Collection<KtNamedDeclaration>
|
||||||
|
|
||||||
|
class Elements(override val elementsToMove: Collection<KtNamedDeclaration>) : MoveSource()
|
||||||
|
|
||||||
|
class File(val file: KtFile) : MoveSource() {
|
||||||
|
override val elementsToMove: Collection<KtNamedDeclaration>
|
||||||
|
get() = file.declarations.filterIsInstance<KtNamedDeclaration>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun MoveSource(declaration: KtNamedDeclaration) = MoveSource.Elements(listOf(declaration))
|
||||||
|
fun MoveSource(declarations: Collection<KtNamedDeclaration>) = MoveSource.Elements(declarations)
|
||||||
|
fun MoveSource(file: KtFile) = MoveSource.File(file)
|
||||||
|
|
||||||
class MoveDeclarationsDescriptor @JvmOverloads constructor(
|
class MoveDeclarationsDescriptor @JvmOverloads constructor(
|
||||||
val project: Project,
|
val project: Project,
|
||||||
val elementsToMove: Collection<KtNamedDeclaration>,
|
val moveSource: MoveSource,
|
||||||
val moveTarget: KotlinMoveTarget,
|
val moveTarget: KotlinMoveTarget,
|
||||||
val delegate: MoveDeclarationsDelegate,
|
val delegate: MoveDeclarationsDelegate,
|
||||||
val searchInCommentsAndStrings: Boolean = true,
|
val searchInCommentsAndStrings: Boolean = true,
|
||||||
val searchInNonCode: Boolean = true,
|
val searchInNonCode: Boolean = true,
|
||||||
val scanEntireFile: Boolean = false,
|
val deleteSourceFiles: Boolean = false,
|
||||||
val deleteSourceFiles: Boolean = false,
|
val moveCallback: MoveCallback? = null,
|
||||||
val moveCallback: MoveCallback? = null,
|
val openInEditor: Boolean = false,
|
||||||
val openInEditor: Boolean = false,
|
val allElementsToMove: List<PsiElement>? = null,
|
||||||
val allElementsToMove: List<PsiElement>? = null,
|
val analyzeConflicts: Boolean = true,
|
||||||
val analyzeConflicts: Boolean = true,
|
val searchReferences: Boolean = true
|
||||||
val searchReferences: Boolean = true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class ConflictUsageInfo(element: PsiElement, val messages: Collection<String>) : UsageInfo(element)
|
class ConflictUsageInfo(element: PsiElement, val messages: Collection<String>) : UsageInfo(element)
|
||||||
@@ -144,7 +153,8 @@ class MoveKotlinDeclarationsProcessor(
|
|||||||
val project get() = descriptor.project
|
val project get() = descriptor.project
|
||||||
|
|
||||||
private var nonCodeUsages: Array<NonCodeUsageInfo>? = null
|
private var nonCodeUsages: Array<NonCodeUsageInfo>? = null
|
||||||
private val elementsToMove = descriptor.elementsToMove.filter { e -> e.parent != descriptor.moveTarget.getTargetPsiIfExists(e) }
|
private val moveEntireFile = descriptor.moveSource is MoveSource.File
|
||||||
|
private val elementsToMove = descriptor.moveSource.elementsToMove.filter { e -> e.parent != descriptor.moveTarget.getTargetPsiIfExists(e) }
|
||||||
private val kotlinToLightElementsBySourceFile = elementsToMove
|
private val kotlinToLightElementsBySourceFile = elementsToMove
|
||||||
.groupBy { it.containingKtFile }
|
.groupBy { it.containingKtFile }
|
||||||
.mapValues { it.value.keysToMap { it.toLightElements().ifEmpty { listOf(it) } } }
|
.mapValues { it.value.keysToMap { it.toLightElements().ifEmpty { listOf(it) } } }
|
||||||
@@ -238,7 +248,7 @@ class MoveKotlinDeclarationsProcessor(
|
|||||||
val internalUsages = LinkedHashSet<UsageInfo>()
|
val internalUsages = LinkedHashSet<UsageInfo>()
|
||||||
val externalUsages = LinkedHashSet<UsageInfo>()
|
val externalUsages = LinkedHashSet<UsageInfo>()
|
||||||
|
|
||||||
if (descriptor.scanEntireFile) {
|
if (moveEntireFile) {
|
||||||
val changeInfo = ContainerChangeInfo(
|
val changeInfo = ContainerChangeInfo(
|
||||||
ContainerInfo.Package(sourceFile.packageFqName),
|
ContainerInfo.Package(sourceFile.packageFqName),
|
||||||
descriptor.moveTarget.targetContainerFqName?.let { ContainerInfo.Package(it) } ?: ContainerInfo.UnknownPackage
|
descriptor.moveTarget.targetContainerFqName?.let { ContainerInfo.Package(it) } ?: ContainerInfo.UnknownPackage
|
||||||
@@ -277,6 +287,7 @@ class MoveKotlinDeclarationsProcessor(
|
|||||||
val targetContainer = moveTarget.getOrCreateTargetPsi(declaration)
|
val targetContainer = moveTarget.getOrCreateTargetPsi(declaration)
|
||||||
?: throw AssertionError("Couldn't create Kotlin file for: ${declaration::class.java}: ${declaration.text}")
|
?: throw AssertionError("Couldn't create Kotlin file for: ${declaration::class.java}: ${declaration.text}")
|
||||||
descriptor.delegate.preprocessDeclaration(descriptor, declaration)
|
descriptor.delegate.preprocessDeclaration(descriptor, declaration)
|
||||||
|
if (moveEntireFile) return declaration
|
||||||
return mover(declaration, targetContainer).apply {
|
return mover(declaration, targetContainer).apply {
|
||||||
addToBeShortenedDescendantsToWaitingSet()
|
addToBeShortenedDescendantsToWaitingSet()
|
||||||
}
|
}
|
||||||
@@ -321,7 +332,7 @@ class MoveKotlinDeclarationsProcessor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val internalUsageScopes: List<KtElement> = if (descriptor.scanEntireFile) {
|
val internalUsageScopes: List<KtElement> = if (moveEntireFile) {
|
||||||
newDeclarations.asSequence().map { it.containingKtFile }.distinct().toList()
|
newDeclarations.asSequence().map { it.containingKtFile }.distinct().toList()
|
||||||
} else {
|
} else {
|
||||||
newDeclarations
|
newDeclarations
|
||||||
|
|||||||
+10
-1
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo;
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPanel;
|
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPanel;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionTable;
|
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionTable;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.*;
|
import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.*;
|
||||||
|
import static org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.MoveKotlinDeclarationsProcessorKt.MoveSource;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.ui.KotlinTypeReferenceEditorComboWithBrowseButton;
|
import org.jetbrains.kotlin.idea.refactoring.ui.KotlinTypeReferenceEditorComboWithBrowseButton;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
|
||||||
@@ -262,7 +263,15 @@ public class MoveKotlinNestedClassesDialog extends RefactoringDialog {
|
|||||||
KotlinMoveTarget target = new KotlinMoveTargetForExistingElement((KtClassOrObject) targetClass);
|
KotlinMoveTarget target = new KotlinMoveTargetForExistingElement((KtClassOrObject) targetClass);
|
||||||
MoveDeclarationsDelegate.NestedClass delegate = new MoveDeclarationsDelegate.NestedClass();
|
MoveDeclarationsDelegate.NestedClass delegate = new MoveDeclarationsDelegate.NestedClass();
|
||||||
MoveDeclarationsDescriptor descriptor = new MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor descriptor = new MoveDeclarationsDescriptor(
|
||||||
myProject, elementsToMove, target, delegate, false, false, false, false, moveCallback, openInEditorCheckBox.isSelected()
|
myProject,
|
||||||
|
MoveSource(elementsToMove),
|
||||||
|
target,
|
||||||
|
delegate,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
moveCallback,
|
||||||
|
openInEditorCheckBox.isSelected()
|
||||||
);
|
);
|
||||||
invokeRefactoring(new MoveKotlinDeclarationsProcessor(descriptor, Mover.Default.INSTANCE));
|
invokeRefactoring(new MoveKotlinDeclarationsProcessor(descriptor, Mover.Default.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -39,7 +39,6 @@ import com.intellij.refactoring.util.RefactoringUtil;
|
|||||||
import com.intellij.ui.EditorTextField;
|
import com.intellij.ui.EditorTextField;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
import com.intellij.util.IncorrectOperationException;
|
import com.intellij.util.IncorrectOperationException;
|
||||||
import kotlin.collections.CollectionsKt;
|
|
||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -72,6 +71,8 @@ import java.awt.event.ItemListener;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.MoveKotlinDeclarationsProcessorKt.MoveSource;
|
||||||
|
|
||||||
public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase {
|
public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase {
|
||||||
@NonNls private static final String RECENTS_KEY = MoveKotlinNestedClassesToUpperLevelDialog.class.getName() + ".RECENTS_KEY";
|
@NonNls private static final String RECENTS_KEY = MoveKotlinNestedClassesToUpperLevelDialog.class.getName() + ".RECENTS_KEY";
|
||||||
|
|
||||||
@@ -416,13 +417,12 @@ public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase {
|
|||||||
MoveDeclarationsDelegate delegate = new MoveDeclarationsDelegate.NestedClass(newClassName, outerInstanceParameterName);
|
MoveDeclarationsDelegate delegate = new MoveDeclarationsDelegate.NestedClass(newClassName, outerInstanceParameterName);
|
||||||
MoveDeclarationsDescriptor moveDescriptor = new MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor moveDescriptor = new MoveDeclarationsDescriptor(
|
||||||
project,
|
project,
|
||||||
CollectionsKt.listOf(innerClass),
|
MoveSource(innerClass),
|
||||||
moveTarget,
|
moveTarget,
|
||||||
delegate,
|
delegate,
|
||||||
isSearchInComments(),
|
isSearchInComments(),
|
||||||
isSearchInNonJavaFiles(),
|
isSearchInNonJavaFiles(),
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
null,
|
null,
|
||||||
isOpenInEditor()
|
isOpenInEditor()
|
||||||
);
|
);
|
||||||
|
|||||||
+2
-2
@@ -63,6 +63,7 @@ import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPan
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionTable;
|
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionTable;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.move.MoveUtilsKt;
|
import org.jetbrains.kotlin.idea.refactoring.move.MoveUtilsKt;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.*;
|
import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.*;
|
||||||
|
import static org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.MoveKotlinDeclarationsProcessorKt.MoveSource;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.ui.KotlinFileChooserDialog;
|
import org.jetbrains.kotlin.idea.refactoring.ui.KotlinFileChooserDialog;
|
||||||
import org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt;
|
import org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
@@ -774,12 +775,11 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
|
|
||||||
MoveDeclarationsDescriptor options = new MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor options = new MoveDeclarationsDescriptor(
|
||||||
myProject,
|
myProject,
|
||||||
elementsToMove,
|
MoveSource(elementsToMove),
|
||||||
target,
|
target,
|
||||||
MoveDeclarationsDelegate.TopLevel.INSTANCE,
|
MoveDeclarationsDelegate.TopLevel.INSTANCE,
|
||||||
isSearchInComments(),
|
isSearchInComments(),
|
||||||
isSearchInNonJavaFiles(),
|
isSearchInNonJavaFiles(),
|
||||||
false,
|
|
||||||
deleteSourceFile,
|
deleteSourceFile,
|
||||||
moveCallback,
|
moveCallback,
|
||||||
false,
|
false,
|
||||||
|
|||||||
+8
-11
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.*
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.move.updatePackageDirective
|
import org.jetbrains.kotlin.idea.refactoring.move.updatePackageDirective
|
||||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtNamedDeclaration
|
|
||||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||||
|
|
||||||
internal var KtFile.allElementsToMove: List<PsiElement>? by UserDataProperty(Key.create("SCOPE_TO_MOVE"))
|
internal var KtFile.allElementsToMove: List<PsiElement>? by UserDataProperty(Key.create("SCOPE_TO_MOVE"))
|
||||||
@@ -92,16 +91,14 @@ class MoveKotlinFileHandler : MoveFileHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return MoveKotlinDeclarationsProcessor(
|
return MoveKotlinDeclarationsProcessor(
|
||||||
MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor(
|
||||||
project = project,
|
project = project,
|
||||||
elementsToMove = psiFile.declarations.filterIsInstance<KtNamedDeclaration>(),
|
moveSource = MoveSource(psiFile),
|
||||||
moveTarget = moveTarget,
|
moveTarget = moveTarget,
|
||||||
delegate = MoveDeclarationsDelegate.TopLevel,
|
delegate = MoveDeclarationsDelegate.TopLevel,
|
||||||
scanEntireFile = true,
|
allElementsToMove = psiFile.allElementsToMove,
|
||||||
allElementsToMove = psiFile.allElementsToMove,
|
analyzeConflicts = withConflicts
|
||||||
analyzeConflicts = withConflicts
|
)
|
||||||
),
|
|
||||||
Mover.Idle
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ enum class MoveAction : AbstractMultifileRefactoringTest.RefactoringAction {
|
|||||||
KotlinMoveTargetForExistingElement(PsiManager.getInstance(project).findFile(rootDir.findFileByRelativePath(filePath)!!) as KtFile)
|
KotlinMoveTargetForExistingElement(PsiManager.getInstance(project).findFile(rootDir.findFileByRelativePath(filePath)!!) as KtFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
val descriptor = MoveDeclarationsDescriptor(project, elementsToMove, moveTarget, MoveDeclarationsDelegate.TopLevel)
|
val descriptor = MoveDeclarationsDescriptor(project, MoveSource(elementsToMove), moveTarget, MoveDeclarationsDelegate.TopLevel)
|
||||||
MoveKotlinDeclarationsProcessor(descriptor).run()
|
MoveKotlinDeclarationsProcessor(descriptor).run()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -288,7 +288,7 @@ enum class MoveAction : AbstractMultifileRefactoringTest.RefactoringAction {
|
|||||||
createKotlinFile(fileName, targetDir, targetPackageFqName.asString())
|
createKotlinFile(fileName, targetDir, targetPackageFqName.asString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val descriptor = MoveDeclarationsDescriptor(project, listOf(elementToMove), moveTarget, delegate)
|
val descriptor = MoveDeclarationsDescriptor(project, MoveSource(elementToMove), moveTarget, delegate)
|
||||||
MoveKotlinDeclarationsProcessor(descriptor).run()
|
MoveKotlinDeclarationsProcessor(descriptor).run()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user