private static void setPopupSize(@NotNull JTable table,
                                   @NotNull AbstractPopup popup,
                                   @NotNull RelativePoint popupPosition,
                                   @NotNull IntRef minWidth,
                                   boolean showCodePreview,
                                   int dataSize) {

    if (isCodeWithMeClientInstance(popup)) return;

    Component toolbarComponent = ((BorderLayout)popup.getComponent().getLayout()).getLayoutComponent(BorderLayout.NORTH);
    Dimension toolbarSize = toolbarComponent != null ? toolbarComponent.getPreferredSize() : JBUI.emptySize();
    Dimension headerSize = popup.getHeaderPreferredSize();

    int width = calcMaxWidth(table);
    width = Math.max(headerSize.width, width);
    width = Math.max(toolbarSize.width, width);
    width = Math.max(minWidth.get(), width);

    minWidth.set(width);

    int minHeight = headerSize.height + toolbarSize.height;

    Rectangle rectangle = getPreferredBounds(table, popupPosition.getScreenPoint(), width, minHeight, dataSize, showCodePreview);
    table.setSize(rectangle.width, rectangle.height - minHeight);
    if (dataSize > 0) ScrollingUtil.ensureSelectionExists(table);

    JBSplitter splitter = popup.getUserData(JBSplitter.class);

    if (splitter != null) {
      rectangle.height += splitter.getDividerWidth() + splitter.getSecondComponent().getMinimumSize().height;
    }

    popup.setSize(rectangle.getSize());
    popup.moveToFitScreen();
  }
private static void setPopupSize(@NotNull JTable table,
                                   @NotNull AbstractPopup popup,
                                   @NotNull RelativePoint popupPosition,
                                   @NotNull IntRef minWidth,
                                   boolean showCodePreview,
                                   int dataSize)