Inline dialog: handle case with unknown occurrence number correctly
So #KT-21963 Fixed
This commit is contained in:
@@ -30,6 +30,7 @@ abstract class AbstractKotlinInlineDialog(
|
|||||||
project: Project = callable.project
|
project: Project = callable.project
|
||||||
) : InlineOptionsDialog(project, true, callable) {
|
) : InlineOptionsDialog(project, true, callable) {
|
||||||
|
|
||||||
|
// NB: can be -1 in case of too expensive search!
|
||||||
protected val occurrencesNumber = initOccurrencesNumber(callable)
|
protected val occurrencesNumber = initOccurrencesNumber(callable)
|
||||||
|
|
||||||
private val occurrencesString get() = if (occurrencesNumber >= 0) {
|
private val occurrencesString get() = if (occurrencesNumber >= 0) {
|
||||||
@@ -59,19 +60,20 @@ abstract class AbstractKotlinInlineDialog(
|
|||||||
override fun getBorderTitle() = refactoringName
|
override fun getBorderTitle() = refactoringName
|
||||||
|
|
||||||
override fun getNameLabelText(): String {
|
override fun getNameLabelText(): String {
|
||||||
val occurrencesString =
|
val occurrencesString = occurrencesString?.let { " - $it" } ?: ""
|
||||||
if (occurrencesNumber >= 0) " - $occurrencesString"
|
|
||||||
else ""
|
|
||||||
return "${kind.capitalize()} ${callable.nameAsSafeName} $occurrencesString"
|
return "${kind.capitalize()} ${callable.nameAsSafeName} $occurrencesString"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getInlineText(verb: String) =
|
||||||
|
"Inline all references and $verb the $kind " + (occurrencesString?.let { "($it)" } ?: "")
|
||||||
|
|
||||||
override fun getInlineAllText() =
|
override fun getInlineAllText() =
|
||||||
"Inline all references and remove the $kind ($occurrencesString)"
|
getInlineText("remove")
|
||||||
|
|
||||||
override fun getKeepTheDeclarationText(): String? =
|
override fun getKeepTheDeclarationText(): String? =
|
||||||
// With non-writable callable refactoring does not work anyway (for both property or function)
|
// With non-writable callable refactoring does not work anyway (for both property or function)
|
||||||
if (callable.isWritable && (occurrencesNumber > 1 || !myInvokedOnReference)) {
|
if (callable.isWritable && (occurrencesNumber > 1 || !myInvokedOnReference)) {
|
||||||
"Inline all references and keep the $kind ($occurrencesString)"
|
getInlineText("keep")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
null
|
null
|
||||||
|
|||||||
Reference in New Issue
Block a user