55import 'dart:convert' ;
66
77import 'package:analyzer/dart/analysis/results.dart' ;
8+ import 'package:analyzer/diagnostic/diagnostic.dart' ;
89import 'package:analyzer/error/error.dart' ;
910import 'package:analyzer/source/line_info.dart' ;
1011import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart' ;
@@ -28,13 +29,13 @@ String _relative(String file) {
2829 return file.startsWith (path.current) ? path.relative (file) : file;
2930}
3031
31- /// Returns the given error 's severity.
32- DiagnosticSeverity _severityIdentity (AnalysisError error ) =>
33- error .errorCode.errorSeverity;
32+ /// Returns the given diagnostic 's severity.
33+ DiagnosticSeverity _severityIdentity (Diagnostic diagnostic ) =>
34+ diagnostic .errorCode.errorSeverity;
3435
35- /// Returns desired severity for the given [error ] (or `null` if it's to be
36+ /// Returns desired severity for the given [diagnostic ] (or `null` if it's to be
3637/// suppressed).
37- typedef SeverityProcessor = DiagnosticSeverity ? Function (AnalysisError error );
38+ typedef SeverityProcessor = DiagnosticSeverity ? Function (Diagnostic diagnostic );
3839
3940/// Analysis statistics counter.
4041class AnalysisStats {
@@ -103,7 +104,7 @@ class AnalysisStats {
103104 }
104105}
105106
106- /// An [AnalysisError ] with line and column information.
107+ /// A [Diagnostic ] with line and column information.
107108class CLIError implements Comparable <CLIError > {
108109 final String severity;
109110 final String sourcePath;
@@ -174,7 +175,7 @@ class ContextMessage {
174175 ContextMessage (this .filePath, this .message, this .line, this .column);
175176}
176177
177- /// Helper for formatting [AnalysisError ] s.
178+ /// Helper for formatting [Diagnostic ] s.
178179///
179180/// The two format options are a user consumable format and a machine consumable
180181/// format.
@@ -194,34 +195,34 @@ abstract class ErrorFormatter {
194195 /// Call to write any batched up errors from [formatErrors] .
195196 void flush ();
196197
197- Future <void > formatError (
198- Map <AnalysisError , ErrorsResult > errorToLine,
199- AnalysisError error,
198+ Future <void > formatDiagnostic (
199+ Map <Diagnostic , ErrorsResult > errorToLine,
200+ Diagnostic error,
200201 );
201202
202203 Future <void > formatErrors (List <ErrorsResult > results) async {
203204 stats.unfilteredCount += results.length;
204205
205- var errors = < AnalysisError > [];
206- var errorToLine = < AnalysisError , ErrorsResult > {};
206+ var diagnostics = < Diagnostic > [];
207+ var diagnosticToLine = < Diagnostic , ErrorsResult > {};
207208 for (var result in results) {
208209 for (var error in result.errors) {
209210 if (_computeSeverity (error) != null ) {
210- errors .add (error);
211- errorToLine [error] = result;
211+ diagnostics .add (error);
212+ diagnosticToLine [error] = result;
212213 }
213214 }
214215 }
215216
216- for (var error in errors ) {
217- await formatError (errorToLine , error);
217+ for (var error in diagnostics ) {
218+ await formatDiagnostic (diagnosticToLine , error);
218219 }
219220 }
220221
221- /// Compute the severity for this [error ] or `null` if this error should be
222- /// filtered.
223- DiagnosticSeverity ? _computeSeverity (AnalysisError error ) =>
224- _severityProcessor (error );
222+ /// Compute the severity for this [diagnostic ] or `null` if this error should
223+ /// be filtered.
224+ DiagnosticSeverity ? _computeSeverity (Diagnostic diagnostic ) =>
225+ _severityProcessor (diagnostic );
225226}
226227
227228class HumanErrorFormatter extends ErrorFormatter {
@@ -287,9 +288,9 @@ class HumanErrorFormatter extends ErrorFormatter {
287288 }
288289
289290 @override
290- Future <void > formatError (
291- Map <AnalysisError , ErrorsResult > errorToLine,
292- AnalysisError error,
291+ Future <void > formatDiagnostic (
292+ Map <Diagnostic , ErrorsResult > errorToLine,
293+ Diagnostic error,
293294 ) async {
294295 var source = error.source;
295296 var result = errorToLine[error]! ;
@@ -369,9 +370,9 @@ class JsonErrorFormatter extends ErrorFormatter {
369370 void flush () {}
370371
371372 @override
372- Future <void > formatError (
373- Map <AnalysisError , ErrorsResult > errorToLine,
374- AnalysisError error,
373+ Future <void > formatDiagnostic (
374+ Map <Diagnostic , ErrorsResult > errorToLine,
375+ Diagnostic error,
375376 ) async {
376377 throw UnsupportedError ('Cannot format a single error' );
377378 }
@@ -461,7 +462,7 @@ class MachineErrorFormatter extends ErrorFormatter {
461462 static final int _slashCodeUnit = '\\ ' .codeUnitAt (0 );
462463 static final int _newline = '\n ' .codeUnitAt (0 );
463464 static final int _return = '\r ' .codeUnitAt (0 );
464- final Set <AnalysisError > _seenErrors = < AnalysisError > {};
465+ final Set <Diagnostic > _seenDiagnostics = < Diagnostic > {};
465466
466467 MachineErrorFormatter (
467468 super .out,
@@ -474,12 +475,12 @@ class MachineErrorFormatter extends ErrorFormatter {
474475 void flush () {}
475476
476477 @override
477- Future <void > formatError (
478- Map <AnalysisError , ErrorsResult > errorToLine,
479- AnalysisError error,
478+ Future <void > formatDiagnostic (
479+ Map <Diagnostic , ErrorsResult > errorToLine,
480+ Diagnostic error,
480481 ) async {
481482 // Ensure we don't over-report (#36062).
482- if (! _seenErrors .add (error)) {
483+ if (! _seenDiagnostics .add (error)) {
483484 return ;
484485 }
485486 var source = error.source;
0 commit comments