RelativePoint (@NotNull Editor editor) { if (editor instanceof EditorEx) { DataContext context = ((EditorEx)editor).getDataContext(); PopupLocator popupLocator = PlatformDataKeys.CONTEXT_MENU_LOCATOR.getData(context); if (popupLocator != null) { Point result = popupLocator.getPositionFor(this); if (result != null) return new RelativePoint(result); } Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(context); if (dominantArea != null && !myRequestFocus) { final JLayeredPane layeredPane = editor.getContentComponent().getRootPane().getLayeredPane(); return relativePointWithDominantRectangle(layeredPane, dominantArea); } } return guessBestPopupLocation(editor); }