Skip to content

Commit

Permalink
Add Java 23 constants for AST
Browse files Browse the repository at this point in the history
Backports AST Java 23 constants and helper methods of
eclipse-jdt@3e78c6e
to master.
  • Loading branch information
akurtakov committed Apr 23, 2024
1 parent f53ffcb commit c0bffa4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
25 changes: 24 additions & 1 deletion org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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).
* </p>
*
* @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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1260,6 +1281,7 @@ private static Map<String, Long> 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<String, Integer> getApiLevelMapTable() {
Expand All @@ -1286,6 +1308,7 @@ private static Map<String, Integer> 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);
}
/**
Expand Down
15 changes: 15 additions & 0 deletions org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2613,6 +2613,21 @@ final void supportedOnlyIn22() {
}
}
/**
* Checks that this AST operation is only used when
* building JLS23 level ASTs.
* <p>
* Use this method to prevent access to new properties available only in JLS23.
* </p>
*
* @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.
* <p>
Expand Down

0 comments on commit c0bffa4

Please sign in to comment.