KotlinChangeSignature refactoring remove deprecated usage + refactoring

This commit is contained in:
Igor Yakovlev
2020-03-13 17:48:09 +03:00
parent 309ceef49a
commit 64bcc6d54f
5 changed files with 68 additions and 6 deletions
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtPsiFactory
import javax.swing.JCheckBox
import javax.swing.JComboBox
import javax.swing.JComponent
import javax.swing.JLabel
import kotlin.properties.Delegates
@@ -31,7 +30,7 @@ class KotlinChangePropertySignatureDialog(
private val methodDescriptor: KotlinMethodDescriptor,
private val commandName: String?
) : RefactoringDialog(project, true) {
private val visibilityCombo = JComboBox(
private val visibilityCombo = ComboBox(
arrayOf(Visibilities.INTERNAL, Visibilities.PRIVATE, Visibilities.PROTECTED, Visibilities.PUBLIC)
)
private val nameField = EditorTextField(methodDescriptor.name)
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.Messages.OkCancelResult
import org.jetbrains.kotlin.descriptors.Visibility
import javax.swing.Icon
// BUNCH: 193
@OkCancelResult
fun showOkCancelDialog(
project: Project?,
message: String?,
title: String,
icon: Icon?
): Int {
return Messages.showOkCancelDialog(
project,
message,
title,
icon
)
}
typealias ComboBox = javax.swing.JComboBox<Visibility>
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.Messages.OkCancelResult
import javax.swing.Icon
// BUNCH: 193
@OkCancelResult
fun showOkCancelDialog(
project: Project?,
message: String?,
title: String,
icon: Icon?
): Int {
return Messages.showOkCancelDialog(
project,
message,
title,
Messages.OK_BUTTON,
Messages.CANCEL_BUTTON,
icon
)
}
typealias ComboBox = com.intellij.openapi.ui.ComboBox<Visibility>
@@ -332,7 +332,7 @@ class KotlinChangeSignatureDialog(
if (myMethod.canChangeReturnType() == MethodDescriptor.ReadWriteOption.ReadWrite &&
myReturnTypeCodeFragment.getTypeInfo(isCovariant = true, forPreview = false, reanalyse = true).type == null
) {
if (Messages.showOkCancelDialog(
if (showOkCancelDialog(
myProject,
KotlinBundle.message("message.text.return.type.cannot.be.resolved",
myReturnTypeCodeFragment?.text.toString()
@@ -351,7 +351,7 @@ class KotlinChangeSignatureDialog(
KotlinBundle.message("text.parameter.0", item.parameter.name)
else
KotlinBundle.message("text.receiver")
if (Messages.showOkCancelDialog(
if (showOkCancelDialog(
myProject,
KotlinBundle.message("message.type.for.cannot.be.resolved",
item.typeCodeFragment.text,
@@ -334,7 +334,7 @@ class KotlinChangeSignatureDialog(
if (myMethod.canChangeReturnType() == MethodDescriptor.ReadWriteOption.ReadWrite &&
myReturnTypeCodeFragment.getTypeInfo(isCovariant = true, forPreview = false).type == null
) {
if (Messages.showOkCancelDialog(
if (showOkCancelDialog(
myProject,
KotlinBundle.message("message.text.return.type.cannot.be.resolved",
myReturnTypeCodeFragment?.text.toString()
@@ -353,7 +353,7 @@ class KotlinChangeSignatureDialog(
KotlinBundle.message("text.parameter.0", item.parameter.name)
else
KotlinBundle.message("text.receiver")
if (Messages.showOkCancelDialog(
if (showOkCancelDialog(
myProject,
KotlinBundle.message("message.type.for.cannot.be.resolved",
item.typeCodeFragment.text,