'Replace with infix call' Intention: Disable on calls without explicit receiver
#KT-6332 Fixed
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor
|
|||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.psi.*
|
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.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
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
|
val calleeExpr = element.calleeExpression as? KtNameReferenceExpression ?: return false
|
||||||
if (!calleeExpr.textRange.containsOffset(caretOffset)) 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
|
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);
|
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")
|
@TestMetadata("notInfix.kt")
|
||||||
public void testNotInfix() throws Exception {
|
public void testNotInfix() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/toInfixCall/notInfix.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/toInfixCall/notInfix.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user