Method completion with multiple icons

Answered

I'm adding a method completion lookup element with a custom icon. My icon is comprised of two icons, side by side, like the method icon and visiblity icon.

It looks like this:

I'm using the following code to achieve that:

final RowIcon boundCompletionIcon = ElementPresentationUtil.createLayeredIcon(icon, psiMethod, false);
boundCompletionIcon.setIcon(Icons.BOUND_COMPLETION, 1);

This worked fine until version 2019.2. Looks like the visibility icons don't appear any more for method completions (so my second icon doesn't have enough space?). Is this controlled by some user settings like the project's "show visibility icons"?

Also, looks like 

ElementPresentationUtil.createLayeredIcon

is now deprecated.

What's the correct way to achieve this (preferably one that will work for both 2019.2 and previous versions)?

Thanks

Shai

 

0
6 comments

> preferably one that will work for both 2019.2 and previous versions

 

In this case, no variants, new API is not available in old versions.

0

Please see Registry key "ide.completion.show.visibility.icon" to enable visibility icons in completion popup (default is OFF).

0

Hi Vladimir.

I'm Sorry, but I did not understand your answer.

What is the new API and what are the old versions?

Are you saying there's no way to do this in 2019.2? I don't mind having two implementations, one for 2019.2 and up and one for previous versions (i.e. my current implementation unless you think there's a better way).

0

New API: `IconManager.getInstance().createLayeredIcon()`

 

You are not forced to to have different version of plugin — you can continue using old API and migrate in next release (2019.3)

0

I see. That answers the deprecation part.

But can I still have the effect I want even if "ide.completion.show.visibility.icon" is disabled (@Yann, thanks for this)?

0

Correct, the default has changed in 2019.2 to suppress showing visibility icons in completion.

0

Please sign in to leave a comment.