src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
changeset 53023 6879069d9d94
parent 52016 9ea22a0f9540
child 53040 6aeb6a23fb83
equal deleted inserted replaced
53022:ece620f32d2d 53023:6879069d9d94
    83 
    83 
    84     /** 1.11 local-variable syntax for lambda parameters */
    84     /** 1.11 local-variable syntax for lambda parameters */
    85     JDK11("11"),
    85     JDK11("11"),
    86 
    86 
    87     /** 12 covers the to be determined language features that will be added in JDK 12. */
    87     /** 12 covers the to be determined language features that will be added in JDK 12. */
    88     JDK12("12");
    88     JDK12("12"),
       
    89 
       
    90     /** 13 covers the to be determined language features that will be added in JDK 13. */
       
    91     JDK13("13");
    89 
    92 
    90     private static final Context.Key<Source> sourceKey = new Context.Key<>();
    93     private static final Context.Key<Source> sourceKey = new Context.Key<>();
    91 
    94 
    92     public static Source instance(Context context) {
    95     public static Source instance(Context context) {
    93         Source instance = context.get(sourceKey);
    96         Source instance = context.get(sourceKey);
   134     public boolean isSupported() {
   137     public boolean isSupported() {
   135         return this.compareTo(MIN) >= 0;
   138         return this.compareTo(MIN) >= 0;
   136     }
   139     }
   137 
   140 
   138     public Target requiredTarget() {
   141     public Target requiredTarget() {
       
   142         if (this.compareTo(JDK13) >= 0) return Target.JDK1_13;
   139         if (this.compareTo(JDK12) >= 0) return Target.JDK1_12;
   143         if (this.compareTo(JDK12) >= 0) return Target.JDK1_12;
   140         if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
   144         if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
   141         if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
   145         if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
   142         if (this.compareTo(JDK9) >= 0) return Target.JDK1_9;
   146         if (this.compareTo(JDK9) >= 0) return Target.JDK1_9;
   143         if (this.compareTo(JDK8) >= 0) return Target.JDK1_8;
   147         if (this.compareTo(JDK8) >= 0) return Target.JDK1_8;
   180         UNDERSCORE_IDENTIFIER(MIN, JDK8),
   184         UNDERSCORE_IDENTIFIER(MIN, JDK8),
   181         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
   185         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
   182         LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
   186         LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
   183         VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL),
   187         VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL),
   184         IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8),
   188         IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8),
   185         SWITCH_MULTIPLE_CASE_LABELS(JDK12, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
   189         SWITCH_MULTIPLE_CASE_LABELS(JDK13, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
   186         SWITCH_RULE(JDK12, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
   190         SWITCH_RULE(JDK13, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
   187         SWITCH_EXPRESSION(JDK12, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
   191         SWITCH_EXPRESSION(JDK13, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
   188         RAW_STRING_LITERALS(JDK12, Fragments.FeatureRawStringLiterals, DiagKind.PLURAL);
   192         RAW_STRING_LITERALS(JDK13, Fragments.FeatureRawStringLiterals, DiagKind.PLURAL);
   189 
   193 
   190         enum DiagKind {
   194         enum DiagKind {
   191             NORMAL,
   195             NORMAL,
   192             PLURAL;
   196             PLURAL;
   193         }
   197         }
   268             return RELEASE_10;
   272             return RELEASE_10;
   269         case JDK11:
   273         case JDK11:
   270             return RELEASE_11;
   274             return RELEASE_11;
   271         case JDK12:
   275         case JDK12:
   272             return RELEASE_12;
   276             return RELEASE_12;
       
   277         case JDK13:
       
   278             return RELEASE_13;
   273         default:
   279         default:
   274             return null;
   280             return null;
   275         }
   281         }
   276     }
   282     }
   277 }
   283 }