From cccc6bf315ad890947ed89527b5443483c1a524c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 5 Feb 2019 12:57:14 +0300 Subject: [PATCH] Redundant enum constructor invocation inspection: minor rename --- .../RedundantEnumConstructorInvocationInspection.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantEnumConstructorInvocationInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantEnumConstructorInvocationInspection.kt index ed1d507f7ed..56dbec811eb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantEnumConstructorInvocationInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantEnumConstructorInvocationInspection.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType class RedundantEnumConstructorInvocationInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = enumEntryVisitor(fun(enumEntry) { - val valueArgumentList = enumEntry.valueArgumentList() ?: return + val valueArgumentList = enumEntry.valueArgumentListIfEmpty() ?: return holder.registerProblem( valueArgumentList, "Redundant enum constructor invocation", @@ -39,12 +39,12 @@ private class RemoveEnumConstructorInvocationFix : LocalQuickFix { override fun applyFix(project: Project, descriptor: ProblemDescriptor) { descriptor.psiElement.getStrictParentOfType()?.containingClass()?.body?.getChildrenOfType()?.forEach { - it.valueArgumentList()?.delete() + it.valueArgumentListIfEmpty()?.delete() } } } -private fun KtEnumEntry.valueArgumentList(): KtValueArgumentList? { +private fun KtEnumEntry.valueArgumentListIfEmpty(): KtValueArgumentList? { val superTypeCallEntry = initializerList?.initializers?.singleOrNull() as? KtSuperTypeCallEntry ?: return null val valueArgumentList = superTypeCallEntry.valueArgumentList ?: return null if (valueArgumentList.arguments.isNotEmpty()) return null