Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core/dom/org/eclipse/jdt/core')
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java29
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java19
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java14
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypePattern.java12
4 files changed, 63 insertions, 11 deletions
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
index 937aec0ced..8d4befdcb2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.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
*******************************************************************************/
@@ -390,6 +394,21 @@ public final class AST {
* @since 3.28
*/
public static final int JLS17 = 17;
+ /**
+ * Constant for indicating the AST API that handles JLS17.
+ * <p>
+ * This API is capable of handling all constructs in the
+ * Java language as described in the Java Language
+ * Specification, Java SE 18 Edition (JLS18).
+ * JLS18 is a superset of all earlier versions of the
+ * Java language, and the JLS18 API can be used to manipulate
+ * programs written in all versions of the Java language
+ * up to and including Java SE 18(aka JDK 18).
+ * </p>
+ *
+ * @since 3.28 BETA_JAVA 18
+ */
+ public static final int JLS18 = 18;
/**
* Internal synonym for {@link #JLS15}. Use to alleviate
@@ -406,12 +425,16 @@ public final class AST {
* deprecation warnings once JLS17 is deprecated
*/
static final int JLS17_INTERNAL = JLS17;
-
+ /**
+ * Internal synonym for {@link #JLS18}. Use to alleviate
+ * deprecation warnings once JLS18 is deprecated
+ */
+ static final int JLS18_INTERNAL = JLS18;
/**
* Internal property for latest supported JLS level
* This provides the latest JLS level.
*/
- private static final int JLS_INTERNAL_Latest = JLS17;
+ private static final int JLS_INTERNAL_Latest = JLS18;
/**
* @since 3.26
@@ -1153,6 +1176,7 @@ public final class AST {
t.put(JavaCore.VERSION_15, ClassFileConstants.JDK15);
t.put(JavaCore.VERSION_16, ClassFileConstants.JDK16);
t.put(JavaCore.VERSION_17, ClassFileConstants.JDK17);
+ t.put(JavaCore.VERSION_18, ClassFileConstants.JDK18);
return Collections.unmodifiableMap(t);
}
private static Map<String, Integer> getApiLevelMapTable() {
@@ -1174,6 +1198,7 @@ public final class AST {
t.put(JavaCore.VERSION_15, JLS15_INTERNAL);
t.put(JavaCore.VERSION_16, JLS16_INTERNAL);
t.put(JavaCore.VERSION_17, JLS17_INTERNAL);
+ t.put(JavaCore.VERSION_18, JLS18_INTERNAL);
return Collections.unmodifiableMap(t);
}
/**
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
index 9a5a839db1..0e8ef9c4d2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.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
*******************************************************************************/
@@ -2420,6 +2424,21 @@ public abstract class ASTNode {
throw new UnsupportedOperationException("Operation only supported in JLS17 AST"); //$NON-NLS-1$
}
}
+ /**
+ * Checks that this AST operation is only used when
+ * building JLS18 level ASTs.
+ * <p>
+ * Use this method to prevent access to new properties available only in JLS18.
+ * </p>
+ *
+ * @exception UnsupportedOperationException if this operation is not used in JLS18
+ * @since 3.28 BETA_JAVA 18
+ */
+ final void supportedOnlyIn18() {
+ if (this.ast.apiLevel != AST.JLS18_INTERNAL) {
+ throw new UnsupportedOperationException("Operation only supported in JLS17 AST"); //$NON-NLS-1$
+ }
+ }
/**
* Sets or clears this node's parent node and location.
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java
index dd0837fb61..1c92ef14b5 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.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
*******************************************************************************/
@@ -36,7 +40,7 @@ public class GuardedPattern extends Pattern{
GuardedPattern(AST ast) {
super(ast);
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
}
@@ -198,7 +202,7 @@ public class GuardedPattern extends Pattern{
* @return the expression node, or <code>null</code> if there is none
*/
public Expression getExpression() {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
return this.conditonalExpression;
}
@@ -213,7 +217,7 @@ public class GuardedPattern extends Pattern{
* @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
*/
public Pattern getPattern() {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
return this.pattern;
}
@@ -232,7 +236,7 @@ public class GuardedPattern extends Pattern{
* </ul>
*/
public void setExpression(Expression expression) {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
ASTNode oldChild = this.conditonalExpression;
preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY);
@@ -248,7 +252,7 @@ public class GuardedPattern extends Pattern{
* @exception UnsupportedOperationException if this operation is used without previewEnabled
*/
public void setPattern(Pattern pattern) {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
ASTNode oldChild = this.pattern;
preReplaceChild(oldChild, pattern, PATTERN_PROPERTY);
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypePattern.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypePattern.java
index 7990584fbf..f86030863c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypePattern.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypePattern.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
*******************************************************************************/
@@ -60,7 +64,7 @@ public class TypePattern extends Pattern {
TypePattern(AST ast) {
super(ast);
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
}
@@ -123,7 +127,7 @@ public class TypePattern extends Pattern {
@Override
public List<SingleVariableDeclaration> patternVariables() {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
return new ArrayList<SingleVariableDeclaration>(Arrays.asList(getPatternVariable()));
}
@@ -143,7 +147,7 @@ public class TypePattern extends Pattern {
* @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
*/
public void setPatternVariable(SingleVariableDeclaration patternVariable) {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
if (patternVariable == null) {
throw new IllegalArgumentException();
@@ -163,7 +167,7 @@ public class TypePattern extends Pattern {
* @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature.
*/
public SingleVariableDeclaration getPatternVariable() {
- supportedOnlyIn17();
+ supportedOnlyIn18();
unsupportedWithoutPreviewError();
if (this.patternVariable == null) {
// lazy init must be thread-safe for readers

Back to the top