Fixed EA-74848 + conversion was incorrect!
This commit is contained in:
+4
-2
@@ -147,8 +147,8 @@ class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(KtExpre
|
||||
KtTokens.MULTEQ -> if (functionName == "multAssign") "$0.multAssign($1)" else "$0 = $0.mult($1)"
|
||||
KtTokens.DIVEQ -> if (functionName == "divAssign") "$0.divAssign($1)" else "$0 = $0.div($1)"
|
||||
KtTokens.PERCEQ -> if (functionName == "modAssign") "$0.modAssign($1)" else "$0 = $0.mod($1)"
|
||||
KtTokens.EQEQ -> if (elemType?.isMarkedNullable() ?: true) "$0?.equals($1) ?: $1 == null" else "$0.equals($1)"
|
||||
KtTokens.EXCLEQ -> if (elemType?.isMarkedNullable() ?: true) "!($0?.equals($1) ?: $1 == null)" else "!$0.equals($1)"
|
||||
KtTokens.EQEQ -> if (elemType?.isMarkedNullable() ?: true) "$0?.equals($1) ?: ($1 == null)" else "$0.equals($1)"
|
||||
KtTokens.EXCLEQ -> if (elemType?.isMarkedNullable() ?: true) "!($0?.equals($1) ?: ($1 == null))" else "!$0.equals($1)"
|
||||
KtTokens.GT -> "$0.compareTo($1) > 0"
|
||||
KtTokens.LT -> "$0.compareTo($1) < 0"
|
||||
KtTokens.GTEQ -> "$0.compareTo($1) >= 0"
|
||||
@@ -249,6 +249,8 @@ class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(KtExpre
|
||||
result.baseExpression?.let { findCallName(it) }
|
||||
}
|
||||
|
||||
is KtParenthesizedExpression -> result.expression?.let { findCallName(it) }
|
||||
|
||||
else -> result.getQualifiedElementSelector() as KtSimpleNameExpression?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo(p1: String?, p2: String?) {
|
||||
if (p1 <caret>!= p2) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo(p1: String?, p2: String?) {
|
||||
if (!(p1?.equals(p2) ?: (p2 == null))) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: String, b: String?) {
|
||||
a <caret>== b
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(a: String, b: String?) {
|
||||
a.equals(b)
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
fun foo(a: String?, b: String?) {
|
||||
a?.equals(b) ?: b == null
|
||||
a?.equals(b) ?: (b == null)
|
||||
}
|
||||
@@ -6896,15 +6896,27 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("binaryEqualsEqualsNullableOperands.kt")
|
||||
public void testBinaryEqualsEqualsNullableOperands() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/binaryEqualsEqualsNullableOperands.kt");
|
||||
@TestMetadata("binarayNotEqNullable.kt")
|
||||
public void testBinarayNotEqNullable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/binarayNotEqNullable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("binaryNotEqualsNonNullableOperands.kt")
|
||||
public void testBinaryNotEqualsNonNullableOperands() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/binaryNotEqualsNonNullableOperands.kt");
|
||||
@TestMetadata("binaryEqEqNonNullable.kt")
|
||||
public void testBinaryEqEqNonNullable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/binaryEqEqNonNullable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("binaryEqEqNullable.kt")
|
||||
public void testBinaryEqEqNullable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/binaryEqEqNullable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("binaryNotEqNonNullable.kt")
|
||||
public void testBinaryNotEqNonNullable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/binaryNotEqNonNullable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user