Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/org/fife/rtext/AbstractParserNoticeWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ public Class<?> getColumnClass(int col) {
public void addRow(Object[] data) {
// NOTE: It's valid for data[1] to be Strings, in which case
// it's taken to be the full path of a file.
if (data[1] instanceof RTextEditorPane) {
data[1] = new TextAreaWrapper((RTextEditorPane)data[1]);
if (data[1] instanceof RTextEditorPane pane) {
data[1] = new TextAreaWrapper(pane);
}
else if (data[1] instanceof String) {
data[1] = new TextAreaWrapper((String)data[1]);
else if (data[1] instanceof String str) {
data[1] = new TextAreaWrapper(str);
}
super.addRow(data);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/fife/rtext/RTextUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,14 @@ public static void setDropShadowsEnabledInEditor(boolean enabled) {
@Override
public void decorate(JWindow window) {
Container cp = window.getContentPane();
if (cp instanceof JComponent) {
if (cp instanceof JComponent jc) {
TranslucencyUtil util =
TranslucencyUtil.get();
util.setOpaque(window, false);
((JComponent)cp).setBorder(
jc.setBorder(
BorderFactory.createCompoundBorder(
ShadowPopupBorder.getInstance(),
((JComponent)cp).getBorder()));
jc.getBorder()));
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fife/rtext/RemoteFileChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ protected void escapePressed() {
@Override
public void focusGained(FocusEvent e) {
Object source = e.getSource();
if (source instanceof JTextComponent) {
((JTextComponent)source).selectAll();
if (source instanceof JTextComponent tc) {
tc.selectAll();
}
}

Expand Down
15 changes: 5 additions & 10 deletions src/main/java/org/fife/rtext/SyntaxFilters.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,14 @@ public static boolean isValidFileFilterString(String fileFilterString) {
for (int i=0; i<length; i++) {
char c = fileFilterString.charAt(i);
switch (c) {
case '*':
case '?':
case '.':
case '-':
case '_':
case '$':
case ' ':
continue;
default:
case '*', '?', '.', '-', '_', '$', ' ' -> {
// Valid special character, keep going
}
default -> {
if (!Character.isLetterOrDigit(c)) {
return false;
}
break;
}
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public boolean importData(JComponent c, Transferable t) {
protected void selectTab(final JTabbedPane tabbedPane, final int index) {
SwingUtilities.invokeLater(() -> {
Container parent = tabbedPane.getParent();
if (parent instanceof AbstractMainView) {
((AbstractMainView)parent).setSelectedIndex(index);
if (parent instanceof AbstractMainView mainView) {
mainView.setSelectedIndex(index);
}
else {
// Should never happen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ private void handleSubmitImpl(String code, boolean appendPrompt) {

} catch (Exception e) {
// Peel off wrapper ScriptException
if (e instanceof ScriptException) {
append(massageScriptException((ScriptException)e), STYLE_STDERR);
if (e instanceof ScriptException se) {
append(massageScriptException(se), STYLE_STDERR);
}
else {
StringWriter sw = new StringWriter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ private LangSupportUtils() {
* @return The file.
*/
public static File getClassFileLocation(LibraryInfo li) {
if (li instanceof JarLibraryInfo) {
return ((JarLibraryInfo)li).getJarFile();
if (li instanceof JarLibraryInfo jli) {
return jli.getJarFile();
}
else if (li instanceof DirLibraryInfo) {
return new File(li.getLocationAsString());
}
else if (li instanceof Jdk9LibraryInfo) {
return ((Jdk9LibraryInfo)li).getJreHome();
else if (li instanceof Jdk9LibraryInfo j9li) {
return j9li.getJreHome();
}
throw new IllegalArgumentException("Unknown LibraryInfo type: " + li.getClass().getName());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fife/rtext/plugins/macros/Macro.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ else if (o!=null) {
*/
@Override
public boolean equals(Object o) {
return o instanceof Macro && compareTo((Macro)o)==0;
return o instanceof Macro other && compareTo(other)==0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void accept(WorkspaceVisitor visitor) {

@Override
public int compareTo(ProjectEntry entry) {
if (entry instanceof FileProjectEntry) {
return file.compareTo(entry.getFile());
if (entry instanceof FileProjectEntry other) {
return file.compareTo(other.getFile());
}
return -1;
}
Expand All @@ -56,8 +56,8 @@ public final boolean equals(Object o) {
if (o==this) {
return true;
}
return o instanceof FileProjectEntry &&
compareTo((FileProjectEntry)o)==0;
return o instanceof FileProjectEntry other &&
compareTo(other)==0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void accept(WorkspaceVisitor visitor) {

@Override
public int compareTo(ProjectEntry o) {
if (o instanceof FolderProjectEntry) {
return dir.compareTo(o.getFile());
if (o instanceof FolderProjectEntry other) {
return dir.compareTo(other.getFile());
}
return -1;
}
Expand All @@ -57,8 +57,8 @@ public final boolean equals(Object o) {
if (o==this) {
return true;
}
return o instanceof FolderProjectEntry &&
compareTo((FolderProjectEntry)o)==0;
return o instanceof FolderProjectEntry other &&
compareTo(other)==0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void addEntry(ProjectEntry entry) {

@Override
public int compareTo(ProjectEntry o) {
if (o instanceof LogicalFolderProjectEntry) {
return name.compareTo(((LogicalFolderProjectEntry)o).getName());
if (o instanceof LogicalFolderProjectEntry other) {
return name.compareTo(other.getName());
}
return -1;
}
Expand All @@ -67,8 +67,8 @@ public final boolean equals(Object o) {
if (o==this) {
return true;
}
return o instanceof LogicalFolderProjectEntry &&
compareTo((LogicalFolderProjectEntry)o)==0;
return o instanceof LogicalFolderProjectEntry other &&
compareTo(other)==0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public boolean equals(Object o) {
if (o==this) {
return true;
}
if (o instanceof Project) {
return compareTo((Project)o)==0;
if (o instanceof Project other) {
return compareTo(other)==0;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ public String getToolTipText(MouseEvent e) {
TreePath path = getPathForLocation(e.getX(), e.getY());
if (path!=null) {
Object last = path.getLastPathComponent();
if (last instanceof AbstractWorkspaceTreeNode) {
return ((AbstractWorkspaceTreeNode)last).getToolTipText();
if (last instanceof AbstractWorkspaceTreeNode node) {
return node.getToolTipText();
}
}
return null;
Expand Down Expand Up @@ -329,8 +329,8 @@ private void installActions() {
@Override
public void actionPerformed(ActionEvent e) {
Object selected = getLastSelectedPathComponent();
if (selected instanceof AbstractWorkspaceTreeNode) {
((AbstractWorkspaceTreeNode)selected).handleRename();
if (selected instanceof AbstractWorkspaceTreeNode node) {
node.handleRename();
}
}
});
Expand All @@ -350,8 +350,8 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
Object selected = getLastSelectedPathComponent();
if (selected instanceof ProjectEntryTreeNode) {
((ProjectEntryTreeNode)selected).handleRemove();
if (selected instanceof ProjectEntryTreeNode node) {
node.handleRemove();
}
}
});
Expand All @@ -371,8 +371,8 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
Object selected = getLastSelectedPathComponent();
if (selected instanceof PhysicalLocationTreeNode) {
refreshChildren((PhysicalLocationTreeNode)selected);
if (selected instanceof PhysicalLocationTreeNode node) {
refreshChildren(node);
}
}
});
Expand All @@ -397,8 +397,8 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
Object selected = getLastSelectedPathComponent();
if (selected instanceof AbstractWorkspaceTreeNode) {
((AbstractWorkspaceTreeNode)selected).handleProperties();
if (selected instanceof AbstractWorkspaceTreeNode node) {
node.handleProperties();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,21 +393,20 @@ private void mouseMovedImpl(MouseEvent e) {
String text = null;

// If it's a high-level node (e.g. "Methods (4)").
if (object instanceof String) {
text = (String)object;
if (object instanceof String str) {
text = str;
}

// If it's a low-level node (function, variable, etc.). Note
// that this should always be a TagEntry, but we're just being
// safe by checking here.
else if (object instanceof TagEntry) {
ExtendedTagEntry entry = (ExtendedTagEntry)object;
else if (object instanceof ExtendedTagEntry entry) {
text = mouseMovedTagEntry(entry);
}

// Set the tooltip text.
if (treeRenderer instanceof JComponent) {
((JComponent)treeRenderer).setToolTipText(text);
if (treeRenderer instanceof JComponent jc) {
jc.setToolTipText(text);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/fife/rtext/plugins/tools/Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ else if (t2!=null) {
*/
@Override
public boolean equals(Object o) {
return o instanceof Tool && compareTo((Tool)o)==0;
return o instanceof Tool other && compareTo(other)==0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ class TemplateDialog extends EscapableDialog implements ActionListener,
idField = new JTextField(20);
Document doc = idField.getDocument();
doc.addDocumentListener(this);
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).setDocumentFilter(
if (doc instanceof AbstractDocument ad) {
ad.setDocumentFilter(
new TemplateNameDocumentFilter());
}
idLabel.setLabelFor(idField);
Expand Down