diff --git a/ChangeLog.md b/ChangeLog.md index 98288f64a4c..91f5cbde715 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -136,6 +136,7 @@ These artifacts include extensions for the types available in the latter JDKs, s - [`KT-13916`](https://youtrack.jetbrains.com/issue/KT-13916) Move: Report visibility conflicts in import directives - [`KT-13906`](https://youtrack.jetbrains.com/issue/KT-13906) Move Nested Class to Upper Level: Do not show directory selection dialog twice - [`KT-13901`](https://youtrack.jetbrains.com/issue/KT-13901) Move: Do not ignore target directory selected in the dialog (DnD mode) +- [`KT-13904`](https://youtrack.jetbrains.com/issue/KT-13904) Move Nested Class to Upper Level: Preserve state of "Search in comments"/"Search for text occurrences" checkboxes ##### New features diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index bb71459324c..b4bc6829045 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -679,6 +679,9 @@ serviceImplementation="org.jetbrains.kotlin.idea.editor.KotlinEditorOptions"/> + + diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSettings.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSettings.kt new file mode 100644 index 00000000000..3214d13e862 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/KotlinRefactoringSettings.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2016 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.kotlin.idea.refactoring + +import com.intellij.openapi.components.PersistentStateComponent +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.components.State +import com.intellij.openapi.components.Storage +import com.intellij.util.xmlb.XmlSerializerUtil + +@State(name = "KotlinRefactoringSettings", storages = arrayOf(Storage("kotlinRefactoring.xml"))) +class KotlinRefactoringSettings : PersistentStateComponent { + @JvmField var MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS = false + @JvmField var MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT = false + + override fun getState() = this + + override fun loadState(state: KotlinRefactoringSettings) = XmlSerializerUtil.copyBean(state, this) + + companion object { + @JvmStatic + val instance: KotlinRefactoringSettings + get() = ServiceManager.getService(KotlinRefactoringSettings::class.java) + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java index 4cb3c5afdac..c7d668fc318 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/MoveKotlinNestedClassesToUpperLevelDialog.java @@ -51,6 +51,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils; import org.jetbrains.kotlin.idea.core.CollectingNameValidator; import org.jetbrains.kotlin.idea.core.KotlinNameSuggester; import org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator; +import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSettings; import org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringUtilKt; import org.jetbrains.kotlin.idea.refactoring.move.MoveUtilsKt; import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.*; @@ -219,6 +220,10 @@ public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase { packageNameField.prependItem(packageFqName.asString()); } + KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance(); + searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT); + searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS); + super.init(); } @@ -357,6 +362,10 @@ public class MoveKotlinNestedClassesToUpperLevelDialog extends MoveDialogBase { return; } + KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance(); + settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT = searchForTextOccurrencesCheckBox.isSelected(); + settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS = searchInCommentsCheckBox.isSelected(); + KotlinMoveTarget moveTarget; if (target instanceof PsiDirectory) { final PsiDirectory targetDir = (PsiDirectory) target;