Do not show "Replace overloaded operator with function call" intention on incomplete expressions
#KT-33115 fixed
This commit is contained in:
+2
@@ -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()) {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// DISABLE-ERRORS
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
val x: Int = 1 <caret>+
|
||||
@@ -0,0 +1,3 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
val x = <caret>+
|
||||
@@ -12492,6 +12492,16 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/operatorToFunction/inRightSideOfAssignment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("incompleteBinaryExpression.kt")
|
||||
public void testIncompleteBinaryExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/operatorToFunction/incompleteBinaryExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("incompleteUnaryExpression.kt")
|
||||
public void testIncompleteUnaryExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/operatorToFunction/incompleteUnaryExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("keepComments.kt")
|
||||
public void testKeepComments() throws Exception {
|
||||
runTest("idea/testData/intentions/operatorToFunction/keepComments.kt");
|
||||
|
||||
Reference in New Issue
Block a user