diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantReturnLabelInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantReturnLabelInspection.kt index 622f564c7c8..806e01b1b49 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantReturnLabelInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantReturnLabelInspection.kt @@ -26,7 +26,7 @@ class RedundantReturnLabelInspection : AbstractKotlinInspection() { label, "Redundant '@$labelName'", ProblemHighlightType.LIKE_UNUSED_SYMBOL, - IntentionWrapper(RemoveReturnLabelFix(returnExpression), returnExpression.containingKtFile), + IntentionWrapper(RemoveReturnLabelFix(returnExpression, labelName), returnExpression.containingKtFile), ) }, ) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveReturnLabelFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveReturnLabelFix.kt index ad95fa1519c..ce6bdb840b4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveReturnLabelFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveReturnLabelFix.kt @@ -11,20 +11,20 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtReturnExpression -class RemoveReturnLabelFix(element: KtReturnExpression) : KotlinQuickFixAction(element) { +class RemoveReturnLabelFix(element: KtReturnExpression, private val labelName: String) : KotlinQuickFixAction(element) { override fun invoke(project: Project, editor: Editor?, file: KtFile) { element?.labeledExpression?.delete() } override fun getFamilyName(): String = "Remove redundant label" - override fun getText(): String = "Remove redundant ${element?.getLabelName()?.let { "'@$it'" } ?: "label"}" + override fun getText(): String = "Remove redundant '@$labelName'" companion object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val returnExpression = diagnostic.psiElement as? KtReturnExpression ?: return null - return if (returnExpression.labeledExpression == null) null - else RemoveReturnLabelFix(returnExpression) + val labelName = returnExpression.getLabelName() ?: return null + return RemoveReturnLabelFix(returnExpression, labelName) } } } \ No newline at end of file