Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final bits of pre 1.8 support removal in JavaModelUtils #1911

Merged
merged 1 commit into from
Jan 8, 2025
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
@@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 <code>null</code> to test the workspace settings
* @return <code>true</code> 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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -55,7 +53,6 @@

public class JUnitContainerWizardPage extends NewElementWizardPage implements IClasspathContainerPage, IClasspathContainerPageExtension {

private IJavaProject fProject;
private IClasspathEntry fContainerEntryResult;
private Combo fVersionCombo;
private Text fResolvedPath;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -231,7 +220,6 @@ private String getPathLabel(IPath path) {

@Override
public void initialize(IJavaProject project, IClasspathEntry[] currentEntries) {
fProject= project;
}

}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Loading