Skip to content

Commit

Permalink
Removing some checks for pre-Java 6 since they're no longer needed, a…
Browse files Browse the repository at this point in the history
…nd fixed a few typos in Javadoc
  • Loading branch information
bobbylight committed Jul 28, 2024
1 parent deecf48 commit 66112d2
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>externalURLHandler</code>.
*/
private static LinkRedirector linkRedirector;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.<p>
* If no handler is installed, the system default web browser is used to open
* the URL.<p>
*
* Alternatively, folks implementing robust code completion support for a
* language might install an <code>ExternalURLHandler</code> to handle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public String getToolTipText(RTextArea textArea, MouseEvent e) {
String tip = null;

List<Completion> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void deactivate() {
*/
public String getArgumentText(int offs) {
List<Highlight> paramHighlights = getParameterHighlights();
if (paramHighlights==null || paramHighlights.size()==0) {
if (paramHighlights==null || paramHighlights.isEmpty()) {
return null;
}
for (Highlight h : paramHighlights) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void actionPerformed(ActionEvent e) {
// provider always first.
for (int i=1; i<cycle.size(); i++) {
List<Completion> completions = getCompletionProvider().getCompletions(getTextComponent());
if (completions.size() > 0) {
if (!completions.isEmpty()) {
//nothing to do, just let the current provider display
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
54 changes: 14 additions & 40 deletions AutoComplete/src/main/java/org/fife/ui/autocomplete/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();


Expand All @@ -77,20 +72,17 @@ private Util() {
*
* @param uri The URI to open. If this is <code>null</code>, nothing
* happens and this method returns <code>false</code>.
* @return Whether the operation was successful. This will be
* <code>false</code> 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
Expand All @@ -107,38 +99,20 @@ public static boolean browse(URI uri) {

/**
* Returns the singleton <code>java.awt.Desktop</code> instance, or
* <code>null</code> if it is unsupported on this platform (or the JRE
* is older than 1.6).
* <code>null</code> 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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 66112d2

Please sign in to comment.