89 |
89 |
90 /** |
90 /** |
91 * 13, no language features; text blocks and revised switch |
91 * 13, no language features; text blocks and revised switch |
92 * expressions in preview |
92 * expressions in preview |
93 */ |
93 */ |
94 JDK13("13"); |
94 JDK13("13"), |
|
95 |
|
96 /** |
|
97 * 14 covers the to be determined language features that will be |
|
98 * added in JDK 14. |
|
99 */ |
|
100 JDK14("14"); |
95 |
101 |
96 private static final Context.Key<Source> sourceKey = new Context.Key<>(); |
102 private static final Context.Key<Source> sourceKey = new Context.Key<>(); |
97 |
103 |
98 public static Source instance(Context context) { |
104 public static Source instance(Context context) { |
99 Source instance = context.get(sourceKey); |
105 Source instance = context.get(sourceKey); |
140 public boolean isSupported() { |
146 public boolean isSupported() { |
141 return this.compareTo(MIN) >= 0; |
147 return this.compareTo(MIN) >= 0; |
142 } |
148 } |
143 |
149 |
144 public Target requiredTarget() { |
150 public Target requiredTarget() { |
|
151 if (this.compareTo(JDK14) >= 0) return Target.JDK1_14; |
145 if (this.compareTo(JDK13) >= 0) return Target.JDK1_13; |
152 if (this.compareTo(JDK13) >= 0) return Target.JDK1_13; |
146 if (this.compareTo(JDK12) >= 0) return Target.JDK1_12; |
153 if (this.compareTo(JDK12) >= 0) return Target.JDK1_12; |
147 if (this.compareTo(JDK11) >= 0) return Target.JDK1_11; |
154 if (this.compareTo(JDK11) >= 0) return Target.JDK1_11; |
148 if (this.compareTo(JDK10) >= 0) return Target.JDK1_10; |
155 if (this.compareTo(JDK10) >= 0) return Target.JDK1_10; |
149 if (this.compareTo(JDK9) >= 0) return Target.JDK1_9; |
156 if (this.compareTo(JDK9) >= 0) return Target.JDK1_9; |
187 UNDERSCORE_IDENTIFIER(MIN, JDK8), |
194 UNDERSCORE_IDENTIFIER(MIN, JDK8), |
188 PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL), |
195 PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL), |
189 LOCAL_VARIABLE_TYPE_INFERENCE(JDK10), |
196 LOCAL_VARIABLE_TYPE_INFERENCE(JDK10), |
190 VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL), |
197 VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL), |
191 IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8), |
198 IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8), |
192 SWITCH_MULTIPLE_CASE_LABELS(JDK13, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL), |
199 SWITCH_MULTIPLE_CASE_LABELS(JDK14, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL), |
193 SWITCH_RULE(JDK13, Fragments.FeatureSwitchRules, DiagKind.PLURAL), |
200 SWITCH_RULE(JDK14, Fragments.FeatureSwitchRules, DiagKind.PLURAL), |
194 SWITCH_EXPRESSION(JDK13, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL), |
201 SWITCH_EXPRESSION(JDK14, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL), |
195 TEXT_BLOCKS(JDK13, Fragments.FeatureTextBlocks, DiagKind.PLURAL); |
202 TEXT_BLOCKS(JDK14, Fragments.FeatureTextBlocks, DiagKind.PLURAL); |
196 |
203 |
197 enum DiagKind { |
204 enum DiagKind { |
198 NORMAL, |
205 NORMAL, |
199 PLURAL; |
206 PLURAL; |
200 } |
207 } |