From 2adcaef39c9f22bc9e0c3f3187355b41e0d45c84 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 25 Dec 2014 19:25:10 +0300 Subject: [PATCH] Completion: use class icon instead of method icon for instantiation --- .../plugin/completion/LookupElementFactory.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/completion/LookupElementFactory.kt b/idea/src/org/jetbrains/jet/plugin/completion/LookupElementFactory.kt index cc4cdce48ca..15ceed4d0d3 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/LookupElementFactory.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/LookupElementFactory.kt @@ -141,13 +141,22 @@ public class LookupElementFactory( return createLookupElementForJavaClass(declaration) } + // for constructor use name and icon of containing class + val nameAndIconDescriptor: DeclarationDescriptor + val iconDeclaration: PsiElement? + if (descriptor is ConstructorDescriptor) { + nameAndIconDescriptor = descriptor.getContainingDeclaration() + iconDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(nameAndIconDescriptor) + } + else { + nameAndIconDescriptor = descriptor + iconDeclaration = declaration + } + val name = nameAndIconDescriptor.getName().asString() + val icon = JetDescriptorIconProvider.getIcon(nameAndIconDescriptor, iconDeclaration, Iconable.ICON_FLAG_VISIBILITY) - val name = if (descriptor is ConstructorDescriptor) - descriptor.getContainingDeclaration().getName().asString() - else - descriptor.getName().asString() var element = LookupElementBuilder.create(DeclarationDescriptorLookupObject(descriptor, resolutionFacade, declaration), name) - .withIcon(JetDescriptorIconProvider.getIcon(descriptor, declaration, Iconable.ICON_FLAG_VISIBILITY)) + .withIcon(icon) when (descriptor) { is FunctionDescriptor -> {