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
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ jobs:
- name: ide/javascript2.debug
run: ant $OPTS -f ide/javascript2.debug test

- name: ide/jumpto
run: ant $OPTS -f ide/jumpto test

- name: ide/languages.hcl
run: ant $OPTS -f ide/languages.hcl test

Expand Down
6 changes: 3 additions & 3 deletions ide/jumpto/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
# under the License.

javac.compilerargs=-Xlint:unchecked
javac.source=1.8
javac.release=17
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
nbm.module.author=Andrei Badea, Petr Hrebejk
spec.version.base=1.85.0

test.config.stableBTD.includes=**/*Test.class
test.config.stableBTD.excludes=\
test.config.default.includes=**/*Test.class
test.config.default.excludes=\
**/GoToTypeActionTest.class
15 changes: 8 additions & 7 deletions ide/jumpto/src/org/netbeans/modules/jumpto/EntityComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
Expand All @@ -43,7 +44,7 @@ public abstract class EntityComparator<E> implements Comparator<E> {
Collection<String> namesOfOpenProjects = getNamesOfOpenProjects();

/**
* Comparies its two strings for order.
* Compares its two strings for order.
* @param s1 the first {@code String} to be compared (may be {@code null}).
* @param s2 the second {@code String} to be compared (may be {@code null}).
* @return the value <code>0</code> if the argument string is equal to
Expand All @@ -65,8 +66,8 @@ protected int compare(String s1, String s2, boolean caseSensitive) {
}

/**
* Comparies its two project names for order.
* It establishes the folowing relation between projects:
* Compares its two project names for order.
* It establishes the following relation between projects:
* <pre>
* Main Project &lt; Open Project &lt; Not Open Project
* </pre>
Expand Down Expand Up @@ -168,10 +169,10 @@ public static String getMainProjectName() {
* @return a collection of the names.
*/
private static Collection<String> getNamesOfOpenProjects() {
ArrayList<String> names = new ArrayList<String>(10);
for(Project p: OpenProjects.getDefault().getOpenProjects()) {
String pName = ProjectUtils.getInformation(p).getDisplayName();
names.add(pName);
Project[] projects = OpenProjects.getDefault().getOpenProjects();
List<String> names = new ArrayList<>(projects.length);
for(Project p : projects) {
names.add(ProjectUtils.getInformation(p).getDisplayName());
}
return names;
}
Expand Down
8 changes: 4 additions & 4 deletions ide/jumpto/src/org/netbeans/modules/jumpto/SearchHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public SearchHistory(Class clazz, JTextField textField) {
* @param textField a text field which is used for showing/storing history.
*/
public SearchHistory(String historyKey, JTextField textField) {
assert historyKey != null && historyKey.trim().length() > 0;
assert historyKey != null && !historyKey.isBlank();
assert textField != null;

this.historyKey = historyKey;
Expand Down Expand Up @@ -115,7 +115,7 @@ private void addHistoryItem(String text) {
}

private void addHistoryItem(String text, MoveOffset moveOffset) {
if (text == null || text.trim().length() == 0) {
if (text == null || text.isBlank()) {
LOGGER.fine("String to store is empty => ignoring.");
return;
}
Expand Down Expand Up @@ -217,13 +217,13 @@ private void navigate(String oldText, MoveOffset moveOffset) {
LOGGER.fine("New text is: " + newText);
addHistoryItem(userText, moveOffset);
}
assert newText != null && newText.trim().length() > 0;
assert newText != null && !newText.isBlank();
textField.setText(newText);
}

private List<String> readHistory() {
String history = getPreferences().get(historyKey, null);
if (history == null || history.trim().length() == 0) {
if (history == null || history.isBlank()) {
LOGGER.fine("No history found");
return new ArrayList<String>(2 * HISTORY_LIMIT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.netbeans.modules.jumpto.common;

import java.util.Collections;
import java.util.Map;
import javax.swing.event.ChangeListener;
import org.netbeans.api.annotations.common.CheckForNull;
Expand Down Expand Up @@ -111,7 +110,7 @@ private static NameMatcher createNameMatcher (
NameMatcherFactory.createNameMatcher(
searchText,
searchType,
options == null ? Collections.<String,Object>emptyMap() : options) :
options == null ? Map.of() : options) :
null;
}
}
45 changes: 16 additions & 29 deletions ide/jumpto/src/org/netbeans/modules/jumpto/common/ItemRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.swing.ButtonModel;
Expand All @@ -50,7 +47,6 @@
import org.netbeans.api.editor.settings.FontColorSettings;
import org.netbeans.modules.jumpto.EntityComparator;
import org.netbeans.modules.jumpto.settings.GoToSettings;
import org.openide.awt.HtmlRenderer;
import org.openide.util.ImageUtilities;
import org.openide.util.Parameters;

Expand All @@ -72,7 +68,7 @@ public static interface Convertor<T> {
}

public static final class Builder<T> {
private final JList list;
private final JList<T> list;
private final ButtonModel caseSensitive;
private final Convertor<T> convertor;
private String separatorPattern;
Expand Down Expand Up @@ -146,7 +142,7 @@ public static <T> Builder<T> create(
private final Color fgSelectionColor;
private final Color bgColorGreener;
private final Color bgColorDarkerGreener;
private final JList jList;
private final JList<T> jList;
private final ButtonModel caseSensitive;
private final ButtonModel colorPrefered;
private final ButtonModel searchFolders;
Expand All @@ -173,10 +169,9 @@ private ItemRenderer(
nameFormater = createNameFormatter(hs.getHighlightingType(), separatorPattern);
this.jlName = new JLabel();
resetNameLabel();
Container container = list.getParent();
if ( container instanceof JViewport ) {
((JViewport)container).addChangeListener(this);
stateChanged(new ChangeEvent(container));
if (list.getParent() instanceof JViewport vp) {
vp.addChangeListener(this);
stateChanged(new ChangeEvent(vp));
}
rendererComponent = new MyPanel<>(convertor);
rendererComponent.setLayout(new GridBagLayout());
Expand Down Expand Up @@ -252,7 +247,7 @@ private ItemRenderer(
@NonNull
@Override
public Component getListCellRendererComponent(
@NonNull final JList list,
@NonNull final JList<?> list,
@NullAllowed final Object value,
final int index,
final boolean isSelected,
Expand Down Expand Up @@ -361,8 +356,7 @@ private String getBoldText(String text) {
}

private boolean isMainProject(String projectName) {
return projectName != null && projectName.equals(mainProjectName) ?
true : false;
return projectName != null && projectName.equals(mainProjectName);
}

private static class MyPanel<T> extends JPanel {
Expand Down Expand Up @@ -403,16 +397,11 @@ private void resetNameLabel() {
}

private boolean shouldHighlight(final boolean selectedItem) {
switch (highlightMode) {
case NONE:
return false;
case ACTIVE:
return selectedItem;
case ALL:
return true;
default:
throw new IllegalArgumentException(String.valueOf(selectedItem));
}
return switch (highlightMode) {
case NONE -> false;
case ACTIVE -> selectedItem;
case ALL -> true;
};
}

@NonNull
Expand Down Expand Up @@ -442,13 +431,11 @@ private static HighlightingNameFormatter createNameFormatter(
if (colors != null) {
final AttributeSet attrs = colors.getFontColors("mark-occurrences"); //NOI18N
if (attrs != null) {
Object o = attrs.getAttribute(StyleConstants.Background);
if (o instanceof Color) {
back = (Color) o;
if (attrs.getAttribute(StyleConstants.Background) instanceof Color bg) {
back = bg;
}
o = attrs.getAttribute(StyleConstants.Foreground);
if (o instanceof Color) {
front = (Color) o;
if (attrs.getAttribute(StyleConstants.Foreground) instanceof Color fg) {
front = fg;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions ide/jumpto/src/org/netbeans/modules/jumpto/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public static SearchType getSearchType(
@NullAllowed final String camelCasePart) {
int wildcard = Utils.containsWildCard(text);
if (exact) {
//nameKind = isCaseSensitive ? SearchType.EXACT_NAME : SearchType.CASE_INSENSITIVE_EXACT_NAME;
return SearchType.EXACT_NAME;
return isCaseSensitive ? SearchType.EXACT_NAME : SearchType.CASE_INSENSITIVE_EXACT_NAME;
} else if (wildcard != -1) {
return isCaseSensitive ? SearchType.REGEXP : SearchType.CASE_INSENSITIVE_REGEXP;
} else if ((Utils.isAllUpper(text) && text.length() > 1) || Queries.isCamelCase(text, camelCaseSeparator, camelCasePart)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
CTL_FileSearchAction=Go to &File...
editor-popup-CTL_FileSearchAction=File...

CTL_Open=&OK
CTL_Open=OK
CTL_SelectInProjects=&Select in Projects
CTL_Close=&Close
CTL_Close=Close
# {0} = project name
MSG_FileSearchDlgTitle=Go to File
CTL_FileName=File &Name (prefix, wildcards: "?" "*"):
CTL_FileName=File &Name (prefix, wildcards: "?" "*", exact match: end with space):
CTL_MatchingFiles=&Matching Files
CTL_CaseSensitive=&Case Sensitive

Expand All @@ -37,10 +37,12 @@ TXT_SearchingOtherProjects=Searching Other Projects...
TXT_PartialResults=Partial results, Searching...

LBL_HiddenFiles=Show &Hidden Files
LBL_PreferMainProject=&Prefer Current Project
LBL_PreferMainProject=Prefer &Current Project
LBL_PreferOpenProjects=Prefer &Open Projects
# {0} - display name of the current prject
FMT_CurrentProjectLabel=Prefer Current Project ({0})
LBL_CaseSensitive=&Case Sensitive
LBL_CaseSensitive=Case &Sensitive
LBL_SearchByPath=Search by &Path

AN_Location=Location
AD_Location=Location
Expand Down
31 changes: 18 additions & 13 deletions ide/jumpto/src/org/netbeans/modules/jumpto/file/FileComarator.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class FileComarator extends EntityComparator<FileDescriptor> imp

private final ChangeSupport support;
protected final boolean caseSensitive;
protected final boolean preferOpPrjs;
protected boolean preferOpPrjs;
protected boolean usePreferred;

private FileComarator(
Expand All @@ -61,16 +61,23 @@ boolean isUsePreferred() {
return usePreferred;
}

void setUsePreferred(final boolean usePreferred) {
final boolean fire = this.usePreferred ^ usePreferred;
this.usePreferred = usePreferred;
if (fire) {
void setUsePreferred(boolean usePreferred) {
if (this.usePreferred != usePreferred) {
this.usePreferred = usePreferred;
support.fireChange();
}
}

void setPrefereOpenProjects(boolean prefereOpenProjects) {
if (this.preferOpPrjs != prefereOpenProjects) {
this.preferOpPrjs = prefereOpenProjects;
support.fireChange();
}
}

abstract void setText(@NonNull final String text);

@Override
public abstract int compare(FileDescriptor e1, FileDescriptor e2);

void fireChange() {
Expand All @@ -86,6 +93,7 @@ private static final class Alphabet extends FileComarator {
super(usePreferred, caseSensitive, preferOpPrjs);
}

@Override
void setText(@NonNull final String text) {
}

Expand Down Expand Up @@ -147,6 +155,7 @@ private static final class Levenshtein extends FileComarator {
this.text = text;
}

@Override
void setText(@NonNull final String text) {
final boolean fire = !Objects.equals(this.text, text);
this.text = text;
Expand Down Expand Up @@ -253,14 +262,10 @@ public static FileComarator create(
final boolean usePreferred,
final boolean caseSensitive,
final boolean preferOpPrjs) {
switch (kind) {
case LEXICOGRAPHIC:
return new Alphabet(usePreferred, caseSensitive, preferOpPrjs);
case LEVENSHTEIN:
return new Levenshtein(text, usePreferred, caseSensitive, preferOpPrjs);
default:
throw new IllegalArgumentException(String.valueOf(kind));
}
return switch (kind) {
case LEXICOGRAPHIC -> new Alphabet(usePreferred, caseSensitive, preferOpPrjs);
case LEVENSHTEIN -> new Levenshtein(text, usePreferred, caseSensitive, preferOpPrjs);
};
}
}

Loading
Loading