Bug 574073: [17] Merge master to BETA_JAVA17 branch periodically during
4.21
Merge remote-tracking branch 'origin/master' into BETA_JAVA17
Change-Id: I7ddf1c0d0cc340f782eef826764cde35cc68f116
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 9428e98..8bdf813 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
@@ -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
*******************************************************************************/
@@ -138,6 +142,7 @@
public class ASTView extends ViewPart implements IShowInSource, IShowInTargetList {
static final int JLS_LATEST= AST.getJLSLatest();
+ private static final int JLS17= ASTHelper.JLS17;
private static final int JLS16= ASTHelper.JLS16;
private static final int JLS15= ASTHelper.JLS15;
private static final int JLS14= ASTHelper.JLS14;
@@ -509,6 +514,7 @@
case JLS14:
case JLS15:
case JLS16:
+ case JLS17:
fCurrentASTLevel= level;
}
} catch (NumberFormatException e) {
@@ -1131,6 +1137,7 @@
new ASTLevelToggle("AST Level 1&4 (14)", JLS14), //$NON-NLS-1$
new ASTLevelToggle("AST Level 1&5 (15)", JLS15), //$NON-NLS-1$
new ASTLevelToggle("AST Level 1&6 (16)", JLS16), //$NON-NLS-1$
+ new ASTLevelToggle("AST Level 1&7 (17)", JLS17), //$NON-NLS-1$
};
fAddToTrayAction= new Action() {
diff --git a/org.eclipse.jdt.core.manipulation/.settings/.api_filters b/org.eclipse.jdt.core.manipulation/.settings/.api_filters
index bae7ae8..c6caaf7 100644
--- a/org.eclipse.jdt.core.manipulation/.settings/.api_filters
+++ b/org.eclipse.jdt.core.manipulation/.settings/.api_filters
@@ -8,4 +8,41 @@
</message_arguments>
</filter>
</resource>
+ <resource path="core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java" type="org.eclipse.jdt.internal.corext.dom.ASTFlattener">
+ <filter comment="Java preview feature API" id="640712815">
+ <message_arguments>
+ <message_argument value="ASTNode"/>
+ <message_argument value="ASTFlattener"/>
+ <message_argument value="accept(ASTVisitor)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java preview feature API" id="640712815">
+ <message_arguments>
+ <message_argument value="ASTNode"/>
+ <message_argument value="ASTFlattener"/>
+ <message_argument value="getAST()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java preview feature API" id="640712815">
+ <message_arguments>
+ <message_argument value="GuardedPattern"/>
+ <message_argument value="ASTFlattener"/>
+ <message_argument value="getExpression()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java preview feature API" id="640712815">
+ <message_arguments>
+ <message_argument value="GuardedPattern"/>
+ <message_argument value="ASTFlattener"/>
+ <message_argument value="getPattern()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java preview feature API" id="640712815">
+ <message_arguments>
+ <message_argument value="TypePattern"/>
+ <message_argument value="ASTFlattener"/>
+ <message_argument value="getPatternVariable()"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java
index 7a3c05d..8930b0d 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/core/manipulation/SharedASTProviderCore.java
@@ -32,7 +32,7 @@
* <p>Clients can make the following assumptions about the AST:</p>
* <ul>
* <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#JLS16 API level 16} or higher</li>
+ * <li>the {@link AST#apiLevel() AST API level} is {@link AST#JLS17 API level 17} 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
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java
index cc206df..75ee91f 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/ASTHelper.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
*******************************************************************************/
@@ -32,6 +36,7 @@
public static final int JLS14 = AST.JLS14;
public static final int JLS15 = AST.JLS15;
public static final int JLS16 = AST.JLS16;
+ public static final int JLS17 = AST.JLS17;
private static boolean isNodeTypeSupportedInAST(AST ast, int nodeType) {
switch (nodeType) {
@@ -44,6 +49,8 @@
case ASTNode.RECORD_DECLARATION:
case ASTNode.INSTANCEOF_EXPRESSION:
return ast.apiLevel() >= JLS16;
+ case ASTNode.TYPE_PATTERN:
+ return ast.isPreviewEnabled();
default:
break;
}
@@ -54,7 +61,7 @@
switch (modifier) {
case Modifier.SEALED:
case Modifier.NON_SEALED:
- return ast.isPreviewEnabled();
+ return ast.apiLevel() >= JLS17;
default:
break;
}
@@ -89,4 +96,8 @@
return isNodeTypeSupportedInAST(ast, ASTNode.INSTANCEOF_EXPRESSION);
}
+ public static boolean isPatternSupported(AST ast) {
+ return isNodeTypeSupportedInAST(ast, ASTNode.TYPE_PATTERN);
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
index 65a5af7..fb13b15 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.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
*******************************************************************************/
@@ -356,6 +360,14 @@
return false;
}
+ @Override
+ public boolean visit(CaseDefaultExpression node) {
+ if (ASTHelper.isPatternSupported(node.getAST())) {
+ this.fBuffer.append("default");//$NON-NLS-1$
+ }
+ return false;
+ }
+
/*
* @see ASTVisitor#visit(CastExpression)
*/
@@ -727,6 +739,16 @@
return false;
}
+ @Override
+ public boolean visit(GuardedPattern node) {
+ if (ASTHelper.isPatternSupported(node.getAST())) {
+ node.getPattern().accept(this);
+ this.fBuffer.append(" && ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ }
+ return false;
+ }
+
/*
* @see ASTVisitor#visit(IfStatement)
*/
@@ -1179,6 +1201,14 @@
return false;
}
+ @Override
+ public boolean visit(NullPattern node) {
+ if (ASTHelper.isPatternSupported(node.getAST())) {
+ this.fBuffer.append("null");//$NON-NLS-1$
+ }
+ return false;
+ }
+
/*
* @see ASTVisitor#visit(NumberLiteral)
*/
@@ -1578,7 +1608,7 @@
@Override
public boolean visit(SwitchCase node) {
if (ASTHelper.isSwitchCaseExpressionsSupportedInAST(node.getAST())) {
- if (node.isDefault()) {
+ if (node.isDefault() && !isCaseDefaultExpression(node)) {
this.fBuffer.append("default");//$NON-NLS-1$
this.fBuffer.append(node.isSwitchLabeledRule() ? " ->" : ":");//$NON-NLS-1$ //$NON-NLS-2$
} else {
@@ -1591,7 +1621,7 @@
}
}
} else {
- if (node.isDefault()) {
+ if (node.isDefault() && !isCaseDefaultExpression(node)) {
this.fBuffer.append("default :\n");//$NON-NLS-1$
} else {
this.fBuffer.append("case ");//$NON-NLS-1$
@@ -1602,6 +1632,13 @@
return false;
}
+ private boolean isCaseDefaultExpression(SwitchCase node) {
+ if (node.expressions() != null && node.expressions().size() == 1 && node.expressions().get(0) instanceof CaseDefaultExpression) {
+ return true;
+ }
+ return false;
+ }
+
@Override
public boolean visit(YieldStatement node) {
if (ASTHelper.isYieldNodeSupportedInAST(node.getAST()) && node.isImplicit() && node.getExpression() == null) {
@@ -1901,6 +1938,14 @@
return false;
}
+ @Override
+ public boolean visit(TypePattern node) {
+ if (ASTHelper.isPatternSupported(node.getAST())) {
+ node.getPatternVariable().accept(this);
+ }
+ return false;
+ }
+
/*
* @see ASTVisitor#visit(UnionType)
*/
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java
index b2bd938..fdcc331 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.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
*******************************************************************************/
@@ -380,6 +384,16 @@
}
@Override
+ public boolean visit(CaseDefaultExpression node) {
+ return visit((Expression)node);
+ }
+
+ @Override
+ public void endVisit(CaseDefaultExpression node) {
+ endVisit((Expression)node);
+ }
+
+ @Override
public boolean visit(CastExpression node) {
return visit((Expression)node);
}
@@ -602,6 +616,16 @@
//---- End Name Hierarchy ------------------------------------
@Override
+ public boolean visit(GuardedPattern node) {
+ return visit((Pattern)node);
+ }
+
+ @Override
+ public void endVisit(GuardedPattern node) {
+ endVisit((Pattern)node);
+ }
+
+ @Override
public boolean visit(NullLiteral node) {
return visit((Expression)node);
}
@@ -612,6 +636,16 @@
}
@Override
+ public boolean visit(NullPattern node) {
+ return visit((Pattern)node);
+ }
+
+ @Override
+ public void endVisit(NullPattern node) {
+ endVisit((Pattern)node);
+ }
+
+ @Override
public boolean visit(NumberLiteral node) {
return visit((Expression)node);
}
@@ -621,6 +655,14 @@
endVisit((Expression)node);
}
+ public boolean visit(Pattern node) {
+ return visit((Expression)node);
+ }
+
+ public void endVisit(Pattern node) {
+ endVisit((Expression)node);
+ }
+
@Override
public boolean visit(ParenthesizedExpression node) {
return visit((Expression)node);
@@ -712,6 +754,16 @@
}
@Override
+ public boolean visit(TypePattern node) {
+ return visit((Pattern)node);
+ }
+
+ @Override
+ public void endVisit(TypePattern node) {
+ endVisit((Pattern)node);
+ }
+
+ @Override
public boolean visit(VariableDeclarationExpression node) {
return visit((Expression)node);
}
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 a50255a..7675274 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
@@ -80,7 +84,7 @@
*/
public static final String VERSION_LATEST;
static {
- VERSION_LATEST= JavaCore.VERSION_16; // make sure it is not inlined
+ VERSION_LATEST= JavaCore.VERSION_17; // make sure it is not inlined
}
public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003;
@@ -845,6 +849,10 @@
return !isVersionLessThan(compliance, JavaCore.VERSION_16);
}
+ public static boolean is17OrHigher(String compliance) {
+ return !isVersionLessThan(compliance, JavaCore.VERSION_17);
+ }
+
/**
* Checks if the given project or workspace has source compliance 1.2 or greater.
*
@@ -974,6 +982,17 @@
return is16OrHigher(getSourceCompliance(project));
}
+ /**
+ * Checks if the given project or workspace has source compliance 17 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 17 or
+ * greater.
+ */
+ public static boolean is17OrHigher(IJavaProject project) {
+ return is17OrHigher(getSourceCompliance(project));
+ }
+
public static String getSourceCompliance(IJavaProject project) {
return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE);
}
@@ -1024,6 +1043,8 @@
String version= vMInstall.getJavaVersion();
if (version == null) {
return defaultCompliance;
+ } else if (version.startsWith(JavaCore.VERSION_17)) {
+ return JavaCore.VERSION_17;
} else if (version.startsWith(JavaCore.VERSION_16)) {
return JavaCore.VERSION_16;
} else if (version.startsWith(JavaCore.VERSION_15)) {
@@ -1068,7 +1089,9 @@
// fallback:
String desc= executionEnvironment.getId();
- if (desc.indexOf(JavaCore.VERSION_16) != -1) {
+ if (desc.indexOf(JavaCore.VERSION_17) != -1) {
+ return JavaCore.VERSION_17;
+ } else if (desc.indexOf(JavaCore.VERSION_16) != -1) {
return JavaCore.VERSION_16;
} else if (desc.indexOf(JavaCore.VERSION_15) != -1) {
return JavaCore.VERSION_15;
diff --git a/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java b/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java
index 0952c1d..0cd749a 100644
--- a/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java
+++ b/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/reftracker/ReferenceTracker.java
@@ -110,7 +110,7 @@
}
return isAccessible;
} catch (RuntimeException ex) {
- throw new RuntimeException("JVM settings `--add-modules ALL-SYSTEM --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 java.base/jdk.internal.icu.impl=ALL-UNNAMED --add-opens java.base/jdk.internal.icu.text=ALL-UNNAMED --illegal-access=permit` are probably missing.\nException : \n" + ex.getMessage(), ex);
+ throw new RuntimeException("JVM settings `--add-modules ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --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 java.base/jdk.internal.icu.impl=ALL-UNNAMED --add-opens java.base/jdk.internal.icu.text=ALL-UNNAMED --illegal-access=permit` are probably missing.\nException : \n" + ex.getMessage(), ex);
}
}
diff --git a/org.eclipse.jdt.ui.tests/pom.xml b/org.eclipse.jdt.ui.tests/pom.xml
index 0eeb607..eaa8da2 100644
--- a/org.eclipse.jdt.ui.tests/pom.xml
+++ b/org.eclipse.jdt.ui.tests/pom.xml
@@ -25,7 +25,7 @@
<properties>
<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
<!-- Necessary for leakTests to succeed without raising module/classloader issues on Java 9+ -->
- <leakTestsArgLine>--add-modules ALL-SYSTEM --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 java.base/jdk.internal.icu.impl=ALL-UNNAMED --add-opens java.base/jdk.internal.icu.text=ALL-UNNAMED --illegal-access=permit</leakTestsArgLine>
+ <leakTestsArgLine>--add-modules ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --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 java.base/jdk.internal.icu.impl=ALL-UNNAMED --add-opens java.base/jdk.internal.icu.text=ALL-UNNAMED --illegal-access=permit</leakTestsArgLine>
</properties>
<build>
diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
index a5966fd..f91edad 100644
--- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
+++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
@@ -105,6 +105,7 @@
public static final IPath RT_STUBS14= new Path("testresources/rtstubs14.jar");
public static final IPath RT_STUBS15= new Path("testresources/rtstubs_15.jar");
public static final IPath RT_STUBS16= new Path("testresources/rtstubs_16.jar");
+ public static final IPath RT_STUBS17= new Path("testresources/rtstubs_17.jar");
public static final IPath JUNIT_SRC_381= new Path("testresources/junit381-noUI-src.zip");
public static final String JUNIT_SRC_ENCODING= "ISO-8859-1";
@@ -314,7 +315,7 @@
}
/**
- * Sets the compiler options to 15 for the given project.
+ * Sets the compiler options to 16 for the given project.
*
* @param project the java project
* @param enable_preview_feature sets enable-preview compliance project option based on the
@@ -331,6 +332,23 @@
}
/**
+ * Sets the compiler options to 17 for the given project.
+ *
+ * @param project the java project
+ * @param enable_preview_feature sets enable-preview compliance project option based on the
+ * value specified.
+ */
+ public static void set17CompilerOptions(IJavaProject project, boolean enable_preview_feature) {
+ Map<String, String> options= project.getOptions(false);
+ set17_CompilerOptions(options);
+ if (enable_preview_feature) {
+ options.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ }
+ project.setOptions(options);
+ }
+
+ /**
* Sets the compiler options to 1.8 for the given project.
*
* @param project the java project
@@ -456,6 +474,15 @@
}
/**
+ * Sets the compiler options to 17.
+ *
+ * @param options the compiler options to configure
+ */
+ public static void set17_CompilerOptions(Map<String, String> options) {
+ JavaCore.setComplianceOptions(JavaCore.VERSION_17, options);
+ }
+
+ /**
* Sets the compiler options to 1.8
*
* @param options the compiler options to configure
diff --git a/org.eclipse.jdt.ui.tests/test.xml b/org.eclipse.jdt.ui.tests/test.xml
index 1040e12..4d7ca8d 100644
--- a/org.eclipse.jdt.ui.tests/test.xml
+++ b/org.eclipse.jdt.ui.tests/test.xml
@@ -44,7 +44,7 @@
<property name="jdt-folder" value="${eclipse-home}/jdt_folder"/>
<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 --add-opens java.base/jdk.internal.icu.impl=ALL-UNNAMED --add-opens java.base/jdk.internal.icu.text=ALL-UNNAMED --illegal-access=permit" else="">
+ <condition property="java9vmargs" value="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --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 --add-opens java.base/jdk.internal.icu.impl=ALL-UNNAMED --add-opens java.base/jdk.internal.icu.text=ALL-UNNAMED --illegal-access=permit" else="">
<javaversion atleast="9"/>
</condition>
diff --git a/org.eclipse.jdt.ui.tests/testresources/rtstubs_17.jar b/org.eclipse.jdt.ui.tests/testresources/rtstubs_17.jar
new file mode 100644
index 0000000..fb6cb93
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests/testresources/rtstubs_17.jar
Binary files differ
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java
index 00d3132..be9ecee 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -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
*******************************************************************************/
@@ -39,6 +43,7 @@
import org.eclipse.jdt.core.dom.ModuleDirective;
import org.eclipse.jdt.core.dom.ModulePackageAccess;
import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.Pattern;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.VariableDeclaration;
@@ -255,6 +260,23 @@
super.visit(node);
}
+ @Override
+ public boolean visit(Pattern node) {
+ registerCall(Pattern.class);
+ return false;
+ }
+ @SuppressWarnings("unused") // called reflectively
+ public void superVisit(Pattern node) {
+ super.visit(node);
+ }
+ @Override
+ public void endVisit(Pattern node) {
+ registerCall(Pattern.class);
+ }
+ @SuppressWarnings("unused") // called reflectively
+ public void superEndVisit(Pattern node) {
+ super.visit(node);
+ }
@Override
public boolean visit(Statement node) {
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java17ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java17ProjectTestSetup.java
new file mode 100644
index 0000000..05574b2
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java17ProjectTestSetup.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * derived from corresponding file in org.eclipse.jdt.ui.tests.core
+ * instead extending TestSetup for junit4 ExternalResource is extended
+ * to allow use as junit "@Rule"
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.core.rules;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+import org.eclipse.jdt.internal.core.ClasspathEntry;
+
+public class Java17ProjectTestSetup extends ProjectTestSetup {
+
+ public static final String PROJECT_NAME17= "TestSetupProject17";
+
+ private boolean enable_preview_feature;
+
+ @Override
+ public IJavaProject getProject() {
+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME17);
+ return JavaCore.create(project);
+ }
+
+ @Override
+ public IClasspathEntry[] getDefaultClasspath() throws CoreException {
+ IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS17);
+ IClasspathAttribute[] extraAttributes= { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, Boolean.TRUE.toString()) };
+ return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], ClasspathEntry.NO_ACCESS_RULES, extraAttributes, true) };
+ }
+
+ public Java17ProjectTestSetup( boolean enable_preview_feature) {
+ this.enable_preview_feature= enable_preview_feature;
+ }
+
+ @Override
+ protected boolean projectExists() {
+ return getProject().exists();
+ }
+
+ @Override
+ protected IJavaProject createAndInitializeProject() throws CoreException {
+ IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME17, "bin");
+ javaProject.setRawClasspath(getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(javaProject, enable_preview_feature);
+ return javaProject;
+ }
+
+}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest17.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest17.java
new file mode 100644
index 0000000..2302398
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest17.java
@@ -0,0 +1,598 @@
+/*******************************************************************************
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.quickfix;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+
+import org.eclipse.jdt.ui.tests.core.rules.Java17ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
+
+public class QuickFixTest17 extends QuickFixTest {
+
+ @Rule
+ public ProjectTestSetup projectsetup= new Java17ProjectTestSetup(false);
+
+ private IJavaProject fJProject1;
+
+ private IPackageFragmentRoot fSourceFolder;
+
+ @After
+ public void tearDown() throws Exception {
+ if (fJProject1 != null) {
+ JavaProjectHelper.delete(fJProject1);
+ }
+ }
+
+ @Test
+ public void testAddSealedMissingClassModifierProposal() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, false);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Square {}\n" +
+ "\n" +
+ "class Square extends Shape {}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1);
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ String expected1= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Square {}\n" +
+ "\n" +
+ "final class Square extends Shape {}\n";
+
+ proposal= (CUCorrectionProposal) proposals.get(1);
+ String preview2= getPreviewContent(proposal);
+
+ String expected2= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Square {}\n" +
+ "\n" +
+ "non-sealed class Square extends Shape {}\n";
+
+ proposal= (CUCorrectionProposal) proposals.get(2);
+ String preview3= getPreviewContent(proposal);
+
+ String expected3= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Square {}\n" +
+ "\n" +
+ "sealed class Square extends Shape {}\n";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 });
+
+ }
+
+ @Test
+ public void testAddSealedMissingInterfaceModifierProposal() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, false);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square {}\n" +
+ "\n" +
+ "interface Square extends Shape {}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1);
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ String expected1= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square {}\n" +
+ "\n" +
+ "sealed interface Square extends Shape {}\n";
+
+ proposal= (CUCorrectionProposal) proposals.get(1);
+ String preview2= getPreviewContent(proposal);
+
+ String expected2= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square {}\n" +
+ "\n" +
+ "non-sealed interface Square extends Shape {}\n";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
+
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperTypeProposal1() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Square {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed class Square extends Shape {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Square.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed class Circle extends Shape {\n" +
+ "}\n";
+ ICompilationUnit cu2= pack1.createCompilationUnit("Circle.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu2);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Square, Circle {\n" +
+ "}\n";
+
+ assertEqualString(preview, expected);
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperTypeProposal2() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed class Square implements Shape {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Square.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed class Circle implements Shape {\n" +
+ "}\n";
+ ICompilationUnit cu2= pack1.createCompilationUnit("Circle.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu2);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square, Circle {\n" +
+ "}\n";
+
+ assertEqualString(preview, expected);
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperTypeProposal3() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed class Square implements Shape {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Square.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed interface Circle extends Shape {\n" +
+ "}\n";
+ ICompilationUnit cu2= pack1.createCompilationUnit("Circle.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu2);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square, Circle {\n" +
+ "}\n";
+
+ assertEqualString(preview, expected);
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperTypeProposal4() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+
+ IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ test= "" +
+ "package test;\n" +
+ "\n" +
+ "public non-sealed class Square implements Shape {\n" +
+ "}\n";
+ pack1.createCompilationUnit("Square.java", test, false, null);
+
+
+ IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
+
+ test= "" +
+ "package test2;\n" +
+ "\n" +
+ "import test.Shape;\n" +
+ "\n" +
+ "public non-sealed interface Circle extends Shape {\n" +
+ "}\n";
+ ICompilationUnit cu2= pack2.createCompilationUnit("Circle.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu2);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= "" +
+ "package test;\n" +
+ "\n" +
+ "import test2.Circle;\n" +
+ "\n" +
+ "public sealed interface Shape permits Square, Circle {\n" +
+ "}\n";
+
+ assertEqualString(preview, expected);
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperInterface1() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface IShape permits Circle {\\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "class Circle {\n" +
+ " \n" +
+ "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("IShape.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ String expected1= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface IShape permits Circle {\\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "class Circle implements IShape {\n" +
+ " \n" +
+ "}\n";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 });
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperInterface2() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface IShape permits IRectangle {\\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "interface IRectangle {\n" +
+ " \n" +
+ "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("IShape.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ String expected1= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed interface IShape permits IRectangle {\\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "interface IRectangle extends IShape {\n" +
+ " \n" +
+ "}\n";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 });
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperInterface3() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "import java.lang.annotation.IncompleteAnnotationException;\n" +
+ "\n" +
+ "public sealed interface IShape permits IncompleteAnnotationException {\\n" +
+ "\n" +
+ "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("IShape.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 3);
+ assertNumberOfProposals(proposals, 0);
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperInterface4() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+
+ IPackageFragment defaultPkg= fSourceFolder.createPackageFragment("", false, null);
+ defaultPkg.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
+
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String test= "" +
+ "package test1;\n" +
+ "\n" +
+ "import test2.IRectangle;\n" +
+ "\n" +
+ "public sealed interface IShape permits IRectangle {\n" +
+ "}\n";
+ ICompilationUnit cu1= pack1.createCompilationUnit("IShape.java", test, false, null);
+
+ IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
+ test= "" +
+ "package test2;\n" +
+ "\n" +
+ "public interface IRectangle {\n" +
+ "}\n";
+ pack2.createCompilationUnit("IRectangle.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu1);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu1, astRoot, 1);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= "" +
+ "package test2;\n" +
+ "\n" +
+ "import test1.IShape;\n" +
+ "\n" +
+ "public interface IRectangle extends IShape {\n" +
+ "}\n";
+ assertEqualString(preview, expected);
+ }
+
+ @Test
+ public void testAddSealedAsDirectSuperClass1() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set17CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+
+ String test= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Circle {\\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "class Circle extends AssertionError {\n" +
+ " \n" +
+ "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("Shape.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 3);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ String expected1= "" +
+ "package test;\n" +
+ "\n" +
+ "public sealed class Shape permits Circle {\\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "class Circle extends Shape {\n" +
+ " \n" +
+ "}\n";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 });
+ }
+
+}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestPreview.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestPreview.java
index 10e00d8..02b64ca 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestPreview.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestPreview.java
@@ -13,35 +13,24 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix;
-import java.util.ArrayList;
-import java.util.Map;
-
import org.junit.After;
import org.junit.Rule;
-import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.ui.tests.core.rules.Java16ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
-import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
-import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
public class QuickFixTestPreview extends QuickFixTest {
- @Rule
- public ProjectTestSetup projectsetup = new Java16ProjectTestSetup(true);
+ @Rule
+ public ProjectTestSetup projectsetup= new Java16ProjectTestSetup(true);
- private IJavaProject fJProject1;
+ private IJavaProject fJProject1;
- private IPackageFragmentRoot fSourceFolder;
+// private IPackageFragmentRoot fSourceFolder;
@After
public void tearDown() throws Exception {
@@ -50,549 +39,4 @@
}
}
- @Test
- public void testAddSealedMissingClassModifierProposal() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Square {}\n" +
- "\n" +
- "class Square extends Shape {}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("Shape.java",test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1);
- assertNumberOfProposals(proposals, 3);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview1= getPreviewContent(proposal);
-
- String expected1= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Square {}\n" +
- "\n" +
- "final class Square extends Shape {}\n";
-
- proposal= (CUCorrectionProposal) proposals.get(1);
- String preview2= getPreviewContent(proposal);
-
- String expected2= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Square {}\n" +
- "\n" +
- "non-sealed class Square extends Shape {}\n";
-
- proposal= (CUCorrectionProposal) proposals.get(2);
- String preview3= getPreviewContent(proposal);
-
- String expected3= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Square {}\n" +
- "\n" +
- "sealed class Square extends Shape {}\n";
-
- assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 });
-
- }
-
- @Test
- public void testAddSealedMissingInterfaceModifierProposal() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test = "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square {}\n" +
- "\n" +
- "interface Square extends Shape {}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("Shape.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1);
- assertNumberOfProposals(proposals, 2);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview1= getPreviewContent(proposal);
-
- String expected1= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square {}\n" +
- "\n" +
- "sealed interface Square extends Shape {}\n";
-
- proposal= (CUCorrectionProposal) proposals.get(1);
- String preview2= getPreviewContent(proposal);
-
- String expected2= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square {}\n" +
- "\n" +
- "non-sealed interface Square extends Shape {}\n";
-
- assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
-
- }
-
- @Test
- public void testAddSealedAsDirectSuperTypeProposal1() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Square {\n" +
- "}\n";
- pack1.createCompilationUnit("Shape.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed class Square extends Shape {\n" +
- "}\n";
- pack1.createCompilationUnit("Square.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed class Circle extends Shape {\n" +
- "}\n";
- ICompilationUnit cu2= pack1.createCompilationUnit("Circle.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu2);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview= getPreviewContent(proposal);
-
- String expected= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Square, Circle {\n" +
- "}\n";
-
- assertEqualString(preview, expected);
- }
-
- @Test
- public void testAddSealedAsDirectSuperTypeProposal2() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square {\n" +
- "}\n";
- pack1.createCompilationUnit("Shape.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed class Square implements Shape {\n" +
- "}\n";
- pack1.createCompilationUnit("Square.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed class Circle implements Shape {\n" +
- "}\n";
- ICompilationUnit cu2= pack1.createCompilationUnit("Circle.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu2);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview= getPreviewContent(proposal);
-
- String expected= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square, Circle {\n" +
- "}\n";
-
- assertEqualString(preview, expected);
- }
-
- @Test
- public void testAddSealedAsDirectSuperTypeProposal3() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square {\n" +
- "}\n";
- pack1.createCompilationUnit("Shape.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed class Square implements Shape {\n" +
- "}\n";
- pack1.createCompilationUnit("Square.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed interface Circle extends Shape {\n" +
- "}\n";
- ICompilationUnit cu2= pack1.createCompilationUnit("Circle.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu2);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview= getPreviewContent(proposal);
-
- String expected= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square, Circle {\n" +
- "}\n";
-
- assertEqualString(preview, expected);
- }
-
- @Test
- public void testAddSealedAsDirectSuperTypeProposal4() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
-
- IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
-
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface Shape permits Square {\n" +
- "}\n";
- pack1.createCompilationUnit("Shape.java", test, false, null);
-
- test= "" +
- "package test;\n" +
- "\n" +
- "public non-sealed class Square implements Shape {\n" +
- "}\n";
- pack1.createCompilationUnit("Square.java", test, false, null);
-
-
- IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
-
- test= "" +
- "package test2;\n" +
- "\n" +
- "import test.Shape;\n" +
- "\n" +
- "public non-sealed interface Circle extends Shape {\n" +
- "}\n";
- ICompilationUnit cu2= pack2.createCompilationUnit("Circle.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu2);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu2, astRoot, 1);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview= getPreviewContent(proposal);
-
- String expected= "" +
- "package test;\n" +
- "\n" +
- "import test2.Circle;\n" +
- "\n" +
- "public sealed interface Shape permits Square, Circle {\n" +
- "}\n";
-
- assertEqualString(preview, expected);
- }
-
- @Test
- public void testAddSealedAsDirectSuperInterface1() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface IShape permits Circle {\\n" +
- "\n" +
- "}\n" +
- "\n" +
- "class Circle {\n" +
- " \n" +
- "}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("IShape.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview1= getPreviewContent(proposal);
-
- String expected1= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface IShape permits Circle {\\n" +
- "\n" +
- "}\n" +
- "\n" +
- "class Circle implements IShape {\n" +
- " \n" +
- "}\n";
-
- assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 });
- }
-
- @Test
- public void testAddSealedAsDirectSuperInterface2() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface IShape permits IRectangle {\\n" +
- "\n" +
- "}\n" +
- "\n" +
- "interface IRectangle {\n" +
- " \n" +
- "}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("IShape.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview1= getPreviewContent(proposal);
-
- String expected1= "" +
- "package test;\n" +
- "\n" +
- "public sealed interface IShape permits IRectangle {\\n" +
- "\n" +
- "}\n" +
- "\n" +
- "interface IRectangle extends IShape {\n" +
- " \n" +
- "}\n";
-
- assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 });
- }
-
- @Test
- public void testAddSealedAsDirectSuperInterface3() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "import java.lang.annotation.IncompleteAnnotationException;\n" +
- "\n" +
- "public sealed interface IShape permits IncompleteAnnotationException {\\n" +
- "\n" +
- "}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("IShape.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 3);
- assertNumberOfProposals(proposals, 0);
- }
-
- @Test
- public void testAddSealedAsDirectSuperInterface4() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
-
- IPackageFragment defaultPkg= fSourceFolder.createPackageFragment("", false, null);
- defaultPkg.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
-
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
- String test= "" +
- "package test1;\n" +
- "\n" +
- "import test2.IRectangle;\n" +
- "\n" +
- "public sealed interface IShape permits IRectangle {\n" +
- "}\n";
- ICompilationUnit cu1= pack1.createCompilationUnit("IShape.java", test, false, null);
-
- IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
- test= "" +
- "package test2;\n" +
- "\n" +
- "public interface IRectangle {\n" +
- "}\n";
- pack2.createCompilationUnit("IRectangle.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu1);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu1, astRoot, 1);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview= getPreviewContent(proposal);
-
- String expected= "" +
- "package test2;\n" +
- "\n" +
- "import test1.IShape;\n" +
- "\n" +
- "public interface IRectangle extends IShape {\n" +
- "}\n";
- assertEqualString(preview, expected);
- }
-
- @Test
- public void testAddSealedAsDirectSuperClass1() throws Exception {
- fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- fJProject1.setRawClasspath(projectsetup.getDefaultClasspath(), null);
- JavaProjectHelper.set16CompilerOptions(fJProject1, true);
-
- Map<String, String> options= fJProject1.getOptions(false);
- options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.IGNORE);
- fJProject1.setOptions(options);
-
- fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
-
- String test= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Circle {\\n" +
- "\n" +
- "}\n" +
- "\n" +
- "class Circle extends AssertionError {\n" +
- " \n" +
- "}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("Shape.java", test, false, null);
-
- CompilationUnit astRoot= getASTRoot(cu);
- ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 3);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
- CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
- String preview1= getPreviewContent(proposal);
-
- String expected1= "" +
- "package test;\n" +
- "\n" +
- "public sealed class Shape permits Circle {\\n" +
- "\n" +
- "}\n" +
- "\n" +
- "class Circle extends Shape {\n" +
- " \n" +
- "}\n";
-
- assertEqualStringsIgnoreOrder(new String[] { preview1 }, new String[] { expected1 });
- }
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestSuite.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestSuite.java
index d27cd62..2a05802 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestSuite.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTestSuite.java
@@ -23,7 +23,7 @@
QuickFixTest1d8.class,
QuickFixTest14.class,
QuickFixTest15.class,
- QuickFixTestPreview.class,
+ QuickFixTest17.class,
SerialVersionQuickFixTest.class,
UtilitiesTest.class,
UnresolvedTypesQuickFixTest.class,
diff --git a/org.eclipse.jdt.ui/.settings/.api_filters b/org.eclipse.jdt.ui/.settings/.api_filters
index 6a6c033..440a662 100644
--- a/org.eclipse.jdt.ui/.settings/.api_filters
+++ b/org.eclipse.jdt.ui/.settings/.api_filters
@@ -112,15 +112,6 @@
</message_arguments>
</filter>
</resource>
- <resource path="ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java" type="org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightingReconciler$PositionCollector">
- <filter comment="This is a Java 15 preview feature" id="640712815">
- <message_arguments>
- <message_argument value="TypeDeclaration"/>
- <message_argument value="PositionCollector"/>
- <message_argument value="getRestrictedIdentifierStartPosition()"/>
- </message_arguments>
- </filter>
- </resource>
<resource path="ui/org/eclipse/jdt/internal/ui/text/JavaOutlineInformationControl.java" type="org.eclipse.jdt.internal.ui.text.JavaOutlineInformationControl$OutlineTreeViewer">
<filter id="571473929">
<message_arguments>
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 adb6363..07e8a83 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, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -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
@@ -144,6 +148,7 @@
private static final String VERSION_14 = JavaCore.VERSION_14;
private static final String VERSION_15 = JavaCore.VERSION_15;
private static final String VERSION_16 = JavaCore.VERSION_16;
+ private static final String VERSION_17 = JavaCore.VERSION_17;
private static final String VERSION_LATEST = JavaCore.latestSupportedJavaVersion();
private static final String VERSION_JSR14= "jsr14"; //$NON-NLS-1$
@@ -301,7 +306,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_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16 };
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17 };
final String[] complianceLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_version13,
PreferencesMessages.ComplianceConfigurationBlock_version14,
@@ -317,10 +322,11 @@
PreferencesMessages.ComplianceConfigurationBlock_version_14,
PreferencesMessages.ComplianceConfigurationBlock_version_15,
PreferencesMessages.ComplianceConfigurationBlock_version_16,
+ PreferencesMessages.ComplianceConfigurationBlock_version_17,
};
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_14, VERSION_15, VERSION_16 };
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17 };
String[] targetLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11,
PreferencesMessages.ComplianceConfigurationBlock_version11,
@@ -339,6 +345,7 @@
PreferencesMessages.ComplianceConfigurationBlock_version_14,
PreferencesMessages.ComplianceConfigurationBlock_version_15,
PreferencesMessages.ComplianceConfigurationBlock_version_16,
+ PreferencesMessages.ComplianceConfigurationBlock_version_17,
};
if (ComplianceConfigurationBlock.VERSION_JSR14.equals(getValue(PREF_CODEGEN_TARGET_PLATFORM))) {
targetVersions= append(targetVersions, ComplianceConfigurationBlock.VERSION_JSR14);
@@ -346,7 +353,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_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16 };
+ VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15, VERSION_16, VERSION_17 };
String[] sourceLabels= new String[] {
PreferencesMessages.ComplianceConfigurationBlock_version13,
PreferencesMessages.ComplianceConfigurationBlock_version14,
@@ -362,6 +369,7 @@
PreferencesMessages.ComplianceConfigurationBlock_version_14,
PreferencesMessages.ComplianceConfigurationBlock_version_15,
PreferencesMessages.ComplianceConfigurationBlock_version_16,
+ PreferencesMessages.ComplianceConfigurationBlock_version_17,
};
final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
@@ -811,13 +819,13 @@
}
}
- //TODO: Comment once Java SE 16 has been shipped:
-// String selectedCompliance= getValue(PREF_COMPLIANCE);
-// if (VERSION_16.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;
-// }
+ //TODO: Comment once Java SE 17 has been shipped:
+ String selectedCompliance= getValue(PREF_COMPLIANCE);
+ if (VERSION_17.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 42d5d19..362a727 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -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
@@ -840,6 +844,7 @@
public static String ComplianceConfigurationBlock_version_14;
public static String ComplianceConfigurationBlock_version_15;
public static String ComplianceConfigurationBlock_version_16;
+ public static String ComplianceConfigurationBlock_version_17;
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 437d69fd..5236cf8 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2020 IBM Corporation and others.
+# Copyright (c) 2000, 2021 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -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
@@ -594,6 +598,7 @@
ComplianceConfigurationBlock_version_14=14
ComplianceConfigurationBlock_version_15=15
ComplianceConfigurationBlock_version_16=16
+ComplianceConfigurationBlock_version_17=17 (BETA)
ComplianceConfigurationBlock_versionCLDC11=CLDC 1.1
ComplianceConfigurationBlock_needsbuild_title=Compiler Settings Changed
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 61df9b6..6b39ceb 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
@@ -33,7 +33,7 @@
* <p>Clients can make the following assumptions about the AST:</p>
* <ul>
* <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#JLS16 API level 16} or higher</li>
+ * <li>the {@link AST#apiLevel() AST API level} is {@link AST#JLS17 API level 17} 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
diff --git a/pom.xml b/pom.xml
index df48a3b..c988ab4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,10 @@
<profiles>
<profile>
<id>build-individual-bundles</id>
+ <properties>
+ <eclipse-p2-repo.url>http://download.eclipse.org/eclipse/updates/Y-builds</eclipse-p2-repo.url>
+ <skipAPIAnalysis>true</skipAPIAnalysis>
+ </properties>
<repositories>
<repository>
<releases>