From e2ae7812d3956f6dd4b5a9ffc81007b8aab552bd Mon Sep 17 00:00:00 2001 From: weisj <31143295+weisJ@users.noreply.github.com> Date: Tue, 17 Aug 2021 11:16:52 +0200 Subject: [PATCH] Compatibility: Fix errorprone warnings --- .../darklaf/compatibility/SwingUtil.java | 6 ++- .../util/ui/MenuItemLayoutHelper.java | 37 ++++++++++++++++++- .../util/ui/StringUIClientPropertyKey.java | 1 + .../com/intellij/util/ui/UIUtilities.java | 2 + 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java b/compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java index 0c4af541..ab4c9116 100644 --- a/compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java +++ b/compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java @@ -103,7 +103,8 @@ public final class SwingUtil { if (swingInteropAvailable) { try { grabMethod.get().invokeExact(toolkit, window); - } catch (Throwable ignored) { + } catch (Throwable e) { + throw new RuntimeException(e); } } else { if (toolkit instanceof sun.awt.SunToolkit) { @@ -116,7 +117,8 @@ public final class SwingUtil { if (swingInteropAvailable) { try { ungrabMethod.get().invokeExact(toolkit, window); - } catch (Throwable ignored) { + } catch (Throwable e) { + throw new RuntimeException(e); } } else { if (toolkit instanceof sun.awt.SunToolkit) { diff --git a/compatibility/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java b/compatibility/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java index a5dfcbed..6d5ef1a0 100644 --- a/compatibility/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java +++ b/compatibility/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java @@ -373,6 +373,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil } } + @Override public LayoutResult layoutMenuItem() { LayoutResult lr = this.createLayoutResult(); this.prepareForLayout(lr); @@ -631,7 +632,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil public static JComponent getMenuItemParent(JMenuItem menuItem) { Container parent = menuItem.getParent(); - return !(parent instanceof JComponent) || menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu() + return !(parent instanceof JComponent) || (menuItem instanceof JMenu && ((JMenu) menuItem).isTopLevelMenu()) ? null : (JComponent) parent; } @@ -665,6 +666,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil return maxValue; } + @Override public JMenuItem getMenuItem() { return this.mi; } @@ -681,30 +683,37 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil return this.accFont; } + @Override public FontMetrics getFontMetrics() { return this.fm; } + @Override public FontMetrics getAccFontMetrics() { return this.accFm; } + @Override public Icon getIcon() { return this.icon; } + @Override public Icon getCheckIcon() { return this.checkIcon; } + @Override public Icon getArrowIcon() { return this.arrowIcon; } + @Override public String getText() { return this.text; } + @Override public String getAccText() { return this.accText; } @@ -713,6 +722,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil return this.isColumnLayout; } + @Override public boolean useCheckAndArrow() { return this.useCheckAndArrow; } @@ -721,10 +731,12 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil return this.isLeftToRight; } + @Override public boolean isTopLevelMenu() { return this.isTopLevelMenu; } + @Override public View getHtmlView() { return this.htmlView; } @@ -745,46 +757,57 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil return this.horizontalTextPosition; } + @Override public int getGap() { return this.gap; } + @Override public int getLeadingGap() { return this.leadingGap; } + @Override public int getAfterCheckIconGap() { return this.afterCheckIconGap; } + @Override public int getMinTextOffset() { return this.minTextOffset; } + @Override public Rectangle getViewRect() { return this.viewRect; } + @Override public RectSize getIconSize() { return this.iconSize; } + @Override public RectSize getTextSize() { return this.textSize; } + @Override public RectSize getAccSize() { return this.accSize; } + @Override public RectSize getCheckSize() { return this.checkSize; } + @Override public RectSize getArrowSize() { return this.arrowSize; } + @Override public RectSize getLabelSize() { return this.labelSize; } @@ -936,26 +959,32 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.maxWidth = maxWidth; } + @Override public int getWidth() { return this.width; } + @Override public int getHeight() { return this.height; } + @Override public int getOrigWidth() { return this.origWidth; } + @Override public int getMaxWidth() { return this.maxWidth; } + @Override public void setWidth(int width) { this.width = width; } + @Override public void setHeight(int height) { this.height = height; } @@ -968,6 +997,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.maxWidth = maxWidth; } + @Override public String toString() { return "[w=" + this.width + ",h=" + this.height + ",ow=" + this.origWidth + ",mw=" + this.maxWidth + "]"; } @@ -1039,6 +1069,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.labelRect = labelRect; } + @Override public Rectangle getIconRect() { return this.iconRect; } @@ -1047,6 +1078,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.iconRect = iconRect; } + @Override public Rectangle getTextRect() { return this.textRect; } @@ -1055,6 +1087,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.textRect = textRect; } + @Override public Rectangle getAccRect() { return this.accRect; } @@ -1063,6 +1096,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.accRect = accRect; } + @Override public Rectangle getCheckRect() { return this.checkRect; } @@ -1071,6 +1105,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil this.checkRect = checkRect; } + @Override public Rectangle getArrowRect() { return this.arrowRect; } diff --git a/compatibility/src/main/java/com/intellij/util/ui/StringUIClientPropertyKey.java b/compatibility/src/main/java/com/intellij/util/ui/StringUIClientPropertyKey.java index d4f4455d..5a90997b 100644 --- a/compatibility/src/main/java/com/intellij/util/ui/StringUIClientPropertyKey.java +++ b/compatibility/src/main/java/com/intellij/util/ui/StringUIClientPropertyKey.java @@ -34,6 +34,7 @@ public class StringUIClientPropertyKey implements UIClientPropertyKey { this.key = key; } + @Override public String toString() { return this.key; } diff --git a/compatibility/src/main/java/com/intellij/util/ui/UIUtilities.java b/compatibility/src/main/java/com/intellij/util/ui/UIUtilities.java index 7a7b94c2..72e9561a 100644 --- a/compatibility/src/main/java/com/intellij/util/ui/UIUtilities.java +++ b/compatibility/src/main/java/com/intellij/util/ui/UIUtilities.java @@ -445,6 +445,7 @@ public class UIUtilities { return lsb; } + @Override public boolean equals(Object entry) { if (entry == this) { return true; @@ -456,6 +457,7 @@ public class UIUtilities { } } + @Override public int hashCode() { int result = 17; if (this.font != null) {