Disabled "Convert to get/set call" intention where it did not work correctly anyway

This commit is contained in:
Valentin Kipyatkov
2015-10-20 18:26:57 +03:00
parent c6978d6b69
commit a3d9085ddd
6 changed files with 58 additions and 0 deletions
@@ -20,6 +20,8 @@ import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.references.ReferenceAccess
import org.jetbrains.kotlin.idea.references.readWriteAccess
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
@@ -61,6 +63,10 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<KtExpressio
private fun isApplicableArrayAccess(element: KtArrayAccessExpression, caretOffset: Int): Boolean {
val lbracket = element.getLeftBracket() ?: return false
val rbracket = element.getRightBracket() ?: return false
val access = element.readWriteAccess(useResolveForReadWrite = true)
if (access == ReferenceAccess.READ_WRITE) return false // currently not supported
return lbracket.getTextRange().containsOffset(caretOffset) || rbracket.getTextRange().containsOffset(caretOffset)
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: false
interface C {
operator fun get(p: String): Int
operator fun set(p: String, value: Int)
}
fun foo(c: C) {
c<caret>[""] += 10
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
interface C {
operator fun get(p: String): MutableList<Int>
}
fun foo(c: C) {
c<caret>[""] += 10
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
interface C {
operator fun get(p: String): MutableList<Int>
}
fun foo(c: C) {
c.get("") += 10
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: false
interface C {
operator fun get(p: String): Int
operator fun set(p: String, value: Int)
}
fun foo(c: C) {
c<caret>[""]++
}
@@ -5901,6 +5901,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("compoundAssignment.kt")
public void testCompoundAssignment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/compoundAssignment.kt");
doTest(fileName);
}
@TestMetadata("compoundAssignment2.kt")
public void testCompoundAssignment2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/compoundAssignment2.kt");
doTest(fileName);
}
@TestMetadata("functionCallMultipleArgument.kt")
public void testFunctionCallMultipleArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/functionCallMultipleArgument.kt");
@@ -5949,6 +5961,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("pluPlus.kt")
public void testPluPlus() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/pluPlus.kt");
doTest(fileName);
}
@TestMetadata("postfixMinusMinus.kt")
public void testPostfixMinusMinus() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/operatorToFunction/postfixMinusMinus.kt");