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:
+3
@@ -40,6 +40,9 @@ class IfThenToSafeAccessIntention : SelfTargetingOffsetIndependentIntention<KtIf
|
|||||||
override fun isApplicableTo(element: KtIfExpression): Boolean {
|
override fun isApplicableTo(element: KtIfExpression): Boolean {
|
||||||
val ifThenToSelectData = element.buildSelectTransformationData() ?: return false
|
val ifThenToSelectData = element.buildSelectTransformationData() ?: return false
|
||||||
if (!ifThenToSelectData.receiverExpression.isStableVariable(ifThenToSelectData.context)) 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()
|
return ifThenToSelectData.clausesReplaceableBySafeCall()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -133,6 +133,6 @@
|
|||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/isCheckSimple.kt" />
|
<entry_point TYPE="file" FQNAME="temp:///src/isCheckSimple.kt" />
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?.'</problem_class>
|
<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>
|
</problem>
|
||||||
</problems>
|
</problems>
|
||||||
|
|||||||
Reference in New Issue
Block a user