Update LookupElements after passing to CompletionResultSet?

I'd like to move towards making my completions more responsive by passing elements to the CompletionResultSet as I generate them, rather than batching them up and sending them all at once, getVariants style. There's one case which makes this tricky - in some cases I iterate a lot of indexes generating the lookups, and I have to collate them somewhat to produce a tail text which says " in <location>, <location>...". Concretely, this is for lookup elements corresponding to methods - the lookup text is the name of the method and the args, but I'd like the tail text to show all locations that a method with that signature was found in. However this basically means that that cannot be asynchronous, it has to wait until all methods have been iterated before I can add that lookup to the result set.

Is it possible to hold on to the LookupElements for these methods after I pass them to the CompletionResultSet and update the tail text later? Would that then be updated in the UI? If not, is there any other way to achieve this?

4 comments
Comment actions Permalink
Official comment

The tail text should be there when "renderElement' is called, so it's not necessary to calculate it in contributor. Rendering happens twice: when the item is added (to determine the resulting lookup width) and when the item is actually displayed. If you'd like the first situation to be as fast as possible, you can use LookupElementPresentation#isReal to distinguish it from real rendering, and provide some dummy text (of roughly the same length) instead.

Comment actions Permalink

Thanks, Peter. Once the element has been displayed and the second renderElement called, there's no further way to update that text, correct? Say, if I'm still reading from indices in the background?

0
Comment actions Permalink

Rendering method might be called again on selection change or another repaint, but I wouldn't rely on such implemention details. I believe that once an item is displayed, it'd better not change its appearance anyway, because this would produce distracting/annoying/confusing changes on the screen.

1
Comment actions Permalink

Ok, thanks. I think I might just avoid adding that tail text altogether then.

0

Please sign in to leave a comment.