Do not show "Replace overloaded operator with function call" intention on incomplete expressions

#KT-33115 fixed
This commit is contained in:
Ilya Kirillov
2019-08-02 15:10:58 +03:00
parent 892135ae23
commit 02f2009f2a
4 changed files with 19 additions and 0 deletions
@@ -40,6 +40,7 @@ class OperatorToFunctionIntention :
SelfTargetingIntention<KtExpression>(KtExpression::class.java, "Replace overloaded operator with function call") {
companion object {
private fun isApplicableUnary(element: KtUnaryExpression, caretOffset: Int): Boolean {
if (element.baseExpression == null) return false
val opRef = element.operationReference
if (!opRef.textRange.containsOffset(caretOffset)) return false
return when (opRef.getReferencedNameElementType()) {
@@ -63,6 +64,7 @@ class OperatorToFunctionIntention :
}
private fun isApplicableBinary(element: KtBinaryExpression, caretOffset: Int): Boolean {
if (element.left == null || element.right == null) return false
val opRef = element.operationReference
if (!opRef.textRange.containsOffset(caretOffset)) return false
return when (opRef.getReferencedNameElementType()) {