Invoke back setting "show inline dialog for local variables"

So #KT-19130 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-07-20 13:08:40 +03:00
parent a7084ceb9b
commit 31bb1cc0f9
2 changed files with 24 additions and 2 deletions
@@ -16,6 +16,8 @@
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.refactoring.JavaRefactoringSettings
import com.intellij.refactoring.inline.InlineOptionsDialog
@@ -29,7 +31,7 @@ class KotlinInlineValDialog(
private val reference: KtSimpleNameReference?,
private val replacementStrategy: UsageReplacementStrategy,
private val assignmentToDelete: KtBinaryExpression?
) : InlineOptionsDialog(property.project, true, property) {
) : InlineOptionsDialog(property.project, true, property) {
private var occurrenceCount = initOccurrencesNumber(property)
@@ -40,9 +42,29 @@ class KotlinInlineValDialog(
init {
myInvokedOnReference = reference != null
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()
}
private fun forSimpleLocal() = property.isLocal && (reference == null || occurrenceCount == 1)
fun shouldBeShown() = !forSimpleLocal() || EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog
override fun allowInlineAll() = true
override fun getBorderTitle() = refactoringName
@@ -187,7 +187,7 @@ class KotlinInlineValHandler : InlineActionHandler() {
val dialog = KotlinInlineValDialog(declaration, reference, replacementStrategy, assignmentToDelete)
if (!ApplicationManager.getApplication().isUnitTestMode) {
if (!ApplicationManager.getApplication().isUnitTestMode && dialog.shouldBeShown()) {
dialog.show()
if (!dialog.isOK && hasHighlightings) {
val statusBar = WindowManager.getInstance().getStatusBar(declaration.project)