From 387b7cdc8c7fa6e585e01e9f4bb1803100f4ff99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 8 Jan 2025 11:43:08 +0200 Subject: [PATCH] Final bits of pre 1.8 support removal in JavaModelUtils Removing non reachable code. --- .../javadoc/CoreJavaDocLocations.java | 4 ++-- .../internal/corext/util/JavaModelUtil.java | 19 ------------------- .../buildpath/JUnitContainerWizardPage.java | 14 +------------- .../jdt/internal/junit/ui/JUnitMessages.java | 6 +----- .../junit/ui/JUnitMessages.properties | 4 +--- ...ExternalNullAnnotationChangeProposals.java | 10 +--------- .../ComplianceConfigurationBlock.java | 19 +++++-------------- 7 files changed, 11 insertions(+), 65 deletions(-) diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/internal/javadoc/CoreJavaDocLocations.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/internal/javadoc/CoreJavaDocLocations.java index 75d8a2073e7..7a16cc9b660 100644 --- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/internal/javadoc/CoreJavaDocLocations.java +++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/internal/javadoc/CoreJavaDocLocations.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -404,7 +404,7 @@ private static boolean is1d8Or9(IJavaProject javaProject) { IVMInstall install= JavaRuntime.getVMInstall(javaProject); if (install instanceof AbstractVMInstall) { String vmver= ((AbstractVMInstall) install).getJavaVersion(); - is1d8Or9= JavaModelUtil.is1d8OrHigher(vmver) && !JavaModelUtil.is10OrHigher(vmver); + is1d8Or9= !JavaModelUtil.is10OrHigher(vmver); } else { is1d8Or9= JavaCore.compareJavaVersions(compliance, JavaCore.VERSION_1_8) == 0 || JavaCore.compareJavaVersions(compliance, JavaCore.VERSION_9) == 0; } 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 20bbda68c04..64edadc7975 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 @@ -787,14 +787,6 @@ public static boolean isVersionLessThan(String version1, String version2) { return JavaCore.compareJavaVersions(version1, version2) < 0; } - public static boolean is1d7OrHigher(String compliance) { - return !isVersionLessThan(compliance, JavaCore.VERSION_1_7); - } - - public static boolean is1d8OrHigher(String compliance) { - return !isVersionLessThan(compliance, JavaCore.VERSION_1_8); - } - public static boolean is9OrHigher(String compliance) { return !isVersionLessThan(compliance, JavaCore.VERSION_9); } @@ -855,17 +847,6 @@ public static boolean is23OrHigher(String compliance) { return !isVersionLessThan(compliance, JavaCore.VERSION_23); } - /** - * Checks if the given project or workspace has source compliance 1.8 or greater. - * - * @param project the project to test or null to test the workspace settings - * @return true if the given project or workspace has source compliance 1.8 or - * greater. - */ - public static boolean is1d8OrHigher(IJavaProject project) { - return is1d8OrHigher(getSourceCompliance(project)); - } - /** * Checks if the given project or workspace has source compliance 9 or greater. * diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java index b0928a0cc4f..70105753695 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2017 IBM Corporation and others. + * Copyright (c) 2006, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -37,12 +37,10 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.junit.BasicElementLabels; import org.eclipse.jdt.internal.junit.ui.JUnitMessages; import org.eclipse.jdt.internal.junit.util.ExceptionHandler; import org.eclipse.jdt.internal.junit.util.JUnitStatus; -import org.eclipse.jdt.internal.junit.util.JUnitStubUtility; import org.eclipse.jdt.ui.JavaElementLabels; import org.eclipse.jdt.ui.wizards.IClasspathContainerPage; @@ -55,7 +53,6 @@ public class JUnitContainerWizardPage extends NewElementWizardPage implements IClasspathContainerPage, IClasspathContainerPageExtension { - private IJavaProject fProject; private IClasspathEntry fContainerEntryResult; private Combo fVersionCombo; private Text fResolvedPath; @@ -193,14 +190,6 @@ protected void doSelectionChanged() { if (libEntry == null) { status.setError(JUnitMessages.JUnitContainerWizardPage_error_version_not_available); - } else if (JUnitCore.JUNIT4_CONTAINER_PATH.equals(containerPath)) { - if (fProject != null && !JUnitStubUtility.is50OrHigher(fProject)) { - status.setWarning(JUnitMessages.JUnitContainerWizardPage_warning_java5_required); - } - } else if (JUnitCore.JUNIT5_CONTAINER_PATH.equals(containerPath)) { - if (fProject != null && !JavaModelUtil.is1d8OrHigher(fProject)) { - status.setWarning(JUnitMessages.JUnitContainerWizardPage_warning_java8_required); - } } fContainerEntryResult= JavaCore.newContainerEntry(containerPath); @@ -231,7 +220,6 @@ private String getPathLabel(IPath path) { @Override public void initialize(IJavaProject project, IClasspathEntry[] currentEntries) { - fProject= project; } } diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java index ea93b2809d1..306d679b2f0 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -98,10 +98,6 @@ public final class JUnitMessages extends NLS { public static String JUnitContainerWizardPage_source_not_found; - public static String JUnitContainerWizardPage_warning_java5_required; - - public static String JUnitContainerWizardPage_warning_java8_required; - public static String JUnitContainerWizardPage_wizard_description; public static String JUnitContainerWizardPage_wizard_title; diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties index ef49bee3bc5..8d4e1dcee71 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2020 IBM Corporation and others. +# Copyright (c) 2000, 2025 IBM Corporation and others. # # This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 @@ -54,8 +54,6 @@ JUnitPreferencePage_invalidstepfilterreturnescape=Invalid stack filter. Press En JUnitPreferencePage_addtypedialog_title=Add Class to Stack Filters JUnitPreferencePage_addtypedialog_message=&Select a class to filter in the failure stack trace: JUnitPreferencePage_addtypedialog_error_message=Could not open type selection dialog for stack filters. -JUnitContainerWizardPage_warning_java5_required=JUnit 4 requires a Java 5 project -JUnitContainerWizardPage_warning_java8_required=JUnit 5 requires a Java 8 project JUnitPreferencePage_addpackagedialog_title=Add Packages to Stack Filters JUnitPreferencePage_addpackagedialog_message=&Select a package to filter in the failure stack trace: JUnitPreferencePage_enableassertionscheckbox_label=Add '-ea' to VM arguments when creating a new &JUnit launch configuration diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java index a49ba368664..99681eea7cf 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2019 GK Software AG and others. + * Copyright (c) 2015, 2025 GK Software AG and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -79,7 +79,6 @@ import org.eclipse.jdt.core.util.ExternalAnnotationUtil.MergeStrategy; import org.eclipse.jdt.internal.corext.dom.ASTNodes; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; @@ -468,13 +467,6 @@ public static void collectExternalAnnotationProposals(ICompilationUnit cu, ASTNo rendererNullable.addDimension(i == outerExtraDims); rendererRemove.addDimension(i == outerExtraDims); } - boolean useJava8= JavaModelUtil.is1d8OrHigher(javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); - if (!useJava8 && (outer != inner || outerExtraDims > 0)) { // below 1.8 we can only annotate the top type (not type parameter) - // still need to handle ParameterizedType (outer) with SimpleType (inner) - if ((outer.getNodeType() != ASTNode.PARAMETERIZED_TYPE) - || (inner.getParent() != outer)) - return; - } try { if (outer instanceof Type) { if (extraDims == 0 && !annotateVarargs) { 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 ed155cdebe3..40df11031af 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -747,18 +747,10 @@ private void updateReleaseOptionStatus() { boolean isJREUnsupportedAndGreater= isJREVersionUnsupportedAndGreater(version, compilerCompliance); if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance if (JavaModelUtil.is9OrHigher(compilerCompliance)) { - if (!JavaModelUtil.isVersionLessThan(compliance, compilerCompliance) - || ( JavaModelUtil.is12OrHigher(compilerCompliance)) - && !JavaModelUtil.is1d7OrHigher(compliance)) { - fCompilerReleaseCheck.setEnabled(false); - fCompilerReleaseCheck.setSelection(false); - setValue(PREF_RELEASE, DISABLED); + if (fProject != null) { + fCompilerReleaseCheck.setEnabled(checkValue(INTR_COMPLIANCE_FOLLOWS_EE, USER_CONF) || checkValue(INTR_COMPLIANCE_FOLLOWS_EE, DISABLED)); } else { - if (fProject != null) { - fCompilerReleaseCheck.setEnabled(checkValue(INTR_COMPLIANCE_FOLLOWS_EE, USER_CONF) || checkValue(INTR_COMPLIANCE_FOLLOWS_EE, DISABLED)); - } else { - fCompilerReleaseCheck.setEnabled(true); - } + fCompilerReleaseCheck.setEnabled(true); } updateComplianceEnableSourceTargetState(); } else { @@ -1015,8 +1007,7 @@ private void updateRememberedComplianceOption(Key prefKey, int idx, boolean enab } private void updateStoreMethodParamNamesEnableState() { - String target= getValue(PREF_CODEGEN_TARGET_PLATFORM); - boolean enabled= JavaModelUtil.is1d8OrHigher(target); + boolean enabled= true; Button checkBox= getCheckBox(PREF_CODEGEN_METHOD_PARAMETERS_ATTR); boolean wasCheckBoxEnabled= checkBox.isEnabled(); checkBox.setEnabled(enabled);