Invoke back setting "show inline dialog for local variables"
So #KT-19130 Fixed
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.refactoring.inline
|
package org.jetbrains.kotlin.idea.refactoring.inline
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||||
|
import com.intellij.openapi.ui.DialogWrapper
|
||||||
import com.intellij.openapi.util.text.StringUtil
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
import com.intellij.refactoring.JavaRefactoringSettings
|
import com.intellij.refactoring.JavaRefactoringSettings
|
||||||
import com.intellij.refactoring.inline.InlineOptionsDialog
|
import com.intellij.refactoring.inline.InlineOptionsDialog
|
||||||
@@ -29,7 +31,7 @@ class KotlinInlineValDialog(
|
|||||||
private val reference: KtSimpleNameReference?,
|
private val reference: KtSimpleNameReference?,
|
||||||
private val replacementStrategy: UsageReplacementStrategy,
|
private val replacementStrategy: UsageReplacementStrategy,
|
||||||
private val assignmentToDelete: KtBinaryExpression?
|
private val assignmentToDelete: KtBinaryExpression?
|
||||||
) : InlineOptionsDialog(property.project, true, property) {
|
) : InlineOptionsDialog(property.project, true, property) {
|
||||||
|
|
||||||
private var occurrenceCount = initOccurrencesNumber(property)
|
private var occurrenceCount = initOccurrencesNumber(property)
|
||||||
|
|
||||||
@@ -40,9 +42,29 @@ class KotlinInlineValDialog(
|
|||||||
init {
|
init {
|
||||||
myInvokedOnReference = reference != null
|
myInvokedOnReference = reference != null
|
||||||
title = refactoringName
|
title = refactoringName
|
||||||
|
setPreviewResults(shouldBeShown())
|
||||||
|
if (forSimpleLocal()) {
|
||||||
|
setDoNotAskOption(object : DialogWrapper.DoNotAskOption {
|
||||||
|
override fun isToBeShown() = EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog
|
||||||
|
|
||||||
|
override fun setToBeShown(value: Boolean, exitCode: Int) {
|
||||||
|
EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog = value
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun canBeHidden() = true
|
||||||
|
|
||||||
|
override fun shouldSaveOptionsOnCancel() = false
|
||||||
|
|
||||||
|
override fun getDoNotShowMessage() = "Do not show for local variables in future"
|
||||||
|
})
|
||||||
|
}
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun forSimpleLocal() = property.isLocal && (reference == null || occurrenceCount == 1)
|
||||||
|
|
||||||
|
fun shouldBeShown() = !forSimpleLocal() || EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog
|
||||||
|
|
||||||
override fun allowInlineAll() = true
|
override fun allowInlineAll() = true
|
||||||
|
|
||||||
override fun getBorderTitle() = refactoringName
|
override fun getBorderTitle() = refactoringName
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ class KotlinInlineValHandler : InlineActionHandler() {
|
|||||||
|
|
||||||
val dialog = KotlinInlineValDialog(declaration, reference, replacementStrategy, assignmentToDelete)
|
val dialog = KotlinInlineValDialog(declaration, reference, replacementStrategy, assignmentToDelete)
|
||||||
|
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode) {
|
if (!ApplicationManager.getApplication().isUnitTestMode && dialog.shouldBeShown()) {
|
||||||
dialog.show()
|
dialog.show()
|
||||||
if (!dialog.isOK && hasHighlightings) {
|
if (!dialog.isOK && hasHighlightings) {
|
||||||
val statusBar = WindowManager.getInstance().getStatusBar(declaration.project)
|
val statusBar = WindowManager.getInstance().getStatusBar(declaration.project)
|
||||||
|
|||||||
Reference in New Issue
Block a user