Merge remote-tracking branch 'origin/master' into BETA_JAVA11
Change-Id: Ib70e55a6e1f26838206b5f67b207bd2c929142b4
diff --git a/org.eclipse.jdt.astview/META-INF/MANIFEST.MF b/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
index 1457460..f340bf2 100644
--- a/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
@@ -11,7 +11,7 @@
Export-Package: org.eclipse.jdt.astview;x-internal:=true,
org.eclipse.jdt.astview.views;x-internal:=true
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.jdt.core;bundle-version="[3.14.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.15.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.14.0,4.0.0)",
org.eclipse.ui.ide,
org.eclipse.ui.views,
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java
index 0d36e72..2838a71 100644
--- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java
+++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTView.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -126,8 +130,14 @@
public class ASTView extends ViewPart implements IShowInSource, IShowInTargetList {
- static final int JLS_LATEST= AST.JLS10;
+ static final int JLS_LATEST= AST.JLS11;
+
+ private static final int JLS11= AST.JLS11;
+ /**
+ * @deprecated to get rid of deprecation warnings in code
+ */
+ @Deprecated
private static final int JLS10= AST.JLS10;
/**
@@ -460,6 +470,7 @@
case JLS8:
case JLS9:
case JLS10:
+ case JLS11:
fCurrentASTLevel= level;
}
} catch (NumberFormatException e) {
@@ -1088,6 +1099,7 @@
new ASTLevelToggle("AST Level &8 (1.8)", JLS8), //$NON-NLS-1$
new ASTLevelToggle("AST Level &9 (9)", JLS9), //$NON-NLS-1$
new ASTLevelToggle("AST Level 1&0 (10)", JLS10), //$NON-NLS-1$
+ new ASTLevelToggle("AST Level 1&1 (11)", JLS11), //$NON-NLS-1$
};
fAddToTrayAction= new Action() {
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/IASTSharedValues.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/IASTSharedValues.java
index 904c0f7..9bc6432 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/IASTSharedValues.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/IASTSharedValues.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -18,7 +22,7 @@
* This value is subject to change with every release. JDT-UI-internal code typically supports
* the latest available {@link AST#apiLevel() AST level} exclusively.
*/
- public static final int SHARED_AST_LEVEL= AST.JLS10;
+ public static final int SHARED_AST_LEVEL= AST.JLS11;
public static final boolean SHARED_AST_STATEMENT_RECOVERY= true;
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 c1980b0..cd3daca 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
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
@@ -74,7 +78,7 @@
*/
public static final String VERSION_LATEST;
static {
- VERSION_LATEST= JavaCore.VERSION_10; // make sure it is not inlined
+ VERSION_LATEST= JavaCore.VERSION_11; // make sure it is not inlined
}
public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003;
@@ -813,6 +817,10 @@
return !isVersionLessThan(compliance, JavaCore.VERSION_10);
}
+ public static boolean is11OrHigher(String compliance) {
+ return !isVersionLessThan(compliance, JavaCore.VERSION_11);
+ }
+
/**
* Checks if the given project or workspace has source compliance 1.5 or greater.
*
@@ -865,6 +873,16 @@
return is10OrHigher(getSourceCompliance(project));
}
+ /**
+ * Checks if the given project or workspace has source compliance 11 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 11 or greater.
+ */
+ public static boolean is11OrHigher(IJavaProject project) {
+ return is11OrHigher(getSourceCompliance(project));
+ }
+
private static String getSourceCompliance(IJavaProject project) {
return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE);
}
@@ -898,6 +916,8 @@
String version= vMInstall.getJavaVersion();
if (version == null) {
return defaultCompliance;
+ } else if (version.startsWith(JavaCore.VERSION_11)) {
+ return JavaCore.VERSION_11;
} else if (version.startsWith(JavaCore.VERSION_10)) {
return JavaCore.VERSION_10;
} else if (version.startsWith(JavaCore.VERSION_9)) {
@@ -932,7 +952,9 @@
// fallback:
String desc= executionEnvironment.getId();
- if (desc.indexOf(JavaCore.VERSION_10) != -1) {
+ if (desc.indexOf(JavaCore.VERSION_11) != -1) {
+ return JavaCore.VERSION_11;
+ } else if (desc.indexOf(JavaCore.VERSION_10) != -1) {
return JavaCore.VERSION_10;
} else if (desc.indexOf(JavaCore.VERSION_9) != -1) {
return JavaCore.VERSION_9;
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit4TestFinder.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit4TestFinder.java
index d4b7997..2ee483d 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit4TestFinder.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit4TestFinder.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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:
* David Saff (saff@mit.edu) - initial API and implementation
* (bug 102632: [JUnit] Support for JUnit 4.)
@@ -205,7 +209,7 @@
if (CoreTestSearchEngine.hasSuiteMethod(type)) { // since JUnit 4.3.1
return true;
}
- ASTParser parser= ASTParser.newParser(AST.JLS10);
+ ASTParser parser= ASTParser.newParser(AST.JLS11);
/* TODO: When bug 156352 is fixed:
parser.setProject(type.getJavaProject());
IBinding[] bindings= parser.createBindings(new IJavaElement[] { type }, monitor);
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit5TestFinder.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit5TestFinder.java
index bde17a0..f3ec73e 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit5TestFinder.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnit5TestFinder.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -254,7 +258,7 @@
if (CoreTestSearchEngine.hasSuiteMethod(type)) { // since JUnit 4.3.1
return true;
}
- ASTParser parser= ASTParser.newParser(AST.JLS10);
+ ASTParser parser= ASTParser.newParser(AST.JLS11);
if (type.getCompilationUnit() != null) {
parser.setSource(type.getCompilationUnit());
} else if (!isAvailable(type.getSourceRange())) { // class file with no source
diff --git a/org.eclipse.jdt.ui.tests/test.xml b/org.eclipse.jdt.ui.tests/test.xml
index 805b684..3b45bd8 100644
--- a/org.eclipse.jdt.ui.tests/test.xml
+++ b/org.eclipse.jdt.ui.tests/test.xml
@@ -45,7 +45,7 @@
<delete dir="${jdt-folder}" quiet="true"/>
<condition property="java9vmargs" value="--add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.localedata/sun.util.resources.cldr.provider=ALL-UNNAMED --add-opens jdk.localedata/sun.util.resources.provider=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/jdk.internal.math=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED" else="">
- <matches pattern="^(9|10)$" string="${ant.java.version}" />
+ <matches pattern="^(9|10|11)$" string="${ant.java.version}" />
</condition>
<ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java
index f553a8e..b8e2117 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java
@@ -1612,7 +1612,7 @@
assertNoErrors(context);
List<IJavaCompletionProposal> proposals= collectAssists(context, false);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
assertCorrectLabels(proposals);
buf= new StringBuffer();
@@ -2042,7 +2042,7 @@
assertNoErrors(context);
List<IJavaCompletionProposal> proposals= collectAssists(context, false);
- assertNumberOfProposals(proposals, 3);
+ assertNumberOfProposals(proposals, 4);
assertCorrectLabels(proposals);
buf= new StringBuffer();
@@ -2615,7 +2615,7 @@
assertNoErrors(context);
proposals= collectAssists(context, false);
- assertNumberOfProposals(proposals, 2);
+ assertNumberOfProposals(proposals, 3);
assertCorrectLabels(proposals);
assertProposalDoesNotExist(proposals, CorrectionMessages.QuickAssistProcessor_add_inferred_lambda_parameter_types);
}
@@ -4592,7 +4592,7 @@
AssistContext context= getCorrectionContext(cu, offset, 0);
assertNoErrors(context);
List<IJavaCompletionProposal> proposals= collectAssists(context, false);
- assertNumberOfProposals(proposals, 4);
+ assertNumberOfProposals(proposals, 5);
assertCorrectLabels(proposals);
assertProposalDoesNotExist(proposals, CorrectionMessages.QuickAssistProcessor_removeParenthesesInLambda);
}
@@ -4613,7 +4613,7 @@
AssistContext context= getCorrectionContext(cu, offset, 0);
assertNoErrors(context);
List<IJavaCompletionProposal> proposals= collectAssists(context, false);
- assertNumberOfProposals(proposals, 5);
+ assertNumberOfProposals(proposals, 6);
assertCorrectLabels(proposals);
assertProposalDoesNotExist(proposals, CorrectionMessages.QuickAssistProcessor_removeParenthesesInLambda);
}
diff --git a/org.eclipse.jdt.ui/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui/META-INF/MANIFEST.MF
index 0d8c38d..9926ec8 100644
--- a/org.eclipse.jdt.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.ui/META-INF/MANIFEST.MF
@@ -117,7 +117,7 @@
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.2.200,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.14.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.15.0,4.0.0)",
org.eclipse.search;bundle-version="[3.10.0,4.0.0)",
org.eclipse.debug.core;bundle-version="[3.10.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.11.0,4.0.0)",
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 ad78a96..bbcb4ef 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
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
@@ -129,6 +133,7 @@
private static final String VERSION_1_8= JavaCore.VERSION_1_8;
private static final String VERSION_9= JavaCore.VERSION_9;
private static final String VERSION_10= JavaCore.VERSION_10;
+ private static final String VERSION_11= JavaCore.VERSION_11;
private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$
private static final String ERROR= JavaCore.ERROR;
@@ -271,7 +276,7 @@
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_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11 };
final String[] complianceLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_version13,
PreferencesMessages.ComplianceConfigurationBlock_version14,
@@ -281,10 +286,11 @@
PreferencesMessages.ComplianceConfigurationBlock_version18,
PreferencesMessages.ComplianceConfigurationBlock_version9,
PreferencesMessages.ComplianceConfigurationBlock_version10,
+ PreferencesMessages.ComplianceConfigurationBlock_version_11,
};
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_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11 };
String[] targetLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11,
PreferencesMessages.ComplianceConfigurationBlock_version11,
@@ -297,6 +303,7 @@
PreferencesMessages.ComplianceConfigurationBlock_version18,
PreferencesMessages.ComplianceConfigurationBlock_version9,
PreferencesMessages.ComplianceConfigurationBlock_version10,
+ PreferencesMessages.ComplianceConfigurationBlock_version_11,
};
if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) {
targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14);
@@ -304,7 +311,7 @@
}
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_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11 };
String[] sourceLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_version13,
PreferencesMessages.ComplianceConfigurationBlock_version14,
@@ -314,6 +321,7 @@
PreferencesMessages.ComplianceConfigurationBlock_version18,
PreferencesMessages.ComplianceConfigurationBlock_version9,
PreferencesMessages.ComplianceConfigurationBlock_version10,
+ PreferencesMessages.ComplianceConfigurationBlock_version_11,
};
final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
@@ -689,6 +697,14 @@
}
}
+ //TODO: Remove once Java SE 11 has been shipped:
+ String selectedCompliance= getValue(PREF_COMPLIANCE);
+ if (VERSION_11.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);
fJRE50InfoImage.getParent().layout();
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 28e5439..bca70f1 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
@@ -4,6 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * 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
@@ -820,6 +824,7 @@
public static String ComplianceConfigurationBlock_version18;
public static String ComplianceConfigurationBlock_version9;
public static String ComplianceConfigurationBlock_version10;
+ public static String ComplianceConfigurationBlock_version_11;
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 a18ee76..4a56fe7 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
@@ -5,6 +5,10 @@
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
+# 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
@@ -579,6 +583,7 @@
ComplianceConfigurationBlock_version18=1.8
ComplianceConfigurationBlock_version9=9
ComplianceConfigurationBlock_version10=10
+ComplianceConfigurationBlock_version_11=11 (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/CorrectionMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
index 94c9d79..474b0fc 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
@@ -289,6 +289,11 @@
public static String QuickAssistProcessor_splitdeclaration_description;
public static String QuickAssistProcessor_joindeclaration_description;
public static String QuickAssistProcessor_add_inferred_lambda_parameter_types;
+ public static String QuickAssistProcessor_replace_var_with_inferred_lambda_parameter_types;
+ public static String QuickAssistProcessor_add_var_lambda_parameter_types;
+ public static String QuickAssistProcessor_replace_inferred_with_var_lambda_parameter_types;
+ public static String QuickAssistProcessor_remove_inferred_lambda_parameter_types;
+ public static String QuickAssistProcessor_remove_var_lambda_parameter_types;
public static String QuickAssistProcessor_addfinallyblock_description;
public static String QuickAssistProcessor_addelseblock_description;
public static String QuickAssistProcessor_addParenthesesInLambda;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
index c00ab77..d3671ba 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
@@ -350,6 +350,11 @@
QuickAssistProcessor_extract_to_constant_description=Extract to constant
QuickAssistProcessor_joindeclaration_description=Join variable declaration
QuickAssistProcessor_add_inferred_lambda_parameter_types=Add inferred lambda parameter types
+QuickAssistProcessor_replace_var_with_inferred_lambda_parameter_types= Replace var types with inferred lambda parameter types
+QuickAssistProcessor_add_var_lambda_parameter_types=Add var lambda parameter types
+QuickAssistProcessor_replace_inferred_with_var_lambda_parameter_types=Replace inferred types with var lambda parameter types
+QuickAssistProcessor_remove_inferred_lambda_parameter_types=Remove inferred lambda parameter types
+QuickAssistProcessor_remove_var_lambda_parameter_types=Remove var lambda parameter types
QuickAssistProcessor_addfinallyblock_description=Add finally block
QuickAssistProcessor_addelseblock_description=Add else block
QuickAssistProcessor_addParenthesesInLambda=Add parentheses around lambda parameter
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
index 19fe0fa..172e852 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
@@ -161,6 +161,7 @@
import org.eclipse.jdt.internal.corext.refactoring.code.ExtractTempRefactoring;
import org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring;
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring;
+import org.eclipse.jdt.internal.corext.refactoring.structure.ImportRemover;
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
@@ -183,6 +184,7 @@
import org.eclipse.jdt.internal.ui.fix.TypeParametersCleanUp;
import org.eclipse.jdt.internal.ui.fix.VariableDeclarationCleanUp;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jdt.internal.ui.text.correction.proposals.ASTRewriteRemoveImportsCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.AssignToVariableAssistProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.GenerateForLoopAssistProposal;
@@ -256,6 +258,8 @@
|| getChangeLambdaBodyToBlockProposal(context, coveringNode, null)
|| getChangeLambdaBodyToExpressionProposal(context, coveringNode, null)
|| getAddInferredLambdaParameterTypes(context, coveringNode, null)
+ || getAddVarLambdaParameterTypes(context, coveringNode, null)
+ || getRemoveVarOrInferredLambdaParameterTypes(context, coveringNode, null)
|| getConvertMethodReferenceToLambdaProposal(context, coveringNode, null)
|| getConvertLambdaToMethodReferenceProposal(context, coveringNode, null)
|| getFixParenthesesInLambdaExpression(context, coveringNode, null)
@@ -311,6 +315,8 @@
getChangeLambdaBodyToBlockProposal(context, coveringNode, resultingCollections);
getChangeLambdaBodyToExpressionProposal(context, coveringNode, resultingCollections);
getAddInferredLambdaParameterTypes(context, coveringNode, resultingCollections);
+ getAddVarLambdaParameterTypes(context, coveringNode, resultingCollections);
+ getRemoveVarOrInferredLambdaParameterTypes(context, coveringNode, resultingCollections);
getConvertMethodReferenceToLambdaProposal(context, coveringNode, resultingCollections);
getConvertLambdaToMethodReferenceProposal(context, coveringNode, resultingCollections);
getFixParenthesesInLambdaExpression(context, coveringNode, resultingCollections);
@@ -1367,11 +1373,35 @@
public static boolean getAddInferredLambdaParameterTypes(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) {
LambdaExpression lambda;
+ boolean isvarTypeSingleVariableDeclaration= false;
if (covering instanceof LambdaExpression) {
lambda= (LambdaExpression) covering;
} else if (covering.getLocationInParent() == VariableDeclarationFragment.NAME_PROPERTY &&
((VariableDeclarationFragment) covering.getParent()).getLocationInParent() == LambdaExpression.PARAMETERS_PROPERTY) {
lambda= (LambdaExpression) covering.getParent().getParent();
+ } else if (covering.getLocationInParent() == SingleVariableDeclaration.NAME_PROPERTY &&
+ ((SingleVariableDeclaration) covering.getParent()).getLocationInParent() == LambdaExpression.PARAMETERS_PROPERTY) {
+ CompilationUnit astRoot= context.getASTRoot();
+ IJavaElement root= astRoot.getJavaElement();
+ ASTNode parent= covering.getParent();
+ if (parent == null || root == null) {
+ return false;
+ }
+ IJavaProject javaProject= root.getJavaProject();
+ if (javaProject == null) {
+ return false;
+ }
+ if (!JavaModelUtil.is11OrHigher(javaProject)) {
+ return false;
+ } else {
+ SingleVariableDeclaration svDecl= (SingleVariableDeclaration) parent;
+ if (svDecl.getType() != null && svDecl.getType().isVar()) {
+ lambda= (LambdaExpression) covering.getParent().getParent();
+ isvarTypeSingleVariableDeclaration= true;
+ } else {
+ return false;
+ }
+ }
} else {
return false;
}
@@ -1381,7 +1411,7 @@
if (noOfLambdaParams == 0)
return false;
- if (lambdaParameters.get(0) instanceof SingleVariableDeclaration)
+ if (lambdaParameters.get(0) instanceof SingleVariableDeclaration && !isvarTypeSingleVariableDeclaration)
return false;
IMethodBinding methodBinding= lambda.resolveMethodBinding();
@@ -1409,6 +1439,9 @@
// add proposal
String label= CorrectionMessages.QuickAssistProcessor_add_inferred_lambda_parameter_types;
+ if (isvarTypeSingleVariableDeclaration) {
+ label= CorrectionMessages.QuickAssistProcessor_replace_var_with_inferred_lambda_parameter_types;
+ }
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_INFERRED_LAMBDA_PARAMETER_TYPES, image);
proposal.setImportRewrite(importRewrite);
@@ -1416,6 +1449,191 @@
return true;
}
+ public static boolean getAddVarLambdaParameterTypes(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) {
+ CompilationUnit astRoot= context.getASTRoot();
+ IJavaElement root= astRoot.getJavaElement();
+ ASTNode parent= covering.getParent();
+ if (parent == null || root == null) {
+ return false;
+ }
+ IJavaProject javaProject= root.getJavaProject();
+ if (javaProject == null) {
+ return false;
+ }
+ if (!JavaModelUtil.is11OrHigher(javaProject)) {
+ return false;
+ }
+
+ LambdaExpression lambda;
+ boolean isvarTypeSingleVariableDeclaration= false;
+ if (covering instanceof LambdaExpression) {
+ lambda= (LambdaExpression) covering;
+ } else if (covering.getLocationInParent() == VariableDeclarationFragment.NAME_PROPERTY &&
+ ((VariableDeclarationFragment) parent).getLocationInParent() == LambdaExpression.PARAMETERS_PROPERTY) {
+ lambda= (LambdaExpression) covering.getParent().getParent();
+ } else {
+ if (covering.getLocationInParent() == SingleVariableDeclaration.NAME_PROPERTY &&
+ ((SingleVariableDeclaration) parent).getLocationInParent() == LambdaExpression.PARAMETERS_PROPERTY) {
+ SingleVariableDeclaration svDecl= (SingleVariableDeclaration) parent;
+ if (svDecl.getType() != null && !svDecl.getType().isVar()) {
+ lambda= (LambdaExpression) covering.getParent().getParent();
+ isvarTypeSingleVariableDeclaration= true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ List<VariableDeclaration> lambdaParameters= lambda.parameters();
+ int noOfLambdaParams= lambdaParameters.size();
+ if (noOfLambdaParams == 0)
+ return false;
+
+ if (lambdaParameters.get(0) instanceof SingleVariableDeclaration && !isvarTypeSingleVariableDeclaration)
+ return false;
+
+ IMethodBinding methodBinding= lambda.resolveMethodBinding();
+ if (methodBinding == null)
+ return false;
+
+ if (resultingCollections == null)
+ return true;
+
+ String VAR_TYPE= "var"; //$NON-NLS-1$
+ AST ast= lambda.getAST();
+ ASTRewrite rewrite= ASTRewrite.create(ast);
+
+ ImportRemover remover= new ImportRemover(context.getCompilationUnit().getJavaProject(), context.getASTRoot());
+
+ ImportRewrite importRewrite= StubUtility.createImportRewrite(context.getASTRoot(), true);
+
+ rewrite.set(lambda, LambdaExpression.PARENTHESES_PROPERTY, Boolean.valueOf(true), null);
+ for (int i= 0; i < noOfLambdaParams; i++) {
+ VariableDeclaration param= lambdaParameters.get(i);
+ Type oldType= null;
+ if (param instanceof SingleVariableDeclaration) {
+ SingleVariableDeclaration curParent= (SingleVariableDeclaration) param;
+ oldType= curParent.getType();
+ if (oldType != null) {
+ rewrite.replace(oldType, ast.newSimpleType(ast.newName(VAR_TYPE)), null);
+ remover.registerRemovedNode(oldType);
+ }
+ }
+ if (oldType == null) {
+ SingleVariableDeclaration newParam= ast.newSingleVariableDeclaration();
+ newParam.setName(ast.newSimpleName(param.getName().getIdentifier()));
+ newParam.setType(ast.newSimpleType(ast.newName(VAR_TYPE)));
+ rewrite.replace(param, newParam, null);
+ }
+ }
+
+ // add proposal
+ ASTRewriteCorrectionProposal proposal;
+ String label= null;
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ if (isvarTypeSingleVariableDeclaration) {
+ label= CorrectionMessages.QuickAssistProcessor_replace_inferred_with_var_lambda_parameter_types;
+ ASTRewriteRemoveImportsCorrectionProposal newProposal= new ASTRewriteRemoveImportsCorrectionProposal(label, context.getCompilationUnit(), rewrite,
+ IProposalRelevance.ADD_INFERRED_LAMBDA_PARAMETER_TYPES, image);
+ newProposal.setImportRemover(remover);
+ proposal= newProposal;
+
+ } else {
+ label= CorrectionMessages.QuickAssistProcessor_add_var_lambda_parameter_types;
+ proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_INFERRED_LAMBDA_PARAMETER_TYPES, image);
+ }
+ proposal.setImportRewrite(importRewrite);
+ resultingCollections.add(proposal);
+ return true;
+ }
+
+ public static boolean getRemoveVarOrInferredLambdaParameterTypes(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) {
+ CompilationUnit astRoot= context.getASTRoot();
+ IJavaElement root= astRoot.getJavaElement();
+ ASTNode parent= covering.getParent();
+ if (parent == null || root == null) {
+ return false;
+ }
+ IJavaProject javaProject= root.getJavaProject();
+ if (javaProject == null) {
+ return false;
+ }
+ boolean checkForVarTypes= false;
+ if (JavaModelUtil.is11OrHigher(javaProject)) {
+ checkForVarTypes= true;
+ }
+
+ LambdaExpression lambda;
+ if (covering instanceof LambdaExpression) {
+ lambda= (LambdaExpression) covering;
+ } else if (covering.getLocationInParent() == SingleVariableDeclaration.NAME_PROPERTY &&
+ ((SingleVariableDeclaration) parent).getLocationInParent() == LambdaExpression.PARAMETERS_PROPERTY) {
+ lambda= (LambdaExpression) covering.getParent().getParent();
+ } else {
+ return false;
+ }
+
+ List<VariableDeclaration> lambdaParameters= lambda.parameters();
+ int noOfLambdaParams= lambdaParameters.size();
+ if (noOfLambdaParams == 0)
+ return false;
+
+ if (!(lambdaParameters.get(0) instanceof SingleVariableDeclaration))
+ return false;
+
+ IMethodBinding methodBinding= lambda.resolveMethodBinding();
+ if (methodBinding == null)
+ return false;
+
+ if (resultingCollections == null)
+ return true;
+
+ AST ast= lambda.getAST();
+ ASTRewrite rewrite= ASTRewrite.create(ast);
+
+ ImportRemover remover= new ImportRemover(context.getCompilationUnit().getJavaProject(), context.getASTRoot());
+
+ ImportRewrite importRewrite= StubUtility.createImportRewrite(context.getASTRoot(), true);
+
+ rewrite.set(lambda, LambdaExpression.PARENTHESES_PROPERTY, Boolean.valueOf(true), null);
+ boolean removeImports= false;
+ for (int i= 0; i < noOfLambdaParams; i++) {
+ VariableDeclaration param= lambdaParameters.get(i);
+ Type oldType= null;
+ if (param instanceof SingleVariableDeclaration) {
+ SingleVariableDeclaration curParent= (SingleVariableDeclaration) param;
+ oldType= curParent.getType();
+ if (oldType != null && (!checkForVarTypes || (checkForVarTypes && !oldType.isVar()))) {
+ remover.registerRemovedNode(oldType);
+ removeImports= true;
+ }
+ VariableDeclarationFragment newParam= ast.newVariableDeclarationFragment();
+ newParam.setName(ast.newSimpleName(param.getName().getIdentifier()));
+ rewrite.replace(param, newParam, null);
+ }
+ }
+
+ // add proposal
+ ASTRewriteCorrectionProposal proposal;
+ String label= null;
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ if (removeImports) {
+ label= CorrectionMessages.QuickAssistProcessor_remove_inferred_lambda_parameter_types;
+ ASTRewriteRemoveImportsCorrectionProposal newProposal= new ASTRewriteRemoveImportsCorrectionProposal(label, context.getCompilationUnit(), rewrite,
+ IProposalRelevance.ADD_INFERRED_LAMBDA_PARAMETER_TYPES, image);
+ newProposal.setImportRemover(remover);
+ proposal= newProposal;
+ } else {
+ label= CorrectionMessages.QuickAssistProcessor_remove_var_lambda_parameter_types;
+ proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_INFERRED_LAMBDA_PARAMETER_TYPES, image);
+ }
+ proposal.setImportRewrite(importRewrite);
+ resultingCollections.add(proposal);
+ return true;
+ }
+
public static boolean getInferDiamondArgumentsProposal(IInvocationContext context, ASTNode node, IProblemLocation[] locations, Collection<ICommandAccess> resultingCollections) {
// don't add if already added as quick fix
if (containsMatchingProblem(locations, IProblem.DiamondNotBelow17))
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
index da4ca95..3efb0c4 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
* Benjamin Muskalla <b.muskalla@gmx.net> - [quick fix] Quick fix for missing synchronized modifier - https://bugs.eclipse.org/bugs/show_bug.cgi?id=245250
@@ -67,6 +71,7 @@
case IProblem.PublicClassMustMatchFileName:
case IProblem.PackageIsNotExpectedPackage:
case IProblem.UndefinedType:
+ case IProblem.VarIsNotAllowedHere:
case IProblem.TypeMismatch:
case IProblem.ReturnTypeMismatch:
case IProblem.UnhandledException:
@@ -384,6 +389,7 @@
break;
case IProblem.UndefinedType:
case IProblem.JavadocUndefinedType:
+ case IProblem.VarIsNotAllowedHere:
UnresolvedElementsSubProcessor.getTypeProposals(context, problem, proposals);
break;
case IProblem.TypeMismatch:
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
index 4fd4ff9..7d7514e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
@@ -4,6 +4,11 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * 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
@@ -55,6 +60,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTMatcher;
import org.eclipse.jdt.core.dom.ASTNode;
@@ -76,6 +82,7 @@
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.ImportDeclaration;
+import org.eclipse.jdt.core.dom.LambdaExpression;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
@@ -625,13 +632,35 @@
return;
}
- if (node instanceof SimpleName && !JavaModelUtil.is10OrHigher(javaProject)) {
- String[] args= problem.getProblemArguments();
- if (args != null && args.length > 0) {
- String name= args[0];
- if (name.equals("var")) { //$NON-NLS-1$
- ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_10);
+ if (node instanceof SimpleName && !JavaModelUtil.is11OrHigher(javaProject)) {
+ boolean isVarTypeProblem= false;
+ if (problem.getProblemId() == IProblem.VarIsNotAllowedHere) {
+ isVarTypeProblem= true;
+ } else {
+ String[] args= problem.getProblemArguments();
+ if (args != null && args.length > 0) {
+ String name= args[0];
+ if (name.equals("var")) { //$NON-NLS-1$
+ isVarTypeProblem= true;
+ }
+ }
+ }
+ if (isVarTypeProblem) {
+ // check if "var" is present as lambda parameter type
+ boolean isVarInLambdaParamType= false;
+ ASTNode parent= node.getParent();
+ if (parent instanceof SimpleType && parent.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
+ parent= parent.getParent();
+ if (parent.getLocationInParent() == LambdaExpression.PARAMETERS_PROPERTY) {
+ isVarInLambdaParamType= true;
+ }
}
+
+ if (isVarInLambdaParamType) {
+ ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_11);
+ } else {
+ ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_10);
+ }
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/ASTRewriteRemoveImportsCorrectionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/ASTRewriteRemoveImportsCorrectionProposal.java
new file mode 100644
index 0000000..9f7f37b
--- /dev/null
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/ASTRewriteRemoveImportsCorrectionProposal.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.ui.text.correction.proposals;
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
+
+import org.eclipse.jdt.internal.corext.refactoring.structure.ImportRemover;
+
+import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal;
+
+public class ASTRewriteRemoveImportsCorrectionProposal extends ASTRewriteCorrectionProposal{
+
+ private ImportRemover fImportRemover;
+
+ public ASTRewriteRemoveImportsCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance) {
+ super(name, cu, rewrite, relevance);
+ }
+
+ public ASTRewriteRemoveImportsCorrectionProposal(String name, ICompilationUnit cu, ASTRewrite rewrite, int relevance, Image image) {
+ super(name, cu, rewrite, relevance, image);
+ }
+
+ public void setImportRemover(ImportRemover remover) {
+ fImportRemover= remover;
+ }
+
+ @Override
+ protected ASTRewrite getRewrite() throws CoreException {
+ ASTRewrite rewrite= super.getRewrite();
+ ImportRewrite importRewrite= getImportRewrite();
+ if (fImportRemover != null && importRewrite != null) {
+ fImportRemover.applyRemoves(importRewrite);
+ }
+ return rewrite;
+ }
+
+}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/SharedASTProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/SharedASTProvider.java
index 4169b57..7cde264b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/SharedASTProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/SharedASTProvider.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * 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
*******************************************************************************/
@@ -30,7 +34,7 @@
* <p>Clients can make the following assumptions about the AST:
* <dl>
* <li>the AST has a {@link ITypeRoot} as source: {@link CompilationUnit#getTypeRoot()} is not null.</li>
- * <li>the {@link AST#apiLevel() AST API level} is {@link AST#JLS10 API level 10} or higher</li>
+ * <li>the {@link AST#apiLevel() AST API level} is {@link AST#JLS11 API level 11} or higher</li>
* <li>the AST has bindings resolved ({@link AST#hasResolvedBindings()})</li>
* <li>{@link AST#hasStatementsRecovery() statement} and {@link AST#hasBindingsRecovery() bindings}
* recovery are enabled