Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into BETA_JAVA23
Browse files Browse the repository at this point in the history
  • Loading branch information
noopur2507 committed Aug 28, 2024
2 parents 5c13046 + 1f509a5 commit 125facd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ protected void fillWithWorkspaceJREs() {
protected void fillWithWorkspaceProfiles() {
fEnvironments.clear();
fEnvironments.addAll(JavaRuntime.getExecutionEnvironmentsManager().getSupportedExecutionEnvironments());
Collections.reverse(fEnvironments);
String[] names = new String[fEnvironments.size()];
Iterator<Object> iter = fEnvironments.iterator();
int i = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -96,7 +95,7 @@ public class EnvironmentsManager implements IExecutionEnvironmentsManager, IVMIn
*/
private TreeSet<IExecutionEnvironment> fEnvironments = null;

private List<IExecutionEnvironment> supportedEnvironments;
private SortedSet<IExecutionEnvironment> supportedEnvironments;

/**
* List of access rule participants
Expand Down Expand Up @@ -170,7 +169,7 @@ public synchronized IExecutionEnvironment[] getExecutionEnvironments() {
}

@Override
public synchronized List<IExecutionEnvironment> getSupportedExecutionEnvironments() {
public synchronized SortedSet<IExecutionEnvironment> getSupportedExecutionEnvironments() {
initializeExtensions();
return supportedEnvironments;
}
Expand Down Expand Up @@ -264,20 +263,15 @@ private synchronized void initializeExtensions() {
if (fEnvironments != null) {
return;
}
Comparator<IExecutionEnvironment> eeComparator = ((Comparator<IExecutionEnvironment>) (o1, o2) -> {
String compliance1 = getExecutionEnvironmentCompliance(o1);
String compliance2 = getExecutionEnvironmentCompliance(o2);
return JavaCore.compareJavaVersions(compliance1, compliance2);
}).thenComparing(IExecutionEnvironment::getId);

IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(LaunchingPlugin.ID_PLUGIN, JavaRuntime.EXTENSION_POINT_EXECUTION_ENVIRONMENTS);
IConfigurationElement[] configs = extensionPoint.getConfigurationElements();
fEnvironments = new TreeSet<>(new Comparator<IExecutionEnvironment>() {
@Override
public int compare(IExecutionEnvironment o1, IExecutionEnvironment o2) {
String compliance1 = getExecutionEnvironmentCompliance(o1);
String compliance2 = getExecutionEnvironmentCompliance(o2);
int result = JavaCore.compareJavaVersions(compliance1, compliance2);
if (result == 0) {
return o1.getId().compareTo(o2.getId());
}
return result;
}
});
fEnvironments = new TreeSet<>(eeComparator);
fRuleParticipants = new LinkedHashSet<>();
fEnvironmentsMap = new HashMap<>(configs.length);
fAnalyzers = new HashMap<>(configs.length);
Expand Down Expand Up @@ -320,15 +314,14 @@ public int compare(IExecutionEnvironment o1, IExecutionEnvironment o2) {
}
}

List<IExecutionEnvironment> filtered = new LinkedList<>();
SortedSet<IExecutionEnvironment> filtered = new TreeSet<>(eeComparator);
for (IExecutionEnvironment environment : fEnvironments) {
Map<String, String> options = environment.getComplianceOptions();
if (options != null && JavaCore.isJavaSourceVersionSupportedByCompiler(options.get(JavaCore.COMPILER_COMPLIANCE))) {
filtered.add(environment);
}
}
Collections.reverse(filtered);
supportedEnvironments = Collections.unmodifiableList(filtered);
supportedEnvironments = Collections.unmodifiableSortedSet(filtered);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.launching.environments;

import java.util.List;
import java.util.SortedSet;

import org.eclipse.jdt.core.JavaCore;

Expand All @@ -36,15 +36,15 @@ public interface IExecutionEnvironmentsManager {
public IExecutionEnvironment[] getExecutionEnvironments();

/**
* Returns all execution environments supported by Java projects, <b>reverse</b> sorted by their id.
* Returns all execution environments supported by Java projects, sorted by their id.
*
* @see IExecutionEnvironment#getId()
* @see JavaCore#isJavaSourceVersionSupportedByCompiler(String)
*
* @return all registered execution environments sorted by their id
* @since 3.23
*/
public List<IExecutionEnvironment> getSupportedExecutionEnvironments();
public SortedSet<IExecutionEnvironment> getSupportedExecutionEnvironments();

/**
* Returns the execution environment associated with the given
Expand Down

0 comments on commit 125facd

Please sign in to comment.