KT-12328 Qualified function name inserted when typing before "if"
#KT-12328 Fixed
This commit is contained in:
+10
-4
@@ -37,7 +37,8 @@ abstract class KotlinCallableInsertHandler(val callType: CallType<*>) : BaseDecl
|
||||
}
|
||||
|
||||
private fun addImport(context : InsertionContext, item : LookupElement) {
|
||||
PsiDocumentManager.getInstance(context.project).commitAllDocuments()
|
||||
val psiDocumentManager = PsiDocumentManager.getInstance(context.project)
|
||||
psiDocumentManager.commitAllDocuments()
|
||||
|
||||
val file = context.file
|
||||
val o = item.`object`
|
||||
@@ -50,10 +51,15 @@ abstract class KotlinCallableInsertHandler(val callType: CallType<*>) : BaseDecl
|
||||
}
|
||||
else if (callType == CallType.DEFAULT) {
|
||||
val fqName = descriptor.importableFqName ?: return
|
||||
context.document.replaceString(context.startOffset, context.tailOffset, fqName.render())
|
||||
context.document.replaceString(context.startOffset, context.tailOffset, fqName.render() + " ") // insert space after for correct parsing
|
||||
|
||||
PsiDocumentManager.getInstance(context.project).commitAllDocuments()
|
||||
ShortenReferences.DEFAULT.process(file, context.startOffset, context.tailOffset)
|
||||
psiDocumentManager.commitAllDocuments()
|
||||
|
||||
ShortenReferences.DEFAULT.process(file, context.startOffset, context.tailOffset - 1)
|
||||
|
||||
psiDocumentManager.doPostponedOperationsAndUnblockDocument(context.document)
|
||||
|
||||
context.document.deleteString(context.tailOffset - 1, context.tailOffset) // delete space
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun f() {
|
||||
val v = <caret>if (x) a else b
|
||||
}
|
||||
|
||||
// ELEMENT: emptyList
|
||||
@@ -0,0 +1,5 @@
|
||||
fun f() {
|
||||
val v = emptyList<<caret>>()if (x) a else b
|
||||
}
|
||||
|
||||
// ELEMENT: emptyList
|
||||
+6
@@ -137,6 +137,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT12328.kt")
|
||||
public void testKT12328() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/KT12328.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NestedTypeArg.kt")
|
||||
public void testNestedTypeArg() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/NestedTypeArg.kt");
|
||||
|
||||
Reference in New Issue
Block a user