From c0bffa4ff79add2104955c6d9663d96ba8095432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Sat, 20 Apr 2024 09:41:12 +0300 Subject: [PATCH] Add Java 23 constants for AST Backports AST Java 23 constants and helper methods of https://github.com/eclipse-jdt/eclipse.jdt.core/commit/3e78c6e69a239a51d3d4e7c8c070ec488ce9fa89 to master. --- .../dom/org/eclipse/jdt/core/dom/AST.java | 25 ++++++++++++++++++- .../dom/org/eclipse/jdt/core/dom/ASTNode.java | 15 +++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) 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 4d56d7c5d31..daa8cc9a1e1 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 @@ -469,6 +469,22 @@ public final class AST { * @since 3.38 */ public static final int JLS22 = 22; + /** + * Constant for indicating the AST API that handles JLS23. + *

+ * This API is capable of handling all constructs in the + * Java language as described in the Java Language + * Specification, Java SE 23 Edition (JLS23). + * JLS23 is a superset of all earlier versions of the + * Java language, and the JLS23 API can be used to manipulate + * programs written in all versions of the Java language + * up to and including Java SE 23(aka JDK 23). + *

+ * + * @noreference This field is not intended to be referenced by clients. Java 23 support is WIP. + * @since 3.38 + */ + public static final int JLS23 = 23; /** * Internal synonym for {@link #JLS15}. Use to alleviate * deprecation warnings once JLS15 is deprecated @@ -506,9 +522,14 @@ public final class AST { static final int JLS21_INTERNAL = JLS21; /** * Internal synonym for {@link #JLS22}. Use to alleviate - * deprecation warnings once JLS21 is deprecated + * deprecation warnings once JLS22 is deprecated */ static final int JLS22_INTERNAL = JLS22; + /** + * Internal synonym for {@link #JLS23}. Use to alleviate + * deprecation warnings once JLS23 is deprecated + */ + static final int JLS23_INTERNAL = JLS23; /** * Internal property for latest supported JLS level * This provides the latest JLS level. @@ -1260,6 +1281,7 @@ private static Map getLevelMapTable() { t.put(JavaCore.VERSION_20, ClassFileConstants.JDK20); t.put(JavaCore.VERSION_21, ClassFileConstants.JDK21); t.put(JavaCore.VERSION_22, ClassFileConstants.JDK22); + t.put(JavaCore.VERSION_23, ClassFileConstants.JDK23); return Collections.unmodifiableMap(t); } private static Map getApiLevelMapTable() { @@ -1286,6 +1308,7 @@ private static Map getApiLevelMapTable() { t.put(JavaCore.VERSION_20, JLS20_INTERNAL); t.put(JavaCore.VERSION_21, JLS21_INTERNAL); t.put(JavaCore.VERSION_22, JLS22_INTERNAL); + t.put(JavaCore.VERSION_23, JLS23_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 c10e1e324b4..401c1dc3af6 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 @@ -2613,6 +2613,21 @@ final void supportedOnlyIn22() { } } /** + * Checks that this AST operation is only used when + * building JLS23 level ASTs. + *

+ * Use this method to prevent access to new properties available only in JLS23. + *

+ * + * @exception UnsupportedOperationException if this operation is not used in JLS23 + * @since 3.38 + */ + final void supportedOnlyIn23() { + if (this.ast.apiLevel < AST.JLS23_INTERNAL) { + throw new UnsupportedOperationException("Operation only supported in JLS23 AST"); //$NON-NLS-1$ + } + } + /** * Checks that this AST operation is not used when * building JLS20 level ASTs. *