Inline variable: do not show dialog / preview from J2K #KT-19332 Fixed
This commit is contained in:
@@ -280,7 +280,7 @@ object J2KPostProcessingRegistrar {
|
||||
if (!UnnecessaryVariableInspection.isActiveFor(element)) return null
|
||||
|
||||
return {
|
||||
KotlinInlineValHandler().inlineElement(element.project, element.findExistingEditor(), element)
|
||||
KotlinInlineValHandler(withPrompt = false).inlineElement(element.project, element.findExistingEditor(), element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ class KotlinInlineValDialog(
|
||||
private val property: KtProperty,
|
||||
private val reference: KtSimpleNameReference?,
|
||||
private val replacementStrategy: UsageReplacementStrategy,
|
||||
private val assignmentToDelete: KtBinaryExpression?
|
||||
private val assignmentToDelete: KtBinaryExpression?,
|
||||
withPreview: Boolean = true
|
||||
) : InlineOptionsDialog(property.project, true, property) {
|
||||
|
||||
private var occurrenceCount = initOccurrencesNumber(property)
|
||||
@@ -42,7 +43,7 @@ class KotlinInlineValDialog(
|
||||
init {
|
||||
myInvokedOnReference = reference != null
|
||||
title = refactoringName
|
||||
setPreviewResults(shouldBeShown())
|
||||
setPreviewResults(withPreview && shouldBeShown())
|
||||
if (forSimpleLocal()) {
|
||||
setDoNotAskOption(object : DialogWrapper.DoNotAskOption {
|
||||
override fun isToBeShown() = EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog
|
||||
|
||||
@@ -47,7 +47,9 @@ import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAssignmentByLHS
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis
|
||||
|
||||
class KotlinInlineValHandler : InlineActionHandler() {
|
||||
class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHandler() {
|
||||
|
||||
constructor(): this(withPrompt = true)
|
||||
|
||||
override fun isEnabledForLanguage(l: Language) = l == KotlinLanguage.INSTANCE
|
||||
|
||||
@@ -185,9 +187,9 @@ class KotlinInlineValHandler : InlineActionHandler() {
|
||||
|
||||
val reference = editor?.let { TargetElementUtil.findReference(it, it.caretModel.offset) } as? KtSimpleNameReference
|
||||
|
||||
val dialog = KotlinInlineValDialog(declaration, reference, replacementStrategy, assignmentToDelete)
|
||||
val dialog = KotlinInlineValDialog(declaration, reference, replacementStrategy, assignmentToDelete, withPreview = withPrompt)
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode && dialog.shouldBeShown()) {
|
||||
if (withPrompt && !ApplicationManager.getApplication().isUnitTestMode && dialog.shouldBeShown()) {
|
||||
dialog.show()
|
||||
if (!dialog.isOK && hasHighlightings) {
|
||||
val statusBar = WindowManager.getInstance().getStatusBar(declaration.project)
|
||||
|
||||
Reference in New Issue
Block a user