Object literal to lambda: more precise shorten references #KT-14289 Fixed
This commit is contained in:
@@ -85,7 +85,7 @@ class ObjectLiteralToLambdaIntention : SelfTargetingRangeIntention<KtObjectLiter
|
||||
override fun applyTo(element: KtObjectLiteralExpression, editor: Editor?) {
|
||||
val commentSaver = CommentSaver(element)
|
||||
|
||||
val (@Suppress("UNUSED_VARIABLE") baseTypeRef, baseType, singleFunction) = extractData(element)!!
|
||||
val (baseTypeRef, baseType, singleFunction) = extractData(element)!!
|
||||
|
||||
val returnSaver = ReturnSaver(singleFunction)
|
||||
|
||||
@@ -141,7 +141,8 @@ class ObjectLiteralToLambdaIntention : SelfTargetingRangeIntention<KtObjectLiter
|
||||
}
|
||||
}
|
||||
else {
|
||||
ShortenReferences.DEFAULT.process(replaced.getContainingKtFile(), replaced.startOffset, callee.endOffset)
|
||||
val endOffset = (callee.parent as? KtCallExpression)?.typeArgumentList?.endOffset ?: callee.endOffset
|
||||
ShortenReferences.DEFAULT.process(replaced.getContainingKtFile(), replaced.startOffset, endOffset)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
interface User<T> {
|
||||
void call(T arg);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
interface User<T> {
|
||||
void call(T arg);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun use() {
|
||||
val myUser = <caret>object : User<String> {
|
||||
override fun call(arg: String) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun use() {
|
||||
val myUser = User<String> { }
|
||||
}
|
||||
@@ -10118,6 +10118,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ShortGenericArgument.kt")
|
||||
public void testShortGenericArgument() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/objectLiteralToLambda/ShortGenericArgument.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/objectLiteralToLambda/Simple.kt");
|
||||
|
||||
Reference in New Issue
Block a user