Move: Support "Search references" option in dialogs
This commit is contained in:
+2
-1
@@ -36,6 +36,7 @@ class KotlinAwareMoveFilesOrDirectoriesProcessor @JvmOverloads constructor (
|
|||||||
project: Project,
|
project: Project,
|
||||||
private val elementsToMove: List<PsiElement>,
|
private val elementsToMove: List<PsiElement>,
|
||||||
private val targetDirectory: PsiDirectory,
|
private val targetDirectory: PsiDirectory,
|
||||||
|
private val searchReferences: Boolean,
|
||||||
searchInComments: Boolean,
|
searchInComments: Boolean,
|
||||||
searchInNonJavaFiles: Boolean,
|
searchInNonJavaFiles: Boolean,
|
||||||
moveCallback: MoveCallback?,
|
moveCallback: MoveCallback?,
|
||||||
@@ -55,7 +56,7 @@ class KotlinAwareMoveFilesOrDirectoriesProcessor @JvmOverloads constructor (
|
|||||||
override fun findUsages(): Array<UsageInfo> {
|
override fun findUsages(): Array<UsageInfo> {
|
||||||
try {
|
try {
|
||||||
markScopeToMove(elementsToMove)
|
markScopeToMove(elementsToMove)
|
||||||
return super.findUsages()
|
return if (searchReferences) super.findUsages() else UsageInfo.EMPTY_ARRAY
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
markScopeToMove(null)
|
markScopeToMove(null)
|
||||||
|
|||||||
+3
-2
@@ -103,7 +103,8 @@ class MoveDeclarationsDescriptor @JvmOverloads constructor(
|
|||||||
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
|
||||||
)
|
)
|
||||||
|
|
||||||
class ConflictUsageInfo(element: PsiElement, val messages: Collection<String>) : UsageInfo(element)
|
class ConflictUsageInfo(element: PsiElement, val messages: Collection<String>) : UsageInfo(element)
|
||||||
@@ -156,7 +157,7 @@ class MoveKotlinDeclarationsProcessor(
|
|||||||
fun getConflictsAsUsages(): List<UsageInfo> = conflicts.entrySet().map { ConflictUsageInfo(it.key, it.value) }
|
fun getConflictsAsUsages(): List<UsageInfo> = conflicts.entrySet().map { ConflictUsageInfo(it.key, it.value) }
|
||||||
|
|
||||||
public override fun findUsages(): Array<UsageInfo> {
|
public override fun findUsages(): Array<UsageInfo> {
|
||||||
if (elementsToMove.isEmpty()) return UsageInfo.EMPTY_ARRAY
|
if (!descriptor.searchReferences || elementsToMove.isEmpty()) return UsageInfo.EMPTY_ARRAY
|
||||||
|
|
||||||
val newContainerName = descriptor.moveTarget.targetContainerFqName?.asString() ?: ""
|
val newContainerName = descriptor.moveTarget.targetContainerFqName?.asString() ?: ""
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -14,7 +14,6 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
|
|||||||
import com.intellij.openapi.fileChooser.FileChooserFactory
|
import com.intellij.openapi.fileChooser.FileChooserFactory
|
||||||
import com.intellij.openapi.help.HelpManager
|
import com.intellij.openapi.help.HelpManager
|
||||||
import com.intellij.openapi.keymap.KeymapUtil
|
import com.intellij.openapi.keymap.KeymapUtil
|
||||||
import com.intellij.openapi.project.DumbModePermission
|
|
||||||
import com.intellij.openapi.project.DumbService
|
import com.intellij.openapi.project.DumbService
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.ui.DialogWrapper
|
import com.intellij.openapi.ui.DialogWrapper
|
||||||
@@ -53,6 +52,7 @@ class KotlinAwareMoveFilesOrDirectoriesDialog(
|
|||||||
|
|
||||||
private val nameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true)
|
private val nameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true)
|
||||||
private val targetDirectoryField = TextFieldWithHistoryWithBrowseButton()
|
private val targetDirectoryField = TextFieldWithHistoryWithBrowseButton()
|
||||||
|
private val searchReferencesCb = NonFocusableCheckBox("Search ${UIUtil.MNEMONIC}references").apply { isSelected = true }
|
||||||
private val openInEditorCb = NonFocusableCheckBox("Open moved files in editor")
|
private val openInEditorCb = NonFocusableCheckBox("Open moved files in editor")
|
||||||
private val updatePackageDirectiveCb = NonFocusableCheckBox()
|
private val updatePackageDirectiveCb = NonFocusableCheckBox()
|
||||||
|
|
||||||
@@ -68,6 +68,9 @@ class KotlinAwareMoveFilesOrDirectoriesDialog(
|
|||||||
val updatePackageDirective: Boolean
|
val updatePackageDirective: Boolean
|
||||||
get() = updatePackageDirectiveCb.isSelected
|
get() = updatePackageDirectiveCb.isSelected
|
||||||
|
|
||||||
|
val searchReferences: Boolean
|
||||||
|
get() = searchReferencesCb.isSelected
|
||||||
|
|
||||||
override fun createActions() = arrayOf(okAction, cancelAction, helpAction)
|
override fun createActions() = arrayOf(okAction, cancelAction, helpAction)
|
||||||
|
|
||||||
override fun getPreferredFocusedComponent() = targetDirectoryField.childComponent
|
override fun getPreferredFocusedComponent() = targetDirectoryField.childComponent
|
||||||
@@ -102,6 +105,7 @@ class KotlinAwareMoveFilesOrDirectoriesDialog(
|
|||||||
.addComponent(nameLabel)
|
.addComponent(nameLabel)
|
||||||
.addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), targetDirectoryField, UIUtil.LARGE_VGAP)
|
.addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), targetDirectoryField, UIUtil.LARGE_VGAP)
|
||||||
.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText))
|
.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText))
|
||||||
|
.addComponentToRightColumn(searchReferencesCb, UIUtil.LARGE_VGAP)
|
||||||
.addComponentToRightColumn(openInEditorCb, UIUtil.LARGE_VGAP)
|
.addComponentToRightColumn(openInEditorCb, UIUtil.LARGE_VGAP)
|
||||||
.addComponentToRightColumn(updatePackageDirectiveCb, UIUtil.LARGE_VGAP)
|
.addComponentToRightColumn(updatePackageDirectiveCb, UIUtil.LARGE_VGAP)
|
||||||
.panel
|
.panel
|
||||||
|
|||||||
+13
-4
@@ -2,7 +2,7 @@
|
|||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog">
|
||||||
<grid id="1a398" binding="mainPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
<grid id="1a398" binding="mainPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="10" y="10" width="472" height="414"/>
|
<xy x="10" y="10" width="729" height="414"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none">
|
<border type="none">
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
<text value="&Update package directive"/>
|
<text value="&Update package directive"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<grid id="69aba" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="69aba" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
<children>
|
<children>
|
||||||
<component id="74471" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchInComments">
|
<component id="74471" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchInComments">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<selected value="true"/>
|
<selected value="true"/>
|
||||||
@@ -135,13 +135,22 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="a7936" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchTextOccurrences">
|
<component id="a7936" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchTextOccurrences">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<selected value="true"/>
|
<selected value="true"/>
|
||||||
<text resource-bundle="messages/RefactoringBundle" key="search.for.text.occurrences"/>
|
<text resource-bundle="messages/RefactoringBundle" key="search.for.text.occurrences"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="cc60c" class="javax.swing.JCheckBox" binding="cbSearchReferences">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<selected value="true"/>
|
||||||
|
<text value="Search &references"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
+6
-1
@@ -94,6 +94,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
private JTextField tfFileNameInPackage;
|
private JTextField tfFileNameInPackage;
|
||||||
private JCheckBox cbSpecifyFileNameInPackage;
|
private JCheckBox cbSpecifyFileNameInPackage;
|
||||||
private JCheckBox cbUpdatePackageDirective;
|
private JCheckBox cbUpdatePackageDirective;
|
||||||
|
private JCheckBox cbSearchReferences;
|
||||||
private KotlinMemberSelectionTable memberTable;
|
private KotlinMemberSelectionTable memberTable;
|
||||||
public MoveKotlinTopLevelDeclarationsDialog(
|
public MoveKotlinTopLevelDeclarationsDialog(
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@@ -747,6 +748,7 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
: new KotlinAwareMoveFilesOrDirectoriesProcessor(myProject,
|
: new KotlinAwareMoveFilesOrDirectoriesProcessor(myProject,
|
||||||
sourceFiles,
|
sourceFiles,
|
||||||
targetDirectory,
|
targetDirectory,
|
||||||
|
cbSearchReferences.isSelected(),
|
||||||
isSearchInComments(),
|
isSearchInComments(),
|
||||||
isSearchInNonJavaFiles(),
|
isSearchInNonJavaFiles(),
|
||||||
moveCallback);
|
moveCallback);
|
||||||
@@ -777,7 +779,10 @@ public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
|
|||||||
false,
|
false,
|
||||||
deleteSourceFile,
|
deleteSourceFile,
|
||||||
moveCallback,
|
moveCallback,
|
||||||
false
|
false,
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
cbSearchReferences.isSelected()
|
||||||
);
|
);
|
||||||
invokeRefactoring(new MoveKotlinDeclarationsProcessor(options, Mover.Default.INSTANCE));
|
invokeRefactoring(new MoveKotlinDeclarationsProcessor(options, Mover.Default.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ fun invokeMoveFilesOrDirectoriesRefactoring(
|
|||||||
project,
|
project,
|
||||||
elementsToMove as List<KtFile>,
|
elementsToMove as List<KtFile>,
|
||||||
selectedDir,
|
selectedDir,
|
||||||
|
moveDialog?.searchReferences ?: true,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
moveCallback,
|
moveCallback,
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ enum class MoveAction : AbstractMultifileRefactoringTest.RefactoringAction {
|
|||||||
project,
|
project,
|
||||||
elementsToMove,
|
elementsToMove,
|
||||||
targetDir,
|
targetDir,
|
||||||
|
true,
|
||||||
searchInComments = true,
|
searchInComments = true,
|
||||||
searchInNonJavaFiles = true,
|
searchInNonJavaFiles = true,
|
||||||
moveCallback = null
|
moveCallback = null
|
||||||
|
|||||||
Reference in New Issue
Block a user