void (TemplateState state, final List<? extends TemplateExpressionLookupElement> lookupItems, Project project, Editor editor, @Nullable @NlsContexts.PopupAdvertisement String advertisingText, @NotNull LookupFocusDegree lookupFocusDegree) { if (state.isDisposed()) return; final LookupManager lookupManager = LookupManager.getInstance(project); final LookupImpl lookup = (LookupImpl)lookupManager.showLookup(editor, lookupItems.toArray(LookupElement.EMPTY_ARRAY)); if (lookup == null) return; if (CodeInsightSettings.getInstance().AUTO_POPUP_COMPLETION_LOOKUP && editor.getUserData(InplaceRefactoring.INPLACE_RENAMER) == null) { lookup.setStartCompletionWhenNothingMatches(true); } if (advertisingText != null) { lookup.addAdvertisement(advertisingText, null); } else { ActionManager am = ActionManager.getInstance(); String enterShortcut = KeymapUtil.getFirstKeyboardShortcutText(am.getAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM)); String tabShortcut = KeymapUtil.getFirstKeyboardShortcutText(am.getAction(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE)); lookup.addAdvertisement(LangBundle.message("popup.advertisement.press.or.to.replace", enterShortcut, tabShortcut), null); } lookup.setLookupFocusDegree(lookupFocusDegree); lookup.refreshUi(true, true); myLookupShown = true; lookup.addLookupListener(new LookupListener() { @Override public void lookupCanceled(@NotNull LookupEvent event) { lookup.removeLookupListener(this); myLookupShown = false; } @Override public void itemSelected(@NotNull LookupEvent event) { lookup.removeLookupListener(this); if (state.isFinished()) return; myLookupShown = false; LookupElement item = event.getItem(); if (item instanceof TemplateExpressionLookupElement) { ((TemplateExpressionLookupElement)item).handleTemplateInsert(lookupItems, event.getCompletionChar()); } } }); }