Fix 'in' operator intention for Strings (KT-13974)
This commit is contained in:
committed by
Dmitry Jemerov
parent
93c2e7dfc0
commit
925c48c2f0
+2
-1
@@ -48,7 +48,8 @@ class ReplaceContainsIntention : SelfTargetingRangeIntention<KtDotQualifiedExpre
|
|||||||
if (!element.isReceiverExpressionWithValue()) return null
|
if (!element.isReceiverExpressionWithValue()) return null
|
||||||
|
|
||||||
val functionDescriptor = getFunctionDescriptor(element) ?: return null
|
val functionDescriptor = getFunctionDescriptor(element) ?: return null
|
||||||
if (!functionDescriptor.isOperator || !OperatorChecks.check(functionDescriptor).isSuccess) return null
|
|
||||||
|
if (!functionDescriptor.isOperator && !OperatorChecks.check(functionDescriptor).isSuccess) return null
|
||||||
|
|
||||||
return element.callExpression!!.calleeExpression!!.textRange
|
return element.callExpression!!.calleeExpression!!.textRange
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
@Suppress("INAPPLICABLE_OPERATOR_MODIFIER")
|
||||||
|
public operator fun CharSequence.contains(other: CharSequence, ignoreCase: Boolean = false): Boolean = false
|
||||||
|
fun test() {
|
||||||
|
val foo = "foo"
|
||||||
|
foo.c<caret>ontains("bar")
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
@Suppress("INAPPLICABLE_OPERATOR_MODIFIER")
|
||||||
|
public operator fun CharSequence.contains(other: CharSequence, ignoreCase: Boolean = false): Boolean = false
|
||||||
|
fun test() {
|
||||||
|
val foo = "foo"
|
||||||
|
"bar" in foo
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class Container {
|
||||||
|
public boolean contains(int x, int y) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class Container {
|
||||||
|
public boolean contains(int x, int y) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val c = Container()
|
||||||
|
c.cont<caret>ains(1, 2)
|
||||||
|
}
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
// IS_APPLICABLE: false
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
class Test{
|
|
||||||
fun contains(a: Int) : Boolean = true
|
|
||||||
}
|
|
||||||
val test = Test()
|
|
||||||
test.c<caret>ontains(0)
|
|
||||||
}
|
|
||||||
@@ -3140,12 +3140,24 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleStringLiteral.kt")
|
||||||
|
public void testSimpleStringLiteral() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceContains/simpleStringLiteral.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("super.kt")
|
@TestMetadata("super.kt")
|
||||||
public void testSuper() throws Exception {
|
public void testSuper() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceContains/super.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceContains/super.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("twoArgsContainsFromJava.kt")
|
||||||
|
public void testTwoArgsContainsFromJava() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceContains/twoArgsContainsFromJava.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("typeArguments.kt")
|
@TestMetadata("typeArguments.kt")
|
||||||
public void testTypeArguments() throws Exception {
|
public void testTypeArguments() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceContains/typeArguments.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceContains/typeArguments.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user