Reformat: "if then to safe access" inspection
This commit is contained in:
+4
-6
@@ -43,21 +43,19 @@ class IfThenToSafeAccessInspection : AbstractApplicabilityBasedInspection<KtIfEx
|
||||
override fun inspectionText(element: KtIfExpression) = "Foldable if-then"
|
||||
|
||||
override fun inspectionHighlightType(element: KtIfExpression): ProblemHighlightType =
|
||||
if (element.shouldBeTransformed()) ProblemHighlightType.GENERIC_ERROR_OR_WARNING else ProblemHighlightType.INFORMATION
|
||||
if (element.shouldBeTransformed()) ProblemHighlightType.GENERIC_ERROR_OR_WARNING else ProblemHighlightType.INFORMATION
|
||||
|
||||
override val defaultFixText = "Simplify foldable if-then"
|
||||
|
||||
override fun fixText(element: KtIfExpression) : String {
|
||||
override fun fixText(element: KtIfExpression): String {
|
||||
val ifThenToSelectData = element.buildSelectTransformationData()
|
||||
return if (ifThenToSelectData?.baseClauseEvaluatesToReceiver() == true) {
|
||||
if (ifThenToSelectData.condition is KtIsExpression) {
|
||||
"Replace 'if' expression with safe cast expression"
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
"Remove redundant 'if' expression"
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
"Replace 'if' expression with safe access expression"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user