If to safe access: fix message when no dot calls are available

Now "Replace 'if' with safe cast" is suggested
This commit is contained in:
Mikhail Glukhikh
2017-05-11 18:15:10 +03:00
parent a77390ccd6
commit 977d8e1cd7
2 changed files with 4 additions and 1 deletions
@@ -40,6 +40,9 @@ class IfThenToSafeAccessIntention : SelfTargetingOffsetIndependentIntention<KtIf
override fun isApplicableTo(element: KtIfExpression): Boolean {
val ifThenToSelectData = element.buildSelectTransformationData() ?: return false
if (!ifThenToSelectData.receiverExpression.isStableVariable(ifThenToSelectData.context)) return false
if (ifThenToSelectData.baseClause !is KtDotQualifiedExpression) {
text = "Replace 'if' expression with safe cast expression"
}
return ifThenToSelectData.clausesReplaceableBySafeCall()
}
@@ -133,6 +133,6 @@
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/isCheckSimple.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
<description>Replace 'if' expression with safe access expression</description>
<description>Replace 'if' expression with safe cast expression</description>
</problem>
</problems>