Skip to content

Commit

Permalink
DRAFT: Make AST map pre 1.8 versions to 1.8
Browse files Browse the repository at this point in the history
As the compiler mandates 1.8 already it makes sense for the AST to do
the same.
  • Loading branch information
akurtakov committed Jan 8, 2025
1 parent 0ad9a2e commit c453896
Showing 1 changed file with 17 additions and 31 deletions.
48 changes: 17 additions & 31 deletions org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2024 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -1229,22 +1229,8 @@ public AST(Map options) {
this(apiLevelMap.get(options.get(JavaCore.COMPILER_SOURCE)),
JavaCore.ENABLED.equals(options.get(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)));

long sourceLevel;
long complianceLevel;
switch(this.apiLevel) {
case JLS2_INTERNAL :
case JLS3_INTERNAL :
sourceLevel = ClassFileConstants.JDK1_3;
complianceLevel = ClassFileConstants.JDK1_5;
break;
case JLS4_INTERNAL :
sourceLevel = ClassFileConstants.JDK1_7;
complianceLevel = ClassFileConstants.JDK1_7;
break;
default :
sourceLevel = AST.jdkLevelMap.get(options.get(JavaCore.COMPILER_SOURCE));
complianceLevel = sourceLevel;
}
long sourceLevel = AST.jdkLevelMap.get(options.get(JavaCore.COMPILER_SOURCE));
long complianceLevel = sourceLevel;
this.scanner = new Scanner(
true /*comment*/,
true /*whitespace*/,
Expand All @@ -1259,13 +1245,13 @@ public AST(Map options) {

private static Map<String, Long> getLevelMapTable() {
Map<String, Long> t = new HashMap<>();
t.put(null, ClassFileConstants.JDK1_2);
t.put(JavaCore.VERSION_1_2, ClassFileConstants.JDK1_2);
t.put(JavaCore.VERSION_1_3, ClassFileConstants.JDK1_3);
t.put(JavaCore.VERSION_1_4, ClassFileConstants.JDK1_4);
t.put(JavaCore.VERSION_1_5, ClassFileConstants.JDK1_5);
t.put(JavaCore.VERSION_1_6, ClassFileConstants.JDK1_6);
t.put(JavaCore.VERSION_1_7, ClassFileConstants.JDK1_7);
t.put(null, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_2, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_3, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_4, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_5, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_6, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_7, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_1_8, ClassFileConstants.JDK1_8);
t.put(JavaCore.VERSION_9, ClassFileConstants.JDK9);
t.put(JavaCore.VERSION_10, ClassFileConstants.JDK10);
Expand All @@ -1286,13 +1272,13 @@ private static Map<String, Long> getLevelMapTable() {
}
private static Map<String, Integer> getApiLevelMapTable() {
Map<String, Integer> t = new HashMap<>();
t.put(null, JLS2_INTERNAL);
t.put(JavaCore.VERSION_1_2, JLS2_INTERNAL);
t.put(JavaCore.VERSION_1_3, JLS3_INTERNAL);
t.put(JavaCore.VERSION_1_4, JLS4_INTERNAL);
t.put(JavaCore.VERSION_1_5, JLS4_INTERNAL);
t.put(JavaCore.VERSION_1_6, JLS4_INTERNAL);
t.put(JavaCore.VERSION_1_7, JLS4_INTERNAL);
t.put(null, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_2, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_3, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_4, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_5, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_6, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_7, JLS8_INTERNAL);
t.put(JavaCore.VERSION_1_8, JLS8_INTERNAL);
t.put(JavaCore.VERSION_9, JLS9_INTERNAL);
t.put(JavaCore.VERSION_10, JLS10_INTERNAL);
Expand Down

0 comments on commit c453896

Please sign in to comment.