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