LightweightHint (@NotNull Editor editor, @NotNull JComponent component, boolean tenacious) { if (editor.isDisposed()) return null; FoldRegion foldRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(editor.getCaretModel().getOffset()); if (foldRegion == null) return null; JComponent editorComponent = editor.getContentComponent(); JRootPane rootPane = editorComponent.getRootPane(); if (rootPane == null) return null; Point start = editor.offsetToXY(foldRegion.getStartOffset(), true, false); Point end = editor.offsetToXY(foldRegion.getEndOffset(), false, true); Point relativePoint = new Point((start.x + end.x) / 2, start.y); Point point = SwingUtilities.convertPoint(editorComponent, relativePoint, rootPane.getLayeredPane()); LightweightHint hint = new LightweightHint(component); HintHint hintHint = HintManagerImpl.createHintHint(editor, point, hint, ABOVE).setShowImmediately(true).setStatus(HintHint.Status.Info); int flags = HIDE_BY_TEXT_CHANGE | HIDE_BY_SCROLLING; if (tenacious) { hintHint.setExplicitClose(true); } else { flags |= HIDE_BY_ANY_KEY; } FoldingPopupManager.disableForEditor(editor); hint.addHintListener(e -> FoldingPopupManager.enableForEditor(editor)); HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, point, flags, 0, false, hintHint); return hint; }