equal
deleted
inserted
replaced
91 private final JCDiagnostic.Factory diags; |
91 private final JCDiagnostic.Factory diags; |
92 private final JavaFileManager fileManager; |
92 private final JavaFileManager fileManager; |
93 private final Source source; |
93 private final Source source; |
94 private final Target target; |
94 private final Target target; |
95 private final Profile profile; |
95 private final Profile profile; |
|
96 private final Preview preview; |
96 private final boolean warnOnAnyAccessToMembers; |
97 private final boolean warnOnAnyAccessToMembers; |
97 |
98 |
98 // The set of lint options currently in effect. It is initialized |
99 // The set of lint options currently in effect. It is initialized |
99 // from the context, and then is set/reset as needed by Attr as it |
100 // from the context, and then is set/reset as needed by Attr as it |
100 // visits all the various parts of the trees during attribution. |
101 // visits all the various parts of the trees during attribution. |
137 |
138 |
138 Target target = Target.instance(context); |
139 Target target = Target.instance(context); |
139 syntheticNameChar = target.syntheticNameChar(); |
140 syntheticNameChar = target.syntheticNameChar(); |
140 |
141 |
141 profile = Profile.instance(context); |
142 profile = Profile.instance(context); |
|
143 preview = Preview.instance(context); |
142 |
144 |
143 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); |
145 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); |
144 boolean verboseRemoval = lint.isEnabled(LintCategory.REMOVAL); |
146 boolean verboseRemoval = lint.isEnabled(LintCategory.REMOVAL); |
145 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); |
147 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); |
146 boolean enforceMandatoryWarnings = true; |
148 boolean enforceMandatoryWarnings = true; |
220 deprecationHandler.report(pos, Warnings.HasBeenDeprecatedModule(sym)); |
222 deprecationHandler.report(pos, Warnings.HasBeenDeprecatedModule(sym)); |
221 } else { |
223 } else { |
222 deprecationHandler.report(pos, Warnings.HasBeenDeprecated(sym, sym.location())); |
224 deprecationHandler.report(pos, Warnings.HasBeenDeprecated(sym, sym.location())); |
223 } |
225 } |
224 } |
226 } |
|
227 } |
|
228 |
|
229 /** Warn about deprecated symbol. |
|
230 * @param pos Position to be used for error reporting. |
|
231 * @param sym The deprecated symbol. |
|
232 */ |
|
233 void warnPreview(DiagnosticPosition pos, Symbol sym) { |
|
234 warnPreview(pos, Warnings.IsPreview(sym)); |
|
235 } |
|
236 |
|
237 /** Log a preview warning. |
|
238 * @param pos Position to be used for error reporting. |
|
239 * @param msg A Warning describing the problem. |
|
240 */ |
|
241 public void warnPreview(DiagnosticPosition pos, Warning warnKey) { |
|
242 if (!lint.isSuppressed(LintCategory.PREVIEW)) |
|
243 preview.reportPreviewWarning(pos, warnKey); |
225 } |
244 } |
226 |
245 |
227 /** Warn about unchecked operation. |
246 /** Warn about unchecked operation. |
228 * @param pos Position to be used for error reporting. |
247 * @param pos Position to be used for error reporting. |
229 * @param msg A string describing the problem. |
248 * @param msg A string describing the problem. |
430 } |
449 } |
431 |
450 |
432 public void newRound() { |
451 public void newRound() { |
433 compiled.clear(); |
452 compiled.clear(); |
434 localClassNameIndexes.clear(); |
453 localClassNameIndexes.clear(); |
|
454 } |
|
455 |
|
456 public void clear() { |
|
457 deprecationHandler.clear(); |
|
458 removalHandler.clear(); |
|
459 uncheckedHandler.clear(); |
|
460 sunApiHandler.clear(); |
435 } |
461 } |
436 |
462 |
437 public void putCompiled(ClassSymbol csym) { |
463 public void putCompiled(ClassSymbol csym) { |
438 compiled.put(Pair.of(csym.packge().modle, csym.flatname), csym); |
464 compiled.put(Pair.of(csym.packge().modle, csym.flatname), csym); |
439 } |
465 } |
3288 if (profile != Profile.DEFAULT && (s.flags() & NOT_IN_PROFILE) != 0) { |
3314 if (profile != Profile.DEFAULT && (s.flags() & NOT_IN_PROFILE) != 0) { |
3289 log.error(pos, Errors.NotInProfile(s, profile)); |
3315 log.error(pos, Errors.NotInProfile(s, profile)); |
3290 } |
3316 } |
3291 } |
3317 } |
3292 |
3318 |
|
3319 void checkPreview(DiagnosticPosition pos, Symbol s) { |
|
3320 if ((s.flags() & PREVIEW_API) != 0) { |
|
3321 if ((s.flags() & PREVIEW_ESSENTIAL_API) != 0 && !preview.isEnabled()) { |
|
3322 log.error(pos, Errors.IsPreview(s)); |
|
3323 } else { |
|
3324 deferredLintHandler.report(() -> warnPreview(pos, s)); |
|
3325 } |
|
3326 } |
|
3327 } |
|
3328 |
3293 /* ************************************************************************* |
3329 /* ************************************************************************* |
3294 * Check for recursive annotation elements. |
3330 * Check for recursive annotation elements. |
3295 **************************************************************************/ |
3331 **************************************************************************/ |
3296 |
3332 |
3297 /** Check for cycles in the graph of annotation elements. |
3333 /** Check for cycles in the graph of annotation elements. |