Better presentation of aliases in completion list

This commit is contained in:
Valentin Kipyatkov
2016-09-07 16:46:46 +03:00
parent 50a0f9a4a7
commit e41ab2a270
4 changed files with 10 additions and 6 deletions
@@ -169,7 +169,7 @@ class BasicLookupElementFactory(
element = element.withTypeText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(descriptor.type), parametersAndTypeGrayed)
}
is ClassDescriptor -> {
is ClassifierDescriptorWithTypeParameters -> {
val typeParams = descriptor.declaredTypeParameters
if (includeClassTypeArguments && typeParams.isNotEmpty()) {
element = element.appendTailText(typeParams.map { it.name.asString() }.joinToString(", ", "<", ">"), true)
@@ -192,6 +192,10 @@ class BasicLookupElementFactory(
if (container is PackageFragmentDescriptor || container is ClassDescriptor) {
element = element.appendTailText(" (" + DescriptorUtils.getFqName(container) + ")", true)
}
if (descriptor is TypeAliasDescriptor) {
element = element.withTypeText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(descriptor.underlyingType), false)
}
}
else -> {
@@ -3,5 +3,5 @@ fun some(e: IllegalArgumentException<caret>) {
// INVOCATION_COUNT: 2
// WITH_ORDER
// EXIST: { lookupString:"IllegalArgumentException", typeText:"public typealias IllegalArgumentException = IllegalArgumentException defined in kotlin" }
// EXIST: { lookupString:"IllegalArgumentException", tailText: " (kotlin)", typeText:"IllegalArgumentException" }
// EXIST: { lookupString:"IllegalArgumentException", tailText:" (java.lang)" }
@@ -2,4 +2,4 @@ package test2
fun foo(ali<caret>)
// EXIST: { lookupString: "alias : MyAlias", itemText: "alias: MyAlias", typeText: "public typealias MyAlias = MyClass defined in test", attributes: "" }
// EXIST: { lookupString: "alias : MyAlias", itemText: "alias: MyAlias", tailText: " (test)", typeText: "MyClass", attributes: "" }
@@ -5,6 +5,6 @@ private typealias MyPrivateAlias = (String, Char) -> Unit
val test: My<caret>
// EXIST: { lookupString: "MySameFileAlias", itemText: "MySameFileAlias", tailText: null, typeText: "public typealias MySameFileAlias = (String) -> Int defined in test", attributes: "" }
// EXIST: { lookupString: "MyPrivateAlias", itemText: "MyPrivateAlias", tailText: null, typeText: "private typealias MyPrivateAlias = (String, Char) -> Unit defined in test", attributes: "" }
// EXIST: { lookupString: "MyAlias", itemText: "MyAlias", tailText: null, typeText: "public typealias MyAlias = MyClass defined in dependency", attributes: "" }
// EXIST: { lookupString: "MySameFileAlias", itemText: "MySameFileAlias", tailText: " (test)", typeText: "(String) -> Int", attributes: "" }
// EXIST: { lookupString: "MyPrivateAlias", itemText: "MyPrivateAlias", tailText: " (test)", typeText: "(String, Char) -> Unit", attributes: "" }
// EXIST: { lookupString: "MyAlias", itemText: "MyAlias", tailText: " (dependency)", typeText: "MyClass", attributes: "" }