'Replace with infix call' Intention: Disable on calls without explicit receiver

#KT-6332 Fixed
This commit is contained in:
Alexey Sedunov
2015-12-18 14:30:33 +03:00
parent ae636a0d32
commit 123b813073
3 changed files with 11 additions and 1 deletions
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
@@ -28,7 +29,7 @@ public class ToInfixCallIntention : SelfTargetingIntention<KtCallExpression>(KtC
val calleeExpr = element.calleeExpression as? KtNameReferenceExpression ?: return false
if (!calleeExpr.textRange.containsOffset(caretOffset)) return false
val dotQualified = element.parent as? KtDotQualifiedExpression ?: return false
val dotQualified = element.getQualifiedExpressionForSelector() ?: return false
if (element.typeArgumentList != null) return false
@@ -0,0 +1,3 @@
// IS_APPLICABLE: false
infix fun id(s: String) = s
val x = <caret>id("0").get(0)
@@ -8272,6 +8272,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("noExplicitReceiver.kt")
public void testNoExplicitReceiver() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/toInfixCall/noExplicitReceiver.kt");
doTest(fileName);
}
@TestMetadata("notInfix.kt")
public void testNotInfix() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/toInfixCall/notInfix.kt");