Move: Fix "scanEntireFile" values after the refactoring
#KT-17032 Fixed
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ class KotlinChangePackageRefactoring(val file: KtFile) {
|
|||||||
override fun verify(file: PsiFile) = null
|
override fun verify(file: PsiFile) = null
|
||||||
},
|
},
|
||||||
delegate = MoveDeclarationsDelegate.TopLevel,
|
delegate = MoveDeclarationsDelegate.TopLevel,
|
||||||
scanEntireFile = false
|
scanEntireFile = true
|
||||||
),
|
),
|
||||||
Mover.Idle // we don't need to move any declarations physically
|
Mover.Idle // we don't need to move any declarations physically
|
||||||
)
|
)
|
||||||
|
|||||||
+7
-10
@@ -57,11 +57,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MoveKotlinNestedClassesDialog extends RefactoringDialog {
|
public class MoveKotlinNestedClassesDialog extends RefactoringDialog {
|
||||||
private static final String RECENTS_KEY = MoveKotlinNestedClassesDialog.class.getName() + ".RECENTS_KEY";
|
private static final String RECENTS_KEY = MoveKotlinNestedClassesDialog.class.getName() + ".RECENTS_KEY";
|
||||||
|
private final KtClassOrObject originalClass;
|
||||||
private static class MemberInfoModelImpl extends AbstractMemberInfoModel<KtNamedDeclaration, KotlinMemberInfo> {
|
private final MoveCallback moveCallback;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel mainPanel;
|
private JPanel mainPanel;
|
||||||
private JTextField originalClassField;
|
private JTextField originalClassField;
|
||||||
private JPanel membersInfoPanel;
|
private JPanel membersInfoPanel;
|
||||||
@@ -69,11 +66,7 @@ public class MoveKotlinNestedClassesDialog extends RefactoringDialog {
|
|||||||
private JCheckBox openInEditorCheckBox;
|
private JCheckBox openInEditorCheckBox;
|
||||||
private JPanel targetClassChooserPanel;
|
private JPanel targetClassChooserPanel;
|
||||||
private KotlinMemberSelectionTable memberTable;
|
private KotlinMemberSelectionTable memberTable;
|
||||||
|
|
||||||
private final KtClassOrObject originalClass;
|
|
||||||
private KtClassOrObject targetClass;
|
private KtClassOrObject targetClass;
|
||||||
private final MoveCallback moveCallback;
|
|
||||||
|
|
||||||
public MoveKotlinNestedClassesDialog(
|
public MoveKotlinNestedClassesDialog(
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@NotNull List<KtClassOrObject> elementsToMove,
|
@NotNull List<KtClassOrObject> elementsToMove,
|
||||||
@@ -242,7 +235,7 @@ public class MoveKotlinNestedClassesDialog extends RefactoringDialog {
|
|||||||
KotlinMoveTarget target = new KotlinMoveTargetForExistingElement(targetClass);
|
KotlinMoveTarget target = new KotlinMoveTargetForExistingElement(targetClass);
|
||||||
MoveDeclarationsDelegate.NestedClass delegate = new MoveDeclarationsDelegate.NestedClass();
|
MoveDeclarationsDelegate.NestedClass delegate = new MoveDeclarationsDelegate.NestedClass();
|
||||||
MoveDeclarationsDescriptor descriptor = new MoveDeclarationsDescriptor(
|
MoveDeclarationsDescriptor descriptor = new MoveDeclarationsDescriptor(
|
||||||
elementsToMove, target, delegate, false, false, true, false, moveCallback, openInEditorCheckBox.isSelected()
|
elementsToMove, target, delegate, false, false, false, false, moveCallback, openInEditorCheckBox.isSelected()
|
||||||
);
|
);
|
||||||
invokeRefactoring(new MoveKotlinDeclarationsProcessor(myProject, descriptor, Mover.Default.INSTANCE));
|
invokeRefactoring(new MoveKotlinDeclarationsProcessor(myProject, descriptor, Mover.Default.INSTANCE));
|
||||||
}
|
}
|
||||||
@@ -251,4 +244,8 @@ public class MoveKotlinNestedClassesDialog extends RefactoringDialog {
|
|||||||
public JComponent getPreferredFocusedComponent() {
|
public JComponent getPreferredFocusedComponent() {
|
||||||
return targetClassChooser.getChildComponent();
|
return targetClassChooser.getChildComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MemberInfoModelImpl extends AbstractMemberInfoModel<KtNamedDeclaration, KotlinMemberInfo> {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -411,7 +411,7 @@ public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase {
|
|||||||
delegate,
|
delegate,
|
||||||
isSearchInComments(),
|
isSearchInComments(),
|
||||||
isSearchInNonJavaFiles(),
|
isSearchInNonJavaFiles(),
|
||||||
true,
|
false,
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
isOpenInEditor()
|
isOpenInEditor()
|
||||||
|
|||||||
+41
-44
@@ -82,11 +82,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
||||||
private static final String RECENTS_KEY = "MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY";
|
private static final String RECENTS_KEY = "MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY";
|
||||||
|
private final MoveCallback moveCallback;
|
||||||
private static class MemberInfoModelImpl extends AbstractMemberInfoModel<KtNamedDeclaration, KotlinMemberInfo> {
|
private final PsiDirectory initialTargetDirectory;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private JCheckBox cbSearchInComments;
|
private JCheckBox cbSearchInComments;
|
||||||
private JCheckBox cbSearchTextOccurrences;
|
private JCheckBox cbSearchTextOccurrences;
|
||||||
private JPanel mainPanel;
|
private JPanel mainPanel;
|
||||||
@@ -101,10 +98,6 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
private JCheckBox cbSpecifyFileNameInPackage;
|
private JCheckBox cbSpecifyFileNameInPackage;
|
||||||
private JCheckBox cbUpdatePackageDirective;
|
private JCheckBox cbUpdatePackageDirective;
|
||||||
private KotlinMemberSelectionTable memberTable;
|
private KotlinMemberSelectionTable memberTable;
|
||||||
|
|
||||||
private final MoveCallback moveCallback;
|
|
||||||
private final PsiDirectory initialTargetDirectory;
|
|
||||||
|
|
||||||
public MoveKotlinTopLevelDeclarationsDialog(
|
public MoveKotlinTopLevelDeclarationsDialog(
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@NotNull Set<KtNamedDeclaration> elementsToMove,
|
@NotNull Set<KtNamedDeclaration> elementsToMove,
|
||||||
@@ -193,6 +186,40 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static List<PsiFile> getFilesExistingInTargetDir(
|
||||||
|
@NotNull List<KtFile> sourceFiles,
|
||||||
|
@Nullable String targetFileName,
|
||||||
|
@Nullable final PsiDirectory targetDirectory
|
||||||
|
) {
|
||||||
|
if (targetDirectory == null) return Collections.emptyList();
|
||||||
|
|
||||||
|
List<String> fileNames =
|
||||||
|
targetFileName != null
|
||||||
|
? Collections.singletonList(targetFileName)
|
||||||
|
: CollectionsKt.map(
|
||||||
|
sourceFiles,
|
||||||
|
new Function1<KtFile, String>() {
|
||||||
|
@Override
|
||||||
|
public String invoke(KtFile jetFile) {
|
||||||
|
return jetFile.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return CollectionsKt.filterNotNull(
|
||||||
|
CollectionsKt.map(
|
||||||
|
fileNames,
|
||||||
|
new Function1<String, PsiFile>() {
|
||||||
|
@Override
|
||||||
|
public PsiFile invoke(String s) {
|
||||||
|
return targetDirectory.findFile(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void initMemberInfo(
|
private void initMemberInfo(
|
||||||
@NotNull final Set<KtNamedDeclaration> elementsToMove,
|
@NotNull final Set<KtNamedDeclaration> elementsToMove,
|
||||||
@NotNull List<KtFile> sourceFiles
|
@NotNull List<KtFile> sourceFiles
|
||||||
@@ -474,40 +501,6 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static List<PsiFile> getFilesExistingInTargetDir(
|
|
||||||
@NotNull List<KtFile> sourceFiles,
|
|
||||||
@Nullable String targetFileName,
|
|
||||||
@Nullable final PsiDirectory targetDirectory
|
|
||||||
) {
|
|
||||||
if (targetDirectory == null) return Collections.emptyList();
|
|
||||||
|
|
||||||
List<String> fileNames =
|
|
||||||
targetFileName != null
|
|
||||||
? Collections.singletonList(targetFileName)
|
|
||||||
: CollectionsKt.map(
|
|
||||||
sourceFiles,
|
|
||||||
new Function1<KtFile, String>() {
|
|
||||||
@Override
|
|
||||||
public String invoke(KtFile jetFile) {
|
|
||||||
return jetFile.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return CollectionsKt.filterNotNull(
|
|
||||||
CollectionsKt.map(
|
|
||||||
fileNames,
|
|
||||||
new Function1<String, PsiFile>() {
|
|
||||||
@Override
|
|
||||||
public PsiFile invoke(String s) {
|
|
||||||
return targetDirectory.findFile(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private KotlinMoveTarget selectMoveTarget() {
|
private KotlinMoveTarget selectMoveTarget() {
|
||||||
String message = verifyBeforeRun();
|
String message = verifyBeforeRun();
|
||||||
@@ -775,7 +768,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
MoveDeclarationsDelegate.TopLevel.INSTANCE,
|
MoveDeclarationsDelegate.TopLevel.INSTANCE,
|
||||||
isSearchInComments(),
|
isSearchInComments(),
|
||||||
isSearchInNonJavaFiles(),
|
isSearchInNonJavaFiles(),
|
||||||
true,
|
false,
|
||||||
deleteSourceFile,
|
deleteSourceFile,
|
||||||
moveCallback,
|
moveCallback,
|
||||||
false
|
false
|
||||||
@@ -803,4 +796,8 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
public JComponent getPreferredFocusedComponent() {
|
public JComponent getPreferredFocusedComponent() {
|
||||||
return classPackageChooser.getChildComponent();
|
return classPackageChooser.getChildComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MemberInfoModelImpl extends AbstractMemberInfoModel<KtNamedDeclaration, KotlinMemberInfo> {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package cr.app
|
||||||
|
|
||||||
|
class Mobile
|
||||||
Vendored
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package cr
|
||||||
|
|
||||||
|
class Immobile
|
||||||
|
|
||||||
|
val immobileUsage = Immobile()
|
||||||
Vendored
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package cr
|
||||||
|
|
||||||
|
class Immobile
|
||||||
|
|
||||||
|
class <caret>Mobile
|
||||||
|
|
||||||
|
val immobileUsage = Immobile()
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"mainFile": "cr/test.kt",
|
||||||
|
"type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS",
|
||||||
|
"targetPackage": "cr.app"
|
||||||
|
}
|
||||||
@@ -462,6 +462,12 @@ public class MoveTestGenerated extends AbstractMoveTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlin/moveTopLevelDeclarations/misc/kt17032/kt17032.test")
|
||||||
|
public void testKotlin_moveTopLevelDeclarations_misc_kt17032_Kt17032() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/kt17032/kt17032.test");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlin/moveTopLevelDeclarations/misc/moveClassFromDefaultPackage/moveClassFromDefaultPackage.test")
|
@TestMetadata("kotlin/moveTopLevelDeclarations/misc/moveClassFromDefaultPackage/moveClassFromDefaultPackage.test")
|
||||||
public void testKotlin_moveTopLevelDeclarations_misc_moveClassFromDefaultPackage_MoveClassFromDefaultPackage() throws Exception {
|
public void testKotlin_moveTopLevelDeclarations_misc_moveClassFromDefaultPackage_MoveClassFromDefaultPackage() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/moveClassFromDefaultPackage/moveClassFromDefaultPackage.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/moveClassFromDefaultPackage/moveClassFromDefaultPackage.test");
|
||||||
|
|||||||
Reference in New Issue
Block a user