From 11901207db25ce7aea6b339595c15a95b1ef2e51 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Tue, 6 Aug 2024 20:02:24 +0200 Subject: [PATCH] Use new return-type of JC.getAllJavaSourceVersionsSupportedByCompiler() Leverage the new return-type of JavaCore.getAllJavaSourceVersionsSupportedByCompiler(), adjusted in https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2770 --- .../org/eclipse/jdt/internal/corext/util/JavaModelUtil.java | 4 ++-- .../ui/preferences/ComplianceConfigurationBlock.java | 6 +++--- .../eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java index 9f5d12ffc64..866a7dea306 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java @@ -1155,7 +1155,7 @@ public static String getExecutionEnvironmentCompliance(IExecutionEnvironment exe if(JavaCore.isJavaSourceVersionSupportedByCompiler(compliance)) { return compliance; } - return JavaCore.getFirstJavaSourceVersionSupportedByCompiler(); + return JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first(); } } @@ -1192,7 +1192,7 @@ public static String getExecutionEnvironmentCompliance(IExecutionEnvironment exe } else if (desc.indexOf(JavaCore.VERSION_1_8) != -1) { return JavaCore.VERSION_1_8; } - return JavaCore.getFirstJavaSourceVersionSupportedByCompiler(); + return JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first(); } /** diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java index 1d0cb258e61..e084acca408 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java @@ -442,7 +442,7 @@ public void widgetSelected(SelectionEvent e) { fJRE50InfoText= new Link(infoComposite, SWT.WRAP); fJRE50InfoText.setFont(composite.getFont()); // set a text: not the real one, just for layouting - String versionLabel= getVersionLabel(JavaCore.getFirstJavaSourceVersionSupportedByCompiler()); + String versionLabel= getVersionLabel(JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first()); fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, new String[] { versionLabel, versionLabel })); fJRE50InfoText.setVisible(false); fJRE50InfoText.addSelectionListener(new SelectionListener() { @@ -1170,8 +1170,8 @@ private void updateComplianceDefaultSettings(boolean rememberOld, String oldComp reportPreview= WARNING; assertAsId= ERROR; enumAsId= ERROR; - source= JavaCore.getFirstJavaSourceVersionSupportedByCompiler(); - target= JavaCore.getFirstJavaSourceVersionSupportedByCompiler(); + source= JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first(); + target= JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first(); } } } else { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java index 81128cbbc8f..e7f16bdccba 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewJavaProjectWizardPageOne.java @@ -474,8 +474,8 @@ private void initializeJvmFields () { fInstalledJVMs= getWorkspaceJREs(); Arrays.sort(fInstalledJVMs, (i0, i1) -> { if (i1 instanceof IVMInstall2 && i0 instanceof IVMInstall2) { - String cc0= JavaModelUtil.getCompilerCompliance((IVMInstall2) i0, JavaCore.getFirstJavaSourceVersionSupportedByCompiler()); - String cc1= JavaModelUtil.getCompilerCompliance((IVMInstall2) i1, JavaCore.getFirstJavaSourceVersionSupportedByCompiler()); + String cc0= JavaModelUtil.getCompilerCompliance((IVMInstall2) i0, JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first()); + String cc1= JavaModelUtil.getCompilerCompliance((IVMInstall2) i1, JavaCore.getAllJavaSourceVersionsSupportedByCompiler().first()); int result= JavaCore.compareJavaVersions(cc1, cc0); if (result != 0) return result;