Completion: added package name for global functions/properties in the list

This commit is contained in:
Valentin Kipyatkov
2014-12-01 20:57:45 +03:00
parent 7c67566719
commit 72ff719001
4 changed files with 13 additions and 6 deletions
@@ -140,7 +140,7 @@ public class LookupElementFactory(
}
private fun createLookupElement(
analyzer: ResolutionFacade,
resolutionFacade: ResolutionFacade,
descriptor: DeclarationDescriptor,
declaration: PsiElement?
): LookupElement {
@@ -155,7 +155,7 @@ public class LookupElementFactory(
}
var element = LookupElementBuilder.create(DeclarationDescriptorLookupObject(descriptor, analyzer, declaration), descriptor.getName().asString())
var element = LookupElementBuilder.create(DeclarationDescriptorLookupObject(descriptor, resolutionFacade, declaration), descriptor.getName().asString())
.withIcon(JetDescriptorIconProvider.getIcon(descriptor, declaration, Iconable.ICON_FLAG_VISIBILITY))
when (descriptor) {
@@ -194,6 +194,13 @@ public class LookupElementFactory(
val receiverPresentation = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(receiver.getType())
element = element.appendTailText(" for $receiverPresentation in $containerPresentation", true)
}
else {
val container = descriptor.getContainingDeclaration()
if (container is PackageFragmentDescriptor) { // we show container only for global functions and properties
//TODO: it would be probably better to show it also for static declarations which are not from the current class (imported)
element = element.appendTailText(" (${container.fqName})", true)
}
}
}
if (KotlinBuiltIns.isDeprecated(descriptor)) {
@@ -4,4 +4,4 @@ fun some() {
tes<caret>
}
// EXIST: { lookupString:"test", itemText:"test", tailText:"(a: Int)" }
// EXIST: { lookupString:"test", itemText:"test", tailText:"(a: Int) (<root>)" }
@@ -4,5 +4,5 @@ fun test() {
fo<caret>
}
// EXIST: { lookupString:"foo", itemText: "foo", tailText: "(p: (String, Char) -> Unit)", typeText:"Unit" }
// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { (String, Char) -> ... }", typeText:"Unit" }
// EXIST: { lookupString:"foo", itemText: "foo", tailText: "(p: (String, Char) -> Unit) (<root>)", typeText:"Unit" }
// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { (String, Char) -> ... } (<root>)", typeText:"Unit" }
@@ -1,3 +1,3 @@
var a : Runnable = <caret>
// EXIST: {"lookupString":"Runnable", "itemText":"Runnable", "tailText":"(function: () -> Unit)", "typeText":"Runnable"}
// EXIST: {"lookupString":"Runnable", "itemText":"Runnable", "tailText":"(function: () -> Unit) (java.lang)", "typeText":"Runnable"}