void (@NotNull Project project, @NotNull Editor editor) { // Unfortunately, LookupManager.showLookup() doesn't invoke InsertHandler. A workaround with LookupListener is used. // To let the workaround work we need to make sure that noting is actually replaced by the default behavior of showLookup(). editor.getSelectionModel().removeSelection(); final List<LookupElement> items = createLookupElements(); final LookupManager lookupManager = LookupManager.getInstance(project); final LookupEx lookup = lookupManager.showLookup(editor, items.toArray(LookupElement.EMPTY_ARRAY)); if (lookup != null) { lookup.addLookupListener(new LookupListener() { @Override public void itemSelected(@NotNull LookupEvent event) { final LookupElement item = event.getItem(); if (item != null) { final PsiElement element = getStartElement(); final Object object = item.getObject(); if (element != null && object instanceof ReflectiveSignature) { WriteAction.run(() -> applyFix(project, element, (ReflectiveSignature)object)); } } } }); } }