@Override
  public Point getHintPosition(@NotNull LightweightHint hint, @NotNull Editor editor, @HintManager.PositionFlags short constraint) {
    EDT.assertIsEdt();
    LogicalPosition pos = editor.getCaretModel().getLogicalPosition();
    final DataContext dataContext = ((EditorEx)editor).getDataContext();
    final Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(dataContext);

    if (dominantArea != null) {
      return HintManagerImpl.getHintPositionRelativeTo(hint, editor, constraint, dominantArea, pos);
    }

    JRootPane rootPane = editor.getComponent().getRootPane();
    if (rootPane != null) {
      JLayeredPane lp = rootPane.getLayeredPane();
      for (HintManagerImpl.HintInfo info : myHintsStack) {
        if (!info.hint().isSelectingHint()) continue;
        IdeTooltip tooltip = info.hint().getCurrentIdeTooltip();
        if (tooltip != null) {
          Point p = tooltip.getShowingPoint().getPoint(lp);
          if (info.hint() != hint) {
            switch (constraint) {
              case HintManager.ABOVE -> {
                if (tooltip.getPreferredPosition() == Balloon.Position.below) {
                  p.y -= tooltip.getPositionChangeY();
                }
              }
              case HintManager.UNDER, HintManager.RIGHT_UNDER -> {
                if (tooltip.getPreferredPosition() == Balloon.Position.above) {
                  p.y += tooltip.getPositionChangeY();
                }
              }
              case HintManager.RIGHT -> {
                if (tooltip.getPreferredPosition() == Balloon.Position.atLeft) {
                  p.x += tooltip.getPositionChangeX();
                }
              }
              case HintManager.LEFT -> {
                if (tooltip.getPreferredPosition() == Balloon.Position.atRight) {
                  p.x -= tooltip.getPositionChangeX();
                }
              }
            }
          }
          return p;
        }

        Rectangle rectangle = info.hint().getBounds();
        JComponent c = info.hint().getComponent();
        rectangle = SwingUtilities.convertRectangle(c.getParent(), rectangle, lp);

        return HintManagerImpl.getHintPositionRelativeTo(hint, editor, constraint, rectangle, pos);
      }
    }

    return HintManagerImpl.getHintPosition(hint, editor, pos, constraint);
  }
@Override
  public Point getHintPosition(@NotNull LightweightHint hint, @NotNull Editor editor, @HintManager.PositionFlags short constraint)