void (@NotNull PsiElement element, boolean requestFocus, PopupUpdateProcessor updateProcessor, PsiElement originalElement, @Nullable Runnable closeCallback, @Nullable ActionCallback actionCallback, boolean useStoredPopupSize) { Component focusedComponent = WindowManagerEx.getInstanceEx().getFocusedComponent(myProject); myFocusedBeforePopup = new WeakReference<>(focusedComponent); DocumentationComponent component = myTestDocumentationComponent == null ? new DocumentationComponent(this, useStoredPopupSize) : myTestDocumentationComponent; ActionListener actionListener = __ -> { createToolWindow(element, originalElement); JBPopup hint = getDocInfoHint(); if (hint != null && hint.isVisible()) hint.cancel(); }; List<Pair<ActionListener, KeyStroke>> actions = new SmartList<>(); AnAction quickDocAction = ActionManager.getInstance().getAction(IdeActions.ACTION_QUICK_JAVADOC); for (Shortcut shortcut : quickDocAction.getShortcutSet().getShortcuts()) { if (!(shortcut instanceof KeyboardShortcut)) continue; actions.add(Pair.create(actionListener, ((KeyboardShortcut)shortcut).getFirstKeyStroke())); } boolean hasLookup = LookupManager.getActiveLookup(myEditor) != null; AbstractPopup hint = (AbstractPopup)JBPopupFactory .getInstance().createComponentPopupBuilder(component, component) .setProject(myProject) .addListener(updateProcessor) .addUserData(updateProcessor) .addUserData(ClientId.getCurrent()) .setKeyboardActions(actions) .setResizable(true) .setMovable(true) .setFocusable(true) .setRequestFocus(requestFocus) .setCancelOnClickOutside(!hasLookup) // otherwise, selecting lookup items by mouse would close the doc .setModalContext(false) .setCancelCallback(() -> { if (MenuSelectionManager.defaultManager().getSelectedPath().length > 0) { return false; } myCloseOnSneeze = false; if (closeCallback != null) { closeCallback.run(); } findQuickSearchComponent().ifPresent(QuickSearchComponent::unregisterHint); Disposer.dispose(component); myEditor = null; return Boolean.TRUE; }) .setKeyEventHandler(e -> { if (myCloseOnSneeze) { closeDocHint(); } if (AbstractPopup.isCloseRequest(e) && getDocInfoHint() != null) { closeDocHint(); return true; } return false; }) .createPopup(); component.setHint(hint); component.setToolwindowCallback(() -> { createToolWindow(element, originalElement); myToolWindow.setAutoHide(false); hint.cancel(); }); if (useStoredPopupSize && DimensionService.getInstance().getSize(NEW_JAVADOC_LOCATION_AND_SIZE, myProject) != null) { hint.setDimensionServiceKey(NEW_JAVADOC_LOCATION_AND_SIZE); } if (myEditor == null) { // subsequent invocation of javadoc popup from completion will have myEditor == null because of cancel invoked, // so reevaluate the editor for proper popup placement Lookup lookup = LookupManager.getInstance(myProject).getActiveLookup(); myEditor = lookup != null ? lookup.getEditor() : null; } cancelAndFetchDocInfo(component, new MyCollector(myProject, element, originalElement, null, actionCallback, false, false)); myDocInfoHintRef = new WeakReference<>(hint); findQuickSearchComponent().ifPresent(quickSearch -> quickSearch.registerHint(hint)); IdeEventQueue.getInstance().addDispatcher(e -> { if (e.getID() == MouseEvent.MOUSE_PRESSED && e.getSource() == hint.getPopupWindow()) { myCloseOnSneeze = false; } return false; }, component); }