diff options
| author | Noopur Gupta | 2019-11-20 11:12:10 +0000 |
|---|---|---|
| committer | Noopur Gupta | 2019-11-20 11:12:10 +0000 |
| commit | b9ed701bf33ab911e6b7191828c13c9c8bc73f95 (patch) | |
| tree | e8cb22bb85a52bd37c8af884c9248e8396ca604b | |
| parent | 03b74cad8352a0ca9f047fe40641ab48564fac3d (diff) | |
| download | eclipse.jdt.ui-b9ed701bf33ab911e6b7191828c13c9c8bc73f95.tar.gz eclipse.jdt.ui-b9ed701bf33ab911e6b7191828c13c9c8bc73f95.tar.xz eclipse.jdt.ui-b9ed701bf33ab911e6b7191828c13c9c8bc73f95.zip | |
Change-Id: Ibb53b521705a099b71396d714d4ba675dcd96fb7
5 files changed, 75 insertions, 13 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 93c2211b5f..f28dde810c 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 @@ -8,6 +8,10 @@ * * SPDX-License-Identifier: EPL-2.0 * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Matt Chapman, mpchapman@gmail.com - 89977 Make JDT .java agnostic @@ -77,7 +81,7 @@ public final class JavaModelUtil { */ public static final String VERSION_LATEST; static { - VERSION_LATEST= JavaCore.VERSION_13; // make sure it is not inlined + VERSION_LATEST= JavaCore.VERSION_14; // make sure it is not inlined } public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003; @@ -828,6 +832,10 @@ public final class JavaModelUtil { return !isVersionLessThan(compliance, JavaCore.VERSION_13); } + public static boolean is14OrHigher(String compliance) { + return !isVersionLessThan(compliance, JavaCore.VERSION_14); + } + /** * Checks if the given project or workspace has source compliance 1.5 or greater. * @@ -904,10 +912,38 @@ public final class JavaModelUtil { return is13OrHigher(getSourceCompliance(project)); } + /** + * Checks if the given project or workspace has source compliance 14 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 14 or + * greater. + */ + public static boolean is14OrHigher(IJavaProject project) { + return is14OrHigher(getSourceCompliance(project)); + } + private static String getSourceCompliance(IJavaProject project) { return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE); } - + + /** + * Checks if the given project or workspace has source compliance greater than or equal to the + * latest supported Java version. + * + * @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 greater + * than or equal to the latest supported Java version. + */ + public static boolean isLatestOrHigherJavaVersion(IJavaProject project) { + return isLatestOrHigherJavaVersion(getSourceCompliance(project)); + } + + public static boolean isLatestOrHigherJavaVersion(String compliance) { + return !isVersionLessThan(compliance, JavaCore.latestSupportedJavaVersion()); + } + /** * Checks if the JRE of the given project or workspace default JRE have source compliance 1.5 or * greater. @@ -937,6 +973,8 @@ public final class JavaModelUtil { String version= vMInstall.getJavaVersion(); if (version == null) { return defaultCompliance; + } else if (version.startsWith(JavaCore.VERSION_14)) { + return JavaCore.VERSION_14; } else if (version.startsWith(JavaCore.VERSION_13)) { return JavaCore.VERSION_13; } else if (version.startsWith(JavaCore.VERSION_12)) { @@ -974,10 +1012,12 @@ public final class JavaModelUtil { if (compliance instanceof String) return (String)compliance; } - + // fallback: String desc= executionEnvironment.getId(); - if (desc.indexOf(JavaCore.VERSION_13) != -1) { + if (desc.indexOf(JavaCore.VERSION_14) != -1) { + return JavaCore.VERSION_14; + } else if (desc.indexOf(JavaCore.VERSION_13) != -1) { return JavaCore.VERSION_13; } else if (desc.indexOf(JavaCore.VERSION_12) != -1) { return JavaCore.VERSION_12; 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 2d32d6bad3..229c4c0d48 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 @@ -8,6 +8,10 @@ * * SPDX-License-Identifier: EPL-2.0 * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Jesper S Møller - Bug 529432 - Allow JDT UI to target Java 10 @@ -141,6 +145,7 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { private static final String VERSION_11= JavaCore.VERSION_11; private static final String VERSION_12 = JavaCore.VERSION_12; private static final String VERSION_13 = JavaCore.VERSION_13; + private static final String VERSION_14 = JavaCore.VERSION_14; private static final String VERSION_LATEST = JavaCore.latestSupportedJavaVersion(); private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$ @@ -298,7 +303,7 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { private Composite createComplianceTabContent(Composite folder) { final String[] complianceVersions= new String[] { VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13 }; + VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14 }; final String[] complianceLabels= new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13, PreferencesMessages.ComplianceConfigurationBlock_version14, @@ -311,10 +316,11 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { PreferencesMessages.ComplianceConfigurationBlock_version_11, PreferencesMessages.ComplianceConfigurationBlock_version_12, PreferencesMessages.ComplianceConfigurationBlock_version_13, + PreferencesMessages.ComplianceConfigurationBlock_version_14, }; String[] targetVersions= new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13 }; + VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14 }; String[] targetLabels= new String[] { PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11, PreferencesMessages.ComplianceConfigurationBlock_version11, @@ -330,6 +336,7 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { PreferencesMessages.ComplianceConfigurationBlock_version_11, PreferencesMessages.ComplianceConfigurationBlock_version_12, PreferencesMessages.ComplianceConfigurationBlock_version_13, + PreferencesMessages.ComplianceConfigurationBlock_version_14, }; if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) { targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14); @@ -337,7 +344,7 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { } String[] sourceVersions= new String[] { VERSION_1_3, VERSION_1_4, - VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13 }; + VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14 }; String[] sourceLabels= new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13, PreferencesMessages.ComplianceConfigurationBlock_version14, @@ -350,6 +357,7 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { PreferencesMessages.ComplianceConfigurationBlock_version_11, PreferencesMessages.ComplianceConfigurationBlock_version_12, PreferencesMessages.ComplianceConfigurationBlock_version_13, + PreferencesMessages.ComplianceConfigurationBlock_version_14, }; final ScrolledPageContent sc1 = new ScrolledPageContent(folder); @@ -783,13 +791,13 @@ public class ComplianceConfigurationBlock extends OptionsConfigurationBlock { } } - //TODO: Comment once Java SE 13 has been shipped: - /*String selectedCompliance= getValue(PREF_COMPLIANCE); - if (VERSION_13.equals(selectedCompliance)) { + //TODO: Comment once Java SE 14 has been shipped: + String selectedCompliance= getValue(PREF_COMPLIANCE); + if (VERSION_14.equals(selectedCompliance)) { fJRE50InfoText.setText( "This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."); //$NON-NLS-1$ isVisible= true; - }*/ + } fJRE50InfoText.setVisible(isVisible); fJRE50InfoImage.setImage(isVisible ? image : null); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java index 20ea4a6a84..dd3f352aaa 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java @@ -8,6 +8,10 @@ * * SPDX-License-Identifier: EPL-2.0 * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class @@ -835,6 +839,7 @@ public final class PreferencesMessages extends NLS { public static String ComplianceConfigurationBlock_version_11; public static String ComplianceConfigurationBlock_version_12; public static String ComplianceConfigurationBlock_version_13; + public static String ComplianceConfigurationBlock_version_14; public static String ComplianceConfigurationBlock_versionCLDC11; public static String ComplianceConfigurationBlock_src_greater_compliance; public static String ComplianceConfigurationBlock_classfile_greater_compliance; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties index ffb2b4fe7b..d13c00521b 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties @@ -8,6 +8,10 @@ # # SPDX-License-Identifier: EPL-2.0 # +# This is an implementation of an early-draft specification developed under the Java +# Community Process (JCP) and is made available for testing and evaluation purposes +# only. The code is not compatible with any specification of the JCP. +# # Contributors: # IBM Corporation - initial API and implementation # John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class @@ -590,6 +594,7 @@ ComplianceConfigurationBlock_version10=10 ComplianceConfigurationBlock_version_11=11 ComplianceConfigurationBlock_version_12=12 ComplianceConfigurationBlock_version_13=13 +ComplianceConfigurationBlock_version_14=14 (BETA) ComplianceConfigurationBlock_versionCLDC11=CLDC 1.1 ComplianceConfigurationBlock_needsbuild_title=Compiler Settings Changed diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java index d6b204e710..de216ae20a 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java @@ -8,6 +8,10 @@ * * SPDX-License-Identifier: EPL-2.0 * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -219,7 +223,7 @@ public class PreviewFeaturesSubProcessor { public static void getNeedHigherComplianceProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { String[] args= problem.getProblemArguments(); if (args != null && args.length > 0) { - String supportedVersion= JavaCore.VERSION_13; + String supportedVersion= JavaCore.latestSupportedJavaVersion(); String arg= args[1]; if (arg.equals(supportedVersion)) { ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, true, supportedVersion); @@ -239,7 +243,7 @@ public class PreviewFeaturesSubProcessor { public static boolean isPreviewFeatureEnabled(IJavaProject javaProject) { boolean isPreviewFeatureEnabled= false; - if (javaProject != null && JavaModelUtil.is13OrHigher(javaProject)) { + if (javaProject != null && JavaModelUtil.isLatestOrHigherJavaVersion(javaProject)) { IProject project= javaProject.getProject(); Key[] keys= ComplianceConfigurationBlock.getKeys(true); boolean hasProjectSpecificOptions= OptionsConfigurationBlock.hasProjectSpecificOptions(project, keys, null); |
