Skip to content

Commit

Permalink
Adjust to JavaCore.defaultRootModules deprecation
Browse files Browse the repository at this point in the history
Use the new method that filters based on the release. If release option
is not set, use target and if it's not there too use the latest version.
  • Loading branch information
akurtakov committed Jan 21, 2025
1 parent 8fee6c8 commit 75a2cab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 GK Software SE, and others.
* Copyright (c) 2019, 2025 GK Software SE, and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.wizards.buildpaths;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -26,8 +27,6 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import java.text.MessageFormat;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.events.SelectionListener;
Expand Down Expand Up @@ -347,7 +346,14 @@ protected void scanModules() {
}
try {
if (fCurrJProject.getModuleDescription() == null) { // cache default roots when compiling the unnamed module:
fAllDefaultSystemModules= closure(JavaCore.defaultRootModules(Arrays.asList(fAllSystemRoots)));
String release = fCurrJProject.getOption(JavaCore.COMPILER_RELEASE, true);
if (release == null) {
release = fCurrJProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true);
}
if (release == null) {
release = JavaCore.latestSupportedJavaVersion();
}
fAllDefaultSystemModules= closure(JavaCore.defaultRootModules(Arrays.asList(fAllSystemRoots), release));
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2020 GK Software SE, and others.
* Copyright (c) 2017, 2025 GK Software SE, and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -799,11 +799,18 @@ private List<String> defaultIncludedModuleNamesForUnnamedModule() {
if (fJavaElements != null) {
List<IPackageFragmentRoot> roots= new ArrayList<>();
for (IJavaElement element : fJavaElements) {
if (element instanceof IPackageFragmentRoot) {
roots.add((IPackageFragmentRoot) element);
if (element instanceof IPackageFragmentRoot el) {
roots.add(el);
}
}
return JavaCore.defaultRootModules(roots);
String release = fJavaElements[0].getJavaProject().getOption(JavaCore.COMPILER_RELEASE, true);
if (release == null) {
release = fJavaElements[0].getJavaProject().getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true);
}
if (release == null) {
release = JavaCore.latestSupportedJavaVersion();
}
return JavaCore.defaultRootModules(roots, release);
}
return Collections.emptyList();
}
Expand Down

0 comments on commit 75a2cab

Please sign in to comment.