static Point getHintPositionRelativeTo(final @NotNull LightweightHint hint,
                                         final @NotNull Editor editor,
                                         @PositionFlags short constraint,
                                         final @NotNull Rectangle lookupBounds,
                                         final LogicalPosition pos) {

    JComponent externalComponent = getExternalComponent(editor);

    IdeTooltip ideTooltip = hint.getCurrentIdeTooltip();
    if (ideTooltip != null) {
      Point point = ideTooltip.getPoint();
      return SwingUtilities.convertPoint(ideTooltip.getComponent(), point, externalComponent);
    }

    Dimension hintSize = hint.getComponent().getPreferredSize();
    int layeredPaneHeight = externalComponent.getHeight();

    switch (constraint) {
      case LEFT -> {
        int y = lookupBounds.y;
        if (y < 0) {
          y = 0;
        }
        else if (y + hintSize.height >= layeredPaneHeight) {
          y = layeredPaneHeight - hintSize.height;
        }
        return new Point(lookupBounds.x - hintSize.width, y);
      }
      case RIGHT -> {
        int y = lookupBounds.y;
        if (y < 0) {
          y = 0;
        }
        else if (y + hintSize.height >= layeredPaneHeight) {
          y = layeredPaneHeight - hintSize.height;
        }
        return new Point(lookupBounds.x + lookupBounds.width, y);
      }
      case ABOVE -> {
        Point posAboveCaret = getHintPosition(hint, editor, pos, ABOVE);
        return new Point(lookupBounds.x, Math.min(posAboveCaret.y, lookupBounds.y - hintSize.height));
      }
      case UNDER -> {
        Point posUnderCaret = getHintPosition(hint, editor, pos, UNDER);
        return new Point(lookupBounds.x, Math.max(posUnderCaret.y, lookupBounds.y + lookupBounds.height));
      }
      default -> {
        LOG.error("");
        return null;
      }
    }
  }
static Point getHintPositionRelativeTo(final @NotNull LightweightHint hint,
                                         final @NotNull Editor editor,
                                         @PositionFlags short constraint,
                                         final @NotNull Rectangle lookupBounds,
                                         final LogicalPosition pos)