Fixed parameter name&type completion for type parameters
This commit is contained in:
+2
-2
@@ -125,7 +125,7 @@ public class LookupElementFactory(
|
||||
override fun getIcon(flags: Int) = psiClass.getIcon(flags)
|
||||
}
|
||||
var element = LookupElementBuilder.create(lookupObject, psiClass.getName()!!)
|
||||
.withInsertHandler(KotlinClassInsertHandler)
|
||||
.withInsertHandler(KotlinClassifierInsertHandler)
|
||||
|
||||
val typeParams = psiClass.getTypeParameters()
|
||||
if (includeClassTypeArguments && typeParams.isNotEmpty()) {
|
||||
@@ -391,7 +391,7 @@ public class LookupElementFactory(
|
||||
|
||||
is PropertyDescriptor -> KotlinPropertyInsertHandler
|
||||
|
||||
is ClassDescriptor -> KotlinClassInsertHandler
|
||||
is ClassifierDescriptor -> KotlinClassifierInsertHandler
|
||||
|
||||
else -> BaseDeclarationInsertHandler()
|
||||
}
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.completion.isAfterDot
|
||||
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
|
||||
@@ -33,7 +34,7 @@ import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
object KotlinClassInsertHandler : BaseDeclarationInsertHandler() {
|
||||
object KotlinClassifierInsertHandler : BaseDeclarationInsertHandler() {
|
||||
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||
super.handleInsert(context, item)
|
||||
|
||||
@@ -86,7 +87,7 @@ object KotlinClassInsertHandler : BaseDeclarationInsertHandler() {
|
||||
private fun qualifiedNameToInsert(item: LookupElement): String {
|
||||
val lookupObject = item.getObject() as DeclarationLookupObject
|
||||
if (lookupObject.descriptor != null) {
|
||||
return IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(lookupObject.descriptor as ClassDescriptor)
|
||||
return IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(lookupObject.descriptor as ClassifierDescriptor)
|
||||
}
|
||||
else {
|
||||
val qualifiedName = (lookupObject.psiElement as PsiClass).getQualifiedName()!!
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun<T> foo(t<caret>)
|
||||
|
||||
// ELEMENT: t
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun<T> foo(t: T<caret>)
|
||||
|
||||
// ELEMENT: t
|
||||
+6
@@ -319,6 +319,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeParameter.kt")
|
||||
public void testTypeParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/parameterNameAndType/TypeParameter.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("UserPrefix.kt")
|
||||
public void testUserPrefix() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/parameterNameAndType/UserPrefix.kt");
|
||||
|
||||
Reference in New Issue
Block a user