Move top-level declarations: Refactoring UI

This commit is contained in:
Alexey Sedunov
2014-03-18 21:22:04 +04:00
parent abcba89ad3
commit 2f0d0c4d26
7 changed files with 519 additions and 6 deletions
@@ -0,0 +1,33 @@
<root>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate boolean canMove(com.intellij.psi.PsiElement[], com.intellij.psi.PsiElement) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate boolean isValidTarget(com.intellij.psi.PsiElement, com.intellij.psi.PsiElement[]) 1'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate boolean tryToMove(com.intellij.psi.PsiElement, com.intellij.openapi.project.Project, com.intellij.openapi.actionSystem.DataContext, com.intellij.psi.PsiReference, com.intellij.openapi.editor.Editor)'>
<annotation name='kotlin.jvm.KotlinSignature'>
<val name="value"
val="&quot;fun tryToMove(element: PsiElement, project: Project, dataContext: DataContext?, reference: PsiReference?, editor: Editor?): Boolean&quot;"/>
</annotation>
</item>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate com.intellij.psi.PsiElement[] adjustForMove(com.intellij.openapi.project.Project, com.intellij.psi.PsiElement[], com.intellij.psi.PsiElement) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate com.intellij.psi.PsiElement[] adjustForMove(com.intellij.openapi.project.Project, com.intellij.psi.PsiElement[], com.intellij.psi.PsiElement) 1'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate void doMove(com.intellij.openapi.project.Project, com.intellij.psi.PsiElement[], com.intellij.psi.PsiElement, com.intellij.refactoring.move.MoveCallback) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.refactoring.move.MoveHandlerDelegate void doMove(com.intellij.openapi.project.Project, com.intellij.psi.PsiElement[], com.intellij.psi.PsiElement, com.intellij.refactoring.move.MoveCallback) 1'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
+7 -1
View File
@@ -170,7 +170,13 @@
<lang.unwrapDescriptor language="jet" implementationClass="org.jetbrains.jet.plugin.codeInsight.unwrap.KotlinUnwrapDescriptor"/>
<quoteHandler fileType="Kotlin" className="org.jetbrains.jet.plugin.editor.KotlinQuoteHandler"/>
<refactoring.helper implementation="org.jetbrains.jet.plugin.codeInsight.KotlinShortenReferencesRefactoringHelper"/>
<refactoring.moveHandler implementation="org.jetbrains.jet.plugin.refactoring.move.moveFilesOrDirectories.KotlinMoveFilesOrDirectoriesHandler"/>
<refactoring.moveHandler
id="kotlin.moveFilesOrDirectories"
implementation="org.jetbrains.jet.plugin.refactoring.move.moveFilesOrDirectories.KotlinMoveFilesOrDirectoriesHandler"/>
<refactoring.moveHandler
id="kotlin.moveTopLevelDeclarations"
implementation="org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.MoveKotlinTopLevelDeclarationsHandler"
order="before kotlin.moveFilesOrDirectories"/>
<moveFileHandler implementation="org.jetbrains.jet.plugin.refactoring.move.moveFilesOrDirectories.MoveKotlinFileHandler" />
<refactoring.copyHandler implementation="org.jetbrains.jet.plugin.refactoring.copy.JetCopyClassHandler"/>
<refactoring.changeSignatureUsageProcessor implementation="org.jetbrains.jet.plugin.refactoring.changeSignature.JetChangeSignatureUsageProcessor"/>
@@ -19,5 +19,9 @@ parameter.name.is.invalid=Parameter name ''{0}'' is invalid
parameter.type.is.invalid=Parameter type ''{0}'' is invalid
column.name.val.var=Val/Var
refactoring.move.top.level.declarations=Move top-level declarations
refactoring.move.specifc.element=Move {0} {1}
refactoring.move.selected.elements=Move selected elements
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}
@@ -28,15 +28,18 @@ import com.intellij.psi.PsiElement
import com.intellij.openapi.util.Key
import com.intellij.psi.PsiDirectory
import org.jetbrains.jet.lang.psi.JetFile
import com.intellij.psi.PsiFileFactory
import org.jetbrains.jet.lang.psi.psiUtil.getPackage
import org.jetbrains.jet.plugin.JetFileType
import com.intellij.openapi.roots.JavaProjectRootsUtil
import com.intellij.psi.PsiPackage
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiMember
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
import org.jetbrains.jet.lang.psi.JetPsiUtil
import org.jetbrains.jet.asJava.namedUnwrappedElement
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.util.ConflictsUtil
import org.jetbrains.jet.lang.psi.psiUtil.getPackage
import com.intellij.psi.PsiFileFactory
import org.jetbrains.jet.plugin.JetFileType
/**
* Replace [[JetSimpleNameExpression]] (and its enclosing qualifier) with qualified element given by FqName
@@ -102,4 +105,7 @@ public fun PsiElement.getUsageContext(): PsiElement {
is JetElement -> PsiTreeUtil.getParentOfType(this, javaClass<JetNamedDeclaration>(), javaClass<JetFile>())!!
else -> ConflictsUtil.getContainer(this)
}
}
}
public fun PsiElement.isInJavaSourceRoot(): Boolean =
!JavaProjectRootsUtil.isOutsideJavaSourceRoot(getContainingFile())
@@ -0,0 +1,111 @@
/*
* 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.move.MoveHandlerDelegate
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.refactoring.move.MoveCallback
import com.intellij.psi.PsiReference
import com.intellij.openapi.editor.Editor
import org.jetbrains.jet.lang.psi.JetClassOrObject
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.plugin.refactoring.isInJavaSourceRoot
import org.jetbrains.jet.lang.psi.JetObjectDeclaration
import org.jetbrains.jet.lang.psi.JetClass
import com.intellij.psi.PsiPackage
import com.intellij.psi.PsiDirectory
import org.jetbrains.jet.lang.psi.psiUtil.getPackage
import org.jetbrains.jet.plugin.refactoring.move.getFileNameAfterMove
import java.util.HashSet
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.util.CommonRefactoringUtil
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesImpl
import org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog
import com.intellij.refactoring.JavaRefactoringSettings
import com.intellij.openapi.actionSystem.LangDataKeys
import org.jetbrains.jet.lang.psi.JetNamedFunction
import org.jetbrains.jet.lang.psi.JetProperty
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
public class MoveKotlinTopLevelDeclarationsHandler : MoveHandlerDelegate() {
private fun doMoveWithCheck(
project: Project, elements: Array<out PsiElement>, targetContainer: PsiElement?, callback: MoveCallback?
): Boolean {
fun checkNameConflicts(): Boolean {
val fileNames = HashSet<String>()
for (element in elements) {
if (element !is JetNamedDeclaration) continue
val fileName = element.getFileNameAfterMove()
if (fileName != null && !fileNames.add(fileName)) {
val message = RefactoringBundle.getCannotRefactorMessage(
RefactoringBundle.message("there.are.going.to.be.multiple.destination.files.with.the.same.name")
)
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("move.title"), message, null, project)
return false
}
}
return true
}
if (!checkNameConflicts()) return false
if (!CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, elements.toList(), true)) return false
[suppress("UNCHECKED_CAST")]
val elementsToSearch = elements.toList() as List<JetNamedDeclaration>
val targetPackageName = MoveClassesOrPackagesImpl.getInitialTargetPackageName(targetContainer, elements)
val targetDirectory = MoveClassesOrPackagesImpl.getInitialTargetDirectory(targetContainer, elements)
val searchInComments = JavaRefactoringSettings.getInstance()!!.MOVE_SEARCH_IN_COMMENTS
val searchInText = JavaRefactoringSettings.getInstance()!!.MOVE_SEARCH_FOR_TEXT
MoveKotlinTopLevelDeclarationsDialog(
project, elementsToSearch, targetPackageName, targetDirectory, searchInComments, searchInText, callback
).show()
return true
}
override fun canMove(elements: Array<out PsiElement>, targetContainer: PsiElement?): Boolean {
return super.canMove(elements, targetContainer) && elements.all { e ->
if (e is JetClass || (e is JetObjectDeclaration && !e.isObjectLiteral()) || e is JetNamedFunction || e is JetProperty) {
val parent = e.getParent()
parent is JetFile && parent.isInJavaSourceRoot()
}
else false
}
}
override fun isValidTarget(psiElement: PsiElement?, sources: Array<out PsiElement>): Boolean {
return psiElement is PsiPackage || (psiElement is PsiDirectory && psiElement.getPackage() != null)
}
override fun doMove(project: Project, elements: Array<out PsiElement>, targetContainer: PsiElement?, callback: MoveCallback?) {
doMoveWithCheck(project, elements, targetContainer, callback)
}
override fun tryToMove(
element: PsiElement, project: Project, dataContext: DataContext?, reference: PsiReference?, editor: Editor?
): Boolean {
val elementsToMove = array(element)
val targetContainer = dataContext?.let { dataContext -> LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext) }
return canMove(elementsToMove, targetContainer) && doMoveWithCheck(project, elementsToMove, targetContainer, null)
}
}
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog">
<grid id="1a398" binding="mainPanel" layout-manager="GridLayoutManager" row-count="5" 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>
<xy x="10" y="10" width="472" height="414"/>
</constraints>
<properties/>
<border type="none">
<color color="-8355712"/>
</border>
<children>
<component id="ec4f" class="javax.swing.JLabel" binding="elementDescription">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<font style="1"/>
<text value="Move"/>
</properties>
</component>
<component id="74471" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchInComments">
<constraints>
<grid row="2" 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"/>
<text resource-bundle="messages/RefactoringBundle" key="search.in.comments.and.strings"/>
</properties>
</component>
<component id="a7936" class="com.intellij.ui.NonFocusableCheckBox" binding="cbSearchTextOccurences">
<constraints>
<grid row="2" 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>
<grid id="ce694" binding="targetPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4934c" class="javax.swing.JLabel" binding="targetDestinationLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="36327"/>
<text resource-bundle="messages/RefactoringBundle" key="target.destination.folder"/>
</properties>
</component>
<component id="36327" class="com.intellij.ui.ComboboxWithBrowseButton" binding="destinationFolderCB" custom-create="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
<vspacer id="fdc31">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="fced3" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="7" left="0" bottom="7" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="37672" class="com.intellij.ui.ReferenceEditorComboWithBrowseButton" binding="classPackageChooser" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="f73ba" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="To package:"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<buttonGroups>
<group name="buttonGroup1">
<member id="63b06"/>
<member id="37e02"/>
</group>
</buttonGroups>
</form>
@@ -0,0 +1,250 @@
/*
* 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.ui;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.JavaProjectRootsUtil;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Pass;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiNameHelper;
import com.intellij.refactoring.JavaRefactoringSettings;
import com.intellij.refactoring.MoveDestination;
import com.intellij.refactoring.PackageWrapper;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.move.MoveCallback;
import com.intellij.refactoring.move.MoveHandler;
import com.intellij.refactoring.move.moveClassesOrPackages.DestinationFolderComboBox;
import com.intellij.refactoring.ui.PackageNameReferenceEditorCombo;
import com.intellij.refactoring.ui.RefactoringDialog;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.ui.ComboboxWithBrowseButton;
import com.intellij.ui.RecentsManager;
import com.intellij.ui.ReferenceEditorComboWithBrowseButton;
import com.intellij.usageView.UsageViewUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle;
import org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.MoveKotlinTopLevelDeclarationsOptions;
import org.jetbrains.jet.plugin.refactoring.move.moveTopLevelDeclarations.MoveKotlinTopLevelDeclarationsProcessor;
import javax.swing.*;
import java.util.List;
public class MoveKotlinTopLevelDeclarationsDialog extends RefactoringDialog {
private static final String RECENTS_KEY = "MoveKotlinTopLevelDeclarationsDialog.RECENTS_KEY";
private JLabel elementDescription;
private JCheckBox cbSearchInComments;
private JCheckBox cbSearchTextOccurences;
private JPanel mainPanel;
private ReferenceEditorComboWithBrowseButton classPackageChooser;
private ComboboxWithBrowseButton destinationFolderCB;
private JPanel targetPanel;
private JLabel targetDestinationLabel;
private final List<JetNamedDeclaration> elementsToMove;
private final MoveCallback moveCallback;
public MoveKotlinTopLevelDeclarationsDialog(
@NotNull Project project,
@NotNull List<JetNamedDeclaration> elementsToMove,
@Nullable String targetPackageName,
@Nullable PsiDirectory targetDirectory,
boolean searchInComments,
boolean searchForTextOccurences,
@Nullable MoveCallback moveCallback
) {
super(project, true);
this.elementsToMove = elementsToMove;
this.moveCallback = moveCallback;
init();
setTitle(MoveHandler.REFACTORING_NAME);
if (elementsToMove.size() == 1) {
PsiElement element = elementsToMove.get(0);
elementDescription.setText(
JetRefactoringBundle.message(
"refactoring.move.specifc.element",
UsageViewUtil.getType(element),
UsageViewUtil.getLongName(element)
)
);
}
else if (elementsToMove.size() > 1) {
elementDescription.setText(JetRefactoringBundle.message("refactoring.move.selected.elements"));
}
if (targetPackageName != null && targetPackageName.length() != 0) {
classPackageChooser.prependItem(targetPackageName);
}
cbSearchInComments.setSelected(searchInComments);
cbSearchTextOccurences.setSelected(searchForTextOccurences);
((DestinationFolderComboBox) destinationFolderCB).setData(
myProject,
targetDirectory,
new Pass<String>() {
@Override
public void pass(String s) {
setErrorText(s);
}
},
classPackageChooser.getChildComponent()
);
UIUtil.setEnabled(targetPanel, hasAnySourceRoots(), true);
validateButtons();
}
private void createUIComponents() {
classPackageChooser = createPackageChooser();
destinationFolderCB = new DestinationFolderComboBox() {
@Override
public String getTargetPackage() {
return MoveKotlinTopLevelDeclarationsDialog.this.getTargetPackage();
}
};
}
private ReferenceEditorComboWithBrowseButton createPackageChooser() {
ReferenceEditorComboWithBrowseButton packageChooser =
new PackageNameReferenceEditorCombo("", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
Document document = packageChooser.getChildComponent().getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
validateButtons();
}
});
return packageChooser;
}
private boolean hasAnySourceRoots() {
return !JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject).isEmpty();
}
@Override
protected JComponent createCenterPanel() {
boolean isDestinationVisible = hasAnySourceRoots();
destinationFolderCB.setVisible(isDestinationVisible);
targetDestinationLabel.setVisible(isDestinationVisible);
return null;
}
@Override
protected JComponent createNorthPanel() {
return mainPanel;
}
@Override
protected String getDimensionServiceKey() {
return "#com.intellij.refactoring.move.moveClassesOrPackages.MoveKotlinTopLevelDeclarationsDialog.classes";
}
@Override
public JComponent getPreferredFocusedComponent() {
return classPackageChooser.getChildComponent();
}
private void saveRefactoringSettings() {
JavaRefactoringSettings refactoringSettings = JavaRefactoringSettings.getInstance();
refactoringSettings.MOVE_SEARCH_IN_COMMENTS = isSearchInComments();
refactoringSettings.MOVE_SEARCH_FOR_TEXT = isSearchInNonJavaFiles();
refactoringSettings.MOVE_PREVIEW_USAGES = isPreviewUsages();
}
@Nullable
private MoveDestination selectDestination() {
String packageName = getTargetPackage().trim();
if (packageName.length() > 0 && !PsiNameHelper.getInstance(myProject).isQualifiedName(packageName)) {
Messages.showErrorDialog(myProject, RefactoringBundle.message("please.enter.a.valid.target.package.name"),
RefactoringBundle.message("move.title"));
return null;
}
RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, packageName);
PackageWrapper targetPackage = new PackageWrapper(PsiManager.getInstance(myProject), packageName);
if (!targetPackage.exists()) {
int ret = Messages.showYesNoDialog(myProject, RefactoringBundle.message("package.does.not.exist", packageName),
RefactoringBundle.message("move.title"), Messages.getQuestionIcon());
if (ret != Messages.YES) return null;
}
return ((DestinationFolderComboBox) destinationFolderCB).selectDirectory(targetPackage, false);
}
@Override
protected void canRun() throws ConfigurationException {
String name = getTargetPackage().trim();
if (name.length() != 0 && !PsiNameHelper.getInstance(myProject).isQualifiedName(name)) {
throw new ConfigurationException("\'" + name + "\' is invalid destination package name");
}
}
protected String getTargetPackage() {
return classPackageChooser.getText();
}
@Override
protected void doAction() {
MoveDestination destination = selectDestination();
if (destination == null) return;
saveRefactoringSettings();
for (PsiElement element : elementsToMove) {
String message = destination.verify(element.getContainingFile());
if (message != null) {
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), message, null, myProject);
return;
}
}
try {
MoveKotlinTopLevelDeclarationsOptions options = new MoveKotlinTopLevelDeclarationsOptions(
elementsToMove, destination, isSearchInComments(), isSearchInNonJavaFiles(), moveCallback
);
invokeRefactoring(new MoveKotlinTopLevelDeclarationsProcessor(myProject, options));
}
catch (IncorrectOperationException e) {
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), e.getMessage(), null, myProject);
}
}
protected final boolean isSearchInNonJavaFiles() {
return cbSearchTextOccurences.isSelected();
}
protected final boolean isSearchInComments() {
return cbSearchInComments.isSelected();
}
}