Browse Source

Compatibility: Fix errorprone warnings

pull/270/head
weisj 3 years ago
parent
commit
e2ae7812d3
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 6
      compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java
  2. 37
      compatibility/src/main/java/com/intellij/util/ui/MenuItemLayoutHelper.java
  3. 1
      compatibility/src/main/java/com/intellij/util/ui/StringUIClientPropertyKey.java
  4. 2
      compatibility/src/main/java/com/intellij/util/ui/UIUtilities.java

6
compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java

@ -103,7 +103,8 @@ public final class SwingUtil {
if (swingInteropAvailable) { if (swingInteropAvailable) {
try { try {
grabMethod.get().invokeExact(toolkit, window); grabMethod.get().invokeExact(toolkit, window);
} catch (Throwable ignored) { } catch (Throwable e) {
throw new RuntimeException(e);
} }
} else { } else {
if (toolkit instanceof sun.awt.SunToolkit) { if (toolkit instanceof sun.awt.SunToolkit) {
@ -116,7 +117,8 @@ public final class SwingUtil {
if (swingInteropAvailable) { if (swingInteropAvailable) {
try { try {
ungrabMethod.get().invokeExact(toolkit, window); ungrabMethod.get().invokeExact(toolkit, window);
} catch (Throwable ignored) { } catch (Throwable e) {
throw new RuntimeException(e);
} }
} else { } else {
if (toolkit instanceof sun.awt.SunToolkit) { if (toolkit instanceof sun.awt.SunToolkit) {

37
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() { public LayoutResult layoutMenuItem() {
LayoutResult lr = this.createLayoutResult(); LayoutResult lr = this.createLayoutResult();
this.prepareForLayout(lr); this.prepareForLayout(lr);
@ -631,7 +632,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
public static JComponent getMenuItemParent(JMenuItem menuItem) { public static JComponent getMenuItemParent(JMenuItem menuItem) {
Container parent = menuItem.getParent(); 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 ? null
: (JComponent) parent; : (JComponent) parent;
} }
@ -665,6 +666,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
return maxValue; return maxValue;
} }
@Override
public JMenuItem getMenuItem() { public JMenuItem getMenuItem() {
return this.mi; return this.mi;
} }
@ -681,30 +683,37 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
return this.accFont; return this.accFont;
} }
@Override
public FontMetrics getFontMetrics() { public FontMetrics getFontMetrics() {
return this.fm; return this.fm;
} }
@Override
public FontMetrics getAccFontMetrics() { public FontMetrics getAccFontMetrics() {
return this.accFm; return this.accFm;
} }
@Override
public Icon getIcon() { public Icon getIcon() {
return this.icon; return this.icon;
} }
@Override
public Icon getCheckIcon() { public Icon getCheckIcon() {
return this.checkIcon; return this.checkIcon;
} }
@Override
public Icon getArrowIcon() { public Icon getArrowIcon() {
return this.arrowIcon; return this.arrowIcon;
} }
@Override
public String getText() { public String getText() {
return this.text; return this.text;
} }
@Override
public String getAccText() { public String getAccText() {
return this.accText; return this.accText;
} }
@ -713,6 +722,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
return this.isColumnLayout; return this.isColumnLayout;
} }
@Override
public boolean useCheckAndArrow() { public boolean useCheckAndArrow() {
return this.useCheckAndArrow; return this.useCheckAndArrow;
} }
@ -721,10 +731,12 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
return this.isLeftToRight; return this.isLeftToRight;
} }
@Override
public boolean isTopLevelMenu() { public boolean isTopLevelMenu() {
return this.isTopLevelMenu; return this.isTopLevelMenu;
} }
@Override
public View getHtmlView() { public View getHtmlView() {
return this.htmlView; return this.htmlView;
} }
@ -745,46 +757,57 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
return this.horizontalTextPosition; return this.horizontalTextPosition;
} }
@Override
public int getGap() { public int getGap() {
return this.gap; return this.gap;
} }
@Override
public int getLeadingGap() { public int getLeadingGap() {
return this.leadingGap; return this.leadingGap;
} }
@Override
public int getAfterCheckIconGap() { public int getAfterCheckIconGap() {
return this.afterCheckIconGap; return this.afterCheckIconGap;
} }
@Override
public int getMinTextOffset() { public int getMinTextOffset() {
return this.minTextOffset; return this.minTextOffset;
} }
@Override
public Rectangle getViewRect() { public Rectangle getViewRect() {
return this.viewRect; return this.viewRect;
} }
@Override
public RectSize getIconSize() { public RectSize getIconSize() {
return this.iconSize; return this.iconSize;
} }
@Override
public RectSize getTextSize() { public RectSize getTextSize() {
return this.textSize; return this.textSize;
} }
@Override
public RectSize getAccSize() { public RectSize getAccSize() {
return this.accSize; return this.accSize;
} }
@Override
public RectSize getCheckSize() { public RectSize getCheckSize() {
return this.checkSize; return this.checkSize;
} }
@Override
public RectSize getArrowSize() { public RectSize getArrowSize() {
return this.arrowSize; return this.arrowSize;
} }
@Override
public RectSize getLabelSize() { public RectSize getLabelSize() {
return this.labelSize; return this.labelSize;
} }
@ -936,26 +959,32 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
this.maxWidth = maxWidth; this.maxWidth = maxWidth;
} }
@Override
public int getWidth() { public int getWidth() {
return this.width; return this.width;
} }
@Override
public int getHeight() { public int getHeight() {
return this.height; return this.height;
} }
@Override
public int getOrigWidth() { public int getOrigWidth() {
return this.origWidth; return this.origWidth;
} }
@Override
public int getMaxWidth() { public int getMaxWidth() {
return this.maxWidth; return this.maxWidth;
} }
@Override
public void setWidth(int width) { public void setWidth(int width) {
this.width = width; this.width = width;
} }
@Override
public void setHeight(int height) { public void setHeight(int height) {
this.height = height; this.height = height;
} }
@ -968,6 +997,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
this.maxWidth = maxWidth; this.maxWidth = maxWidth;
} }
@Override
public String toString() { public String toString() {
return "[w=" + this.width + ",h=" + this.height + ",ow=" + this.origWidth + ",mw=" + this.maxWidth + "]"; 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; this.labelRect = labelRect;
} }
@Override
public Rectangle getIconRect() { public Rectangle getIconRect() {
return this.iconRect; return this.iconRect;
} }
@ -1047,6 +1078,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
this.iconRect = iconRect; this.iconRect = iconRect;
} }
@Override
public Rectangle getTextRect() { public Rectangle getTextRect() {
return this.textRect; return this.textRect;
} }
@ -1055,6 +1087,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
this.textRect = textRect; this.textRect = textRect;
} }
@Override
public Rectangle getAccRect() { public Rectangle getAccRect() {
return this.accRect; return this.accRect;
} }
@ -1063,6 +1096,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
this.accRect = accRect; this.accRect = accRect;
} }
@Override
public Rectangle getCheckRect() { public Rectangle getCheckRect() {
return this.checkRect; return this.checkRect;
} }
@ -1071,6 +1105,7 @@ public class MenuItemLayoutHelper implements com.github.weisj.darklaf.compatibil
this.checkRect = checkRect; this.checkRect = checkRect;
} }
@Override
public Rectangle getArrowRect() { public Rectangle getArrowRect() {
return this.arrowRect; return this.arrowRect;
} }

1
compatibility/src/main/java/com/intellij/util/ui/StringUIClientPropertyKey.java

@ -34,6 +34,7 @@ public class StringUIClientPropertyKey implements UIClientPropertyKey {
this.key = key; this.key = key;
} }
@Override
public String toString() { public String toString() {
return this.key; return this.key;
} }

2
compatibility/src/main/java/com/intellij/util/ui/UIUtilities.java

@ -445,6 +445,7 @@ public class UIUtilities {
return lsb; return lsb;
} }
@Override
public boolean equals(Object entry) { public boolean equals(Object entry) {
if (entry == this) { if (entry == this) {
return true; return true;
@ -456,6 +457,7 @@ public class UIUtilities {
} }
} }
@Override
public int hashCode() { public int hashCode() {
int result = 17; int result = 17;
if (this.font != null) { if (this.font != null) {

Loading…
Cancel
Save