From 66112d2ce48a3e067e188c8a6a4b53a1ad61c6e1 Mon Sep 17 00:00:00 2001 From: bobbylight Date: Sun, 28 Jul 2024 16:58:51 -0400 Subject: [PATCH] Removing some checks for pre-Java 6 since they're no longer needed, and fixed a few typos in Javadoc --- .../autocomplete/AutoCompleteDescWindow.java | 2 +- .../fife/ui/autocomplete/AutoCompletion.java | 4 +- .../autocomplete/CompletionProviderBase.java | 2 +- .../ui/autocomplete/ExternalURLHandler.java | 9 ++-- .../ui/autocomplete/FunctionCompletion.java | 2 +- .../LanguageAwareCompletionProvider.java | 2 +- .../fife/ui/autocomplete/LinkRedirector.java | 2 +- .../ParameterizedCompletionContext.java | 2 +- ...meterizedCompletionDescriptionToolTip.java | 2 +- .../RoundRobinAutoCompletion.java | 2 +- .../org/fife/ui/autocomplete/TipUtil.java | 4 +- .../java/org/fife/ui/autocomplete/Util.java | 54 +++++-------------- .../ui/autocomplete/VariableCompletion.java | 2 +- 13 files changed, 30 insertions(+), 59 deletions(-) diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompleteDescWindow.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompleteDescWindow.java index e500e31..2ce592a 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompleteDescWindow.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompleteDescWindow.java @@ -333,7 +333,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) { return; } - // Users can redirect URL's, perhaps to a local copy of documentation. + // Users can redirect URLs, perhaps to a local copy of documentation. URL url = e.getURL(); if (url!=null) { LinkRedirector redirector = AutoCompletion.getLinkRedirector(); diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java index ef89a60..6aeeb60 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/AutoCompletion.java @@ -103,7 +103,7 @@ public class AutoCompletion { private ExternalURLHandler externalURLHandler; /** - * An optional redirector that converts URL's to some other location before + * An optional redirector that converts URLs to some other location before * being handed over to externalURLHandler. */ private static LinkRedirector linkRedirector; @@ -1074,7 +1074,7 @@ protected void setHideOnNoText(boolean hideOnNoText) { /** - * Sets the redirector for external URL's found in code completion + * Sets the redirector for external URLs found in code completion * documentation. When a non-local link in completion popups is clicked, * this redirector is given the chance to modify the URL fetched and * displayed. diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/CompletionProviderBase.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/CompletionProviderBase.java index 248367b..a51f92e 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/CompletionProviderBase.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/CompletionProviderBase.java @@ -222,7 +222,7 @@ public void setParameterizedCompletionParams(char listStart, if (listEnd<0x20 || listEnd==0x7F) { throw new IllegalArgumentException("Invalid listEnd"); } - if (separator==null || separator.length()==0) { + if (separator==null || separator.isEmpty()) { throw new IllegalArgumentException("Invalid separator"); } paramListStart = listStart; diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/ExternalURLHandler.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/ExternalURLHandler.java index c009d7b..59132c4 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/ExternalURLHandler.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/ExternalURLHandler.java @@ -2,7 +2,7 @@ * 12/23/2008 * * ExternalURLHandler.java - Implementations can be registered as a callback - * to handle the user clicking on external URL's. + * to handle the user clicking on external URLs. * * This library is distributed under a modified BSD license. See the included * LICENSE.md file for details. @@ -14,11 +14,8 @@ /** * A callback for when an external URL is clicked in the description window. - * If no handler is installed, and if running in Java 6, the system default - * web browser is used to open the URL. If not running Java 6, nothing will - * happen. If you want browser support for pre-Java 6 JRE's, you will need - * to register one of these callbacks on your {@link AutoCompletion}, and - * open the URL in a web browser yourself.

+ * If no handler is installed, the system default web browser is used to open + * the URL.

* * Alternatively, folks implementing robust code completion support for a * language might install an ExternalURLHandler to handle diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java index ffa9d68..f6f9e06 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/FunctionCompletion.java @@ -200,7 +200,7 @@ public String getDefinitionString() { sb.append(type).append(' '); } - // Add the item being described's name. + // Add the name of the described item sb.append(getName()); // Add parameters for functions. diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java index 46d9e83..6bcb396 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java @@ -396,7 +396,7 @@ public String getToolTipText(RTextArea textArea, MouseEvent e) { String tip = null; List completions = getCompletionsAt(textArea, e.getPoint()); - if (completions!=null && completions.size()>0) { + if (completions!=null && !completions.isEmpty()) { // Only ever 1 match for us in C... Completion c = completions.get(0); tip = c.getToolTipText(); diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/LinkRedirector.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/LinkRedirector.java index bc65cbf..f23785a 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/LinkRedirector.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/LinkRedirector.java @@ -10,7 +10,7 @@ /** - * Possibly redirects one URL to another. Useful if you want "external" URL's + * Possibly redirects one URL to another. Useful if you want "external" URLs * in code completion documentation to point to a local copy instead, for * example. * diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java index f802da2..ad8c0ca 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionContext.java @@ -276,7 +276,7 @@ public void deactivate() { */ public String getArgumentText(int offs) { List paramHighlights = getParameterHighlights(); - if (paramHighlights==null || paramHighlights.size()==0) { + if (paramHighlights==null || paramHighlights.isEmpty()) { return null; } for (Highlight h : paramHighlights) { diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java index 6a49194..458a18e 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java @@ -77,7 +77,7 @@ class ParameterizedCompletionDescriptionToolTip { descLabel.setOpaque(true); descLabel.setBackground(TipUtil.getToolTipBackground()); // It appears that if a JLabel is set as a content pane directly, when - // using the JDK's opacity API's, it won't paint its background, even + // using the JDK's opacity APIs, it won't paint its background, even // if label.setOpaque(true) is called. You have to have a container // underneath it for it to paint its background. Thus, we embed our // label in a parent JPanel to handle this case. diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/RoundRobinAutoCompletion.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/RoundRobinAutoCompletion.java index 6e0bd87..dd81b0d 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/RoundRobinAutoCompletion.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/RoundRobinAutoCompletion.java @@ -137,7 +137,7 @@ public void actionPerformed(ActionEvent e) { // provider always first. for (int i=1; i completions = getCompletionProvider().getCompletions(getTextComponent()); - if (completions.size() > 0) { + if (!completions.isEmpty()) { //nothing to do, just let the current provider display break; } diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/TipUtil.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/TipUtil.java index 5ffa4a5..014b65f 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/TipUtil.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/TipUtil.java @@ -160,8 +160,8 @@ public static void tweakTipEditorPane(JEditorPane textArea) { textArea.getCaret().setSelectionVisible(true); // Set the foreground color. Important because when rendering HTML, - // default foreground becomes black, which may not match all LAF's - // (e.g. Substance). + // default foreground becomes black, which may not match all Look and + // Feels (e.g. Substance). Color fg = UIManager.getColor("ToolTip.foreground"); if (fg == null) { fg = UIManager.getColor("Label.foreground"); diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/Util.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/Util.java index 79ff2f7..5f533ad 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/Util.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/Util.java @@ -8,12 +8,7 @@ */ package org.fife.ui.autocomplete; -import java.awt.Color; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Rectangle; -import java.lang.reflect.Method; +import java.awt.*; import java.net.URI; import java.security.AccessControlException; import java.util.regex.Pattern; @@ -65,7 +60,7 @@ public final class Util { private static final boolean USE_SUBSTANCE_RENDERERS; private static boolean desktopCreationAttempted; - private static Object desktop; + private static Desktop desktop; private static final Object LOCK_DESKTOP_CREATION = new Object(); @@ -77,20 +72,17 @@ private Util() { * * @param uri The URI to open. If this is null, nothing * happens and this method returns false. - * @return Whether the operation was successful. This will be - * false on JRE's older than 1.6. + * @return Whether the operation was successful. */ public static boolean browse(URI uri) { boolean success = false; if (uri!=null) { - Object desktop = getDesktop(); + Desktop desktop = getDesktop(); if (desktop!=null) { try { - Method m = desktop.getClass().getDeclaredMethod( - "browse", URI.class); - m.invoke(desktop, uri); + desktop.browse(uri); success = true; } catch (RuntimeException re) { throw re; // Keep FindBugs happy @@ -107,38 +99,20 @@ public static boolean browse(URI uri) { /** * Returns the singleton java.awt.Desktop instance, or - * null if it is unsupported on this platform (or the JRE - * is older than 1.6). + * null if it is unsupported on this platform. * - * @return The desktop, as an {@link Object}. + * @return The desktop, as an {@link Object}, or {@code null} + * if desktop operations are unsupported. */ - private static Object getDesktop() { + private static Desktop getDesktop() { synchronized (LOCK_DESKTOP_CREATION) { - if (!desktopCreationAttempted) { - desktopCreationAttempted = true; - - try { - Class desktopClazz = Class.forName("java.awt.Desktop"); - Method m = desktopClazz. - getDeclaredMethod("isDesktopSupported"); - - boolean supported= (Boolean) m.invoke(null); - if (supported) { - m = desktopClazz.getDeclaredMethod("getDesktop"); - desktop = m.invoke(null); - } - - } catch (RuntimeException re) { - throw re; // Keep FindBugs happy - } catch (Exception e) { - // Ignore; keeps desktop as null. + if (Desktop.isDesktopSupported()) { + desktop = Desktop.getDesktop(); } - } - } return desktop; @@ -196,9 +170,9 @@ public static Rectangle getScreenBoundsForPoint(int x, int y) { /** * Give apps a chance to decorate us with drop shadows, etc. Since very - * scrolly things such as lists (of e.g. completions) are *very* slow when - * in per-pixel translucent windows, even as of Java 7u2, we force the user - * to specify an extra option for the two "main" auto-complete windows. + * scrollable things such as lists (of e.g. completions) are *very* slow + * when in per-pixel translucent windows, even as of Java 7u2, we force the + * user to specify an extra option for the two "main" auto-complete windows. * * @return Whether to allow decorating the main auto-complete windows. * @see #PROPERTY_ALLOW_DECORATED_AUTOCOMPLETE_WINDOWS diff --git a/AutoComplete/src/main/java/org/fife/ui/autocomplete/VariableCompletion.java b/AutoComplete/src/main/java/org/fife/ui/autocomplete/VariableCompletion.java index 1683107..6a48488 100644 --- a/AutoComplete/src/main/java/org/fife/ui/autocomplete/VariableCompletion.java +++ b/AutoComplete/src/main/java/org/fife/ui/autocomplete/VariableCompletion.java @@ -70,7 +70,7 @@ public String getDefinitionString() { sb.append(type).append(' '); } - // Add the item being described's name. + // Add the name of the item being described sb.append(getName()); return sb.toString();