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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

public class NBMNativeMWITest extends NbTestCase {

private static final String EXPECTED_JAVAC_PLUGIN_VERSION = "3.15.0";
private static final String EXPECTED_JAVAC_PLUGIN_VERSION = "3.16.0";

private FileObject wd;

Expand Down
30 changes: 14 additions & 16 deletions ide/editor/src/org/netbeans/modules/editor/EditorModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,18 @@ public void saveSetting(String settingName, Object value) {
initAndCheckEditorKitTypeRegistry("text/html", HTMLEditorKit.class.getName()); //NOI18N
initAndCheckEditorKitTypeRegistry("text/rtf", RTFEditorKit.class.getName()); //NOI18N
initAndCheckEditorKitTypeRegistry("application/rtf", RTFEditorKit.class.getName()); //NOI18N

// Now hook up to the JDK's editor kit registry
// XXX: This all should be removed, see IZ #80110
// TODO: This all should be removed, see IZ #80110 or #9523
if (!Boolean.parseBoolean(System.getProperty("nb.disable.editorkit.hack", "false" /*TODO true in future*/))) {
LOG.log(Level.WARNING,
"""
Setting content type by mime type String for NetBeans editor kits is no longer supported and will fail on JDK 27 and later, obtain the EditorKit instead:
jtextarea.setContentType("text/x-properties") =>
jtextarea.setEditorKit(CloneableEditorSupport.getEditorKit("text/x-properties"))
Set the sytem property 'nb.disable.editorkit.hack=true' to disable this warning.
"""
);
try {
Field keyField = JEditorPane.class.getDeclaredField("kitRegistryKey"); // NOI18N
keyField.setAccessible(true);
Expand All @@ -166,21 +175,10 @@ public void saveSetting(String settingName, Object value) {
// Hashtable kitMapping = (Hashtable)sun.awt.AppContext.getAppContext().get(key);
// sun.awt.AppContext.getAppContext().put(key, new HackMap(kitMapping));
} catch (Throwable t) {
if (debug) {
LOG.log(Level.WARNING, "Can't hack in to the JEditorPane's registry for kits.", t);
} else {
LOG.log(Level.WARNING, "Can''t hack in to the JEditorPane''s registry for kits: {0}", new Object[] {t});
}
LOG.log(Level.WARNING, "Can't hack in to the JEditorPane's registry to replace editor kits.");
}

// Registration of the editor kits to JEditorPane
// for (int i = 0; i < replacements.length; i++) {
// JEditorPane.registerEditorKitForContentType(
// replacements[i].contentType,
// replacements[i].newKitClassName,
// getClass().getClassLoader()
// );
// }
}
// removeme end

// ------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,12 @@ private <T> void queryTermsImpl(

changeIndexReader(adapter, in);
try {
for(LeafReaderContext lrc: in.leaves()) {
TermsEnum te = lrc.reader().terms(field).iterator();
for (LeafReaderContext lrc: in.leaves()) {
Terms terms = lrc.reader().terms(field);
if (terms == null) {
continue;
}
TermsEnum te = terms.iterator();
if (te.seekCeil(startBytesRef) != TermsEnum.SeekStatus.END) {
do {
if (cancel != null && cancel.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,12 @@ public <T> void queryTerms(
if (in == null) {
return;
}
for(LeafReaderContext lrc: in.leaves()) {
TermsEnum te = lrc.reader().terms(field).iterator();
for (LeafReaderContext lrc: in.leaves()) {
Terms terms = lrc.reader().terms(field);
if (terms == null) {
continue;
}
TermsEnum te = terms.iterator();
if (te.seekCeil(startBytesRef) != TermsEnum.SeekStatus.END) {
do {
if (cancel != null && cancel.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -122,10 +121,6 @@ public final class OpenProjectList {
* otherwise we get a deadlock fairly fast
*/
static final Mutex MUTEX = new Mutex();

public static Comparator<? super Project> projectByPath() {
return new ProjectByPathComparator();
}

// Property names
public static final String PROPERTY_OPEN_PROJECTS = "OpenProjects";
Expand Down Expand Up @@ -221,6 +216,10 @@ public static void waitProjectsFullyOpen() {
getDefault().LOAD.waitFinished(0);
}

public static Comparator<? super Project> projectByPath() {
return PROJECT_BY_PATH_COMPARATOR;
}

static void preferredProject(final Project lazyP) {
if (lazyP != null) {
OPENING_RP.post(new Runnable() {
Expand Down Expand Up @@ -1922,21 +1921,35 @@ public URL getURL() {

}

private static class ProjectByPathComparator implements Comparator<Project> {
@Override
public int compare(Project p1, Project p2) {
if (p1 == null && p2 == null) {
return 0;
}
if (p1 == null) {
return -1;
}
if (p2 == null) {
return 1;
/// ensures that child dirs follow right after the parent
private static final Comparator<String> PATH_COMPONENT_COMPARATOR = (p1, p2) -> {
String[] comp1 = p1.split("/");
String[] comp2 = p2.split("/");
int min = Math.min(comp1.length, comp2.length);
for (int i = 0; i < min; i++) {
int c = comp1[i].compareTo(comp2[i]);
if (c != 0) {
return c;
}
return p1.getProjectDirectory().getPath().compareTo(p2.getProjectDirectory().getPath());
}
}
return Integer.compare(comp1.length, comp2.length);
};

private static final Comparator<Project> PROJECT_BY_PATH_COMPARATOR = (p1, p2) -> {
if (p1 == null && p2 == null) {
return 0;
}
if (p1 == null) {
return -1;
}
if (p2 == null) {
return 1;
}
return PATH_COMPONENT_COMPARATOR.compare(
p1.getProjectDirectory().getPath(), // String normalized with '/' separator
p2.getProjectDirectory().getPath()
);
};

private final class NbProjectDeletionListener extends FileChangeAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -29,6 +30,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
Expand All @@ -40,6 +42,7 @@
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
Expand All @@ -48,6 +51,8 @@
import org.netbeans.junit.MockServices;
import org.netbeans.junit.NbTestCase;
import org.netbeans.junit.RandomlyFails;
import org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj;
import org.netbeans.modules.masterfs.filebasedfs.naming.NamingFactory;
import org.netbeans.modules.project.ui.actions.TestSupport;
import org.netbeans.spi.project.SubprojectProvider;
import org.netbeans.spi.project.ui.ProjectOpenedHook;
Expand All @@ -56,14 +61,14 @@
import org.openide.filesystems.URLMapper;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.util.Lookup;
import org.openide.util.RequestProcessor;
import org.openide.util.lookup.Lookups;

/** Tests fix of issue 56454.
*
* @author Jiri Rechtacek
*/
@RandomlyFails
public class OpenProjectListTest extends NbTestCase {
FileObject f1_1_open, f1_2_open, f1_3_close;
FileObject f2_1_open;
Expand Down Expand Up @@ -112,6 +117,7 @@ protected Level logLevel() {
OpenProjectList.getDefault().close(OpenProjectList.getDefault().getOpenProjects(), false);
}

@RandomlyFails
public void testOpen () throws Exception {
assertTrue ("No project is open.", OpenProjectList.getDefault ().getOpenProjects ().length == 0);
CharSequence log = Log.enable("org.netbeans.ui", Level.FINE);
Expand All @@ -130,6 +136,7 @@ public void testOpen () throws Exception {
*/
}

@RandomlyFails
public void testListenerOpenClose () throws Exception {
assertTrue ("No project is open.", OpenProjectList.getDefault ().getOpenProjects ().length == 0);
ChangeListener list = new ChangeListener();
Expand Down Expand Up @@ -187,6 +194,7 @@ public void testClose () throws Exception {
assertTrue ("Document f2_1_open is still loaded.", handler.openFiles.contains (f2_1_open.toURL ().toExternalForm ()));
}

@RandomlyFails
public void testSerialize() throws Exception {
testOpen();

Expand All @@ -209,6 +217,7 @@ public void testSerialize() throws Exception {
}
}

@RandomlyFails
public void testOpenDependingProject () throws Exception {
assertTrue ("No project is open.", OpenProjectList.getDefault ().getOpenProjects ().length == 0);
CharSequence log = Log.enable("org.netbeans.ui", Level.FINE);
Expand All @@ -226,6 +235,7 @@ public void testOpenDependingProject () throws Exception {
assertTrue ("Document f2_1_open is loaded.", handler.openFiles.contains (f2_1_open.toURL ().toExternalForm ()));
}

@RandomlyFails
public void testCloseProjectWithoutOpenDocuments () throws Exception {
assertTrue ("No project is open.", OpenProjectList.getDefault ().getOpenProjects ().length == 0);
OpenProjectList.getDefault ().open (project2, false);
Expand All @@ -242,6 +252,7 @@ public void testCloseProjectWithoutOpenDocuments () throws Exception {
assertFalse ("Project2 is closed.", OpenProjectList.getDefault ().isOpen (project2));
}

@RandomlyFails
public void testProjectOpenedClosed() throws Exception {
((TestSupport.TestProject) project1).setLookup(Lookups.fixed(new Object[] {
new TestProjectOpenedHookImpl(),
Expand All @@ -263,6 +274,7 @@ public void testProjectOpenedClosed() throws Exception {
assertEquals("both close hooks were called", 2, TestProjectOpenedHookImpl.closed);
}

@RandomlyFails
public void testNotifyDeleted() throws Exception {
FileObject workDir = FileUtil.toFileObject (getWorkDir ());

Expand Down Expand Up @@ -299,6 +311,7 @@ public void testNotifyDeleted() throws Exception {
assertFalse("project2 is not in recent projects list", OpenProjectList.getDefault().getRecentProjects().contains(prj2));
}

@RandomlyFails
public void testMainProject() throws Exception {
FileObject workDir = FileUtil.toFileObject (getWorkDir ());

Expand Down Expand Up @@ -348,6 +361,7 @@ public void testMainProject() throws Exception {
OpenProjectList.getDefault().setMainProject(prj1);
}

@RandomlyFails
public void testProjectClosedRace() throws Exception {

final class POHImpl extends ProjectOpenedHook {
Expand Down Expand Up @@ -427,6 +441,43 @@ public void run() {

}

public void testChildrenFirstPathComparator() throws Exception {
// keep relative or this will fail on windows due to File conversion
List<PathProject> paths = Stream.of(
"a/maven",
"a/maven-indexer",
"a/maven-indexer/indexer-core",
"a/maven/maven-model"
).map(s -> new File(s.replace("/", File.separator))).map(PathProject::new).toList();

List<Project> sorted = new ArrayList<>(paths);
sorted.sort(OpenProjectList.projectByPath());
assertEquals(
"maven-indexer must be last",
"[a/maven, a/maven/maven-model, a/maven-indexer, a/maven-indexer/indexer-core]",
sorted.toString()
);
}

private record PathProject(File file) implements Project {

@Override
public FileObject getProjectDirectory() {
return new FolderObj(file, NamingFactory.fromFile(file));
}

@Override
public Lookup getLookup() {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public String toString() {
return file.toString().replace(File.separator, "/");
}

}

// helper code

private static class MySubprojectProvider implements SubprojectProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public final class MavenVersionSettings {
static {
// TODO update periodically - modifications might require unit test adjustments (e.g NBMNativeMWITest)
// (e.g NBMNativeMWITest checks the compiler plugin version)
String nb_version = "RELEASE310";
String nb_version = "RELEASE320";
String nb_utilities_version = "14.5";
fallback = Map.ofEntries(
entry(key("org.netbeans.api", "org-netbeans-modules-editor"), nb_version), // represents all other nb artifacts
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER), "3.15.0"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR), "3.5.0"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER), "3.16.0"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_JAR), "3.5.1"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_RESOURCES), "3.5.0"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_FAILSAFE), "3.5.6"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_SUREFIRE), "3.5.6"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_FAILSAFE), "3.6.0"),
entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_SUREFIRE), "3.6.0"),
entry(key("org.apache.netbeans.utilities", "utilities-parent"), nb_utilities_version),
entry(key("org.apache.netbeans.utilities", "nbm-maven-harness"), nb_utilities_version),
entry(key("org.apache.netbeans.utilities", "nbm-shared"), nb_utilities_version),
Expand Down
Loading
Loading