From 25952036af7b8d29ef5f7aa69300402ff0d36625 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Sat, 2 Feb 2019 10:44:54 +0900 Subject: [PATCH] Reformat RedundantExplicitTypeInspection --- .../RedundantExplicitTypeInspection.kt | 94 +++++++++---------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantExplicitTypeInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantExplicitTypeInspection.kt index bbb62f3370a..c1e5f2581ba 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantExplicitTypeInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantExplicitTypeInspection.kt @@ -16,57 +16,55 @@ import org.jetbrains.kotlin.psi.* class RedundantExplicitTypeInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean) = - propertyVisitor(fun(property) { - if (!property.isLocal) return - val typeReference = property.typeReference ?: return - val initializer = property.initializer ?: return + propertyVisitor(fun(property) { + if (!property.isLocal) return + val typeReference = property.typeReference ?: return + val initializer = property.initializer ?: return - val type = property.resolveToDescriptorIfAny()?.type ?: return - when (initializer) { - is KtConstantExpression -> { - when (initializer.node.elementType) { - KtNodeTypes.BOOLEAN_CONSTANT -> { - if (!KotlinBuiltIns.isBoolean(type)) return - } - KtNodeTypes.INTEGER_CONSTANT -> { - if (initializer.text.endsWith("L")) { - if (!KotlinBuiltIns.isLong(type)) return - } - else { - if (!KotlinBuiltIns.isInt(type)) return - } - } - KtNodeTypes.FLOAT_CONSTANT -> { - if (initializer.text.endsWith("f") || initializer.text.endsWith("F")) { - if (!KotlinBuiltIns.isFloat(type)) return - } - else { - if (!KotlinBuiltIns.isDouble(type)) return - } - } - KtNodeTypes.CHARACTER_CONSTANT -> { - if (!KotlinBuiltIns.isChar(type)) return - } - else -> return + val type = property.resolveToDescriptorIfAny()?.type ?: return + when (initializer) { + is KtConstantExpression -> { + when (initializer.node.elementType) { + KtNodeTypes.BOOLEAN_CONSTANT -> { + if (!KotlinBuiltIns.isBoolean(type)) return } + KtNodeTypes.INTEGER_CONSTANT -> { + if (initializer.text.endsWith("L")) { + if (!KotlinBuiltIns.isLong(type)) return + } else { + if (!KotlinBuiltIns.isInt(type)) return + } + } + KtNodeTypes.FLOAT_CONSTANT -> { + if (initializer.text.endsWith("f") || initializer.text.endsWith("F")) { + if (!KotlinBuiltIns.isFloat(type)) return + } else { + if (!KotlinBuiltIns.isDouble(type)) return + } + } + KtNodeTypes.CHARACTER_CONSTANT -> { + if (!KotlinBuiltIns.isChar(type)) return + } + else -> return } - is KtStringTemplateExpression -> { - if (!KotlinBuiltIns.isString(type)) return - } - is KtNameReferenceExpression -> { - if (typeReference.text != initializer.getReferencedName()) return - } - is KtCallExpression -> { - if (typeReference.text != initializer.calleeExpression?.text) return - } - else -> return } + is KtStringTemplateExpression -> { + if (!KotlinBuiltIns.isString(type)) return + } + is KtNameReferenceExpression -> { + if (typeReference.text != initializer.getReferencedName()) return + } + is KtCallExpression -> { + if (typeReference.text != initializer.calleeExpression?.text) return + } + else -> return + } - holder.registerProblem( - typeReference, - "Explicitly given type is redundant here", - ProblemHighlightType.LIKE_UNUSED_SYMBOL, - IntentionWrapper(RemoveExplicitTypeIntention(), property.containingKtFile) - ) - }) + holder.registerProblem( + typeReference, + "Explicitly given type is redundant here", + ProblemHighlightType.LIKE_UNUSED_SYMBOL, + IntentionWrapper(RemoveExplicitTypeIntention(), property.containingKtFile) + ) + }) } \ No newline at end of file