| Index: pkg/analyzer_cli/lib/src/error_formatter.dart
|
| diff --git a/pkg/analyzer_cli/lib/src/error_formatter.dart b/pkg/analyzer_cli/lib/src/error_formatter.dart
|
| index 722fbd2da540f2b0b4611dcb5d641a6fe9425ef4..bac7f7ce80ad1137acd8a1517ac13209d41eeb88 100644
|
| --- a/pkg/analyzer_cli/lib/src/error_formatter.dart
|
| +++ b/pkg/analyzer_cli/lib/src/error_formatter.dart
|
| @@ -7,6 +7,7 @@ library analyzer_cli.src.error_formatter;
|
| import 'package:analyzer/error/error.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| +import 'package:analyzer_cli/src/ansi.dart';
|
| import 'package:analyzer_cli/src/options.dart';
|
| import 'package:path/path.dart' as path;
|
|
|
| @@ -103,6 +104,7 @@ class AnalysisStats {
|
| }
|
|
|
| /// Helper for formatting [AnalysisError]s.
|
| +///
|
| /// The two format options are a user consumable format and a machine consumable
|
| /// format.
|
| class ErrorFormatter {
|
| @@ -117,8 +119,12 @@ class ErrorFormatter {
|
|
|
| final _SeverityProcessor processSeverity;
|
|
|
| + AnsiLogger ansi;
|
| +
|
| ErrorFormatter(this.out, this.options, this.stats,
|
| - [this.processSeverity = _identity]);
|
| + [this.processSeverity = _identity]) {
|
| + ansi = new AnsiLogger(this.options.color);
|
| + }
|
|
|
| /// Compute the severity for this [error] or `null` if this error should be
|
| /// filtered.
|
| @@ -168,15 +174,21 @@ class ErrorFormatter {
|
| }
|
| }
|
|
|
| - int indent = errorType.length + 3;
|
| + final int errLength = ErrorSeverity.WARNING.displayName.length;
|
| + final int indent = errLength + 5;
|
|
|
| - // [warning] 'foo' is not a bar at lib/foo.dart:1:2 (foo_warning).
|
| + // warning • 'foo' is not a bar at lib/foo.dart:1:2 • foo_warning
|
| String message = error.message;
|
| // Remove any terminating '.' from the end of the message.
|
| if (message.endsWith('.')) {
|
| message = message.substring(0, message.length - 1);
|
| }
|
| - out.write('[$errorType] $message ');
|
| + String issueColor =
|
| + (severity == ErrorSeverity.ERROR || severity == ErrorSeverity.WARNING)
|
| + ? ansi.red
|
| + : '';
|
| + out.write(' $issueColor${errorType.padLeft(errLength)}${ansi.none} '
|
| + '${ansi.bullet} ${ansi.bold}$message${ansi.none} ');
|
| String sourceName;
|
| if (source.uriKind == UriKind.DART_URI) {
|
| sourceName = source.uri.toString();
|
| @@ -191,7 +203,7 @@ class ErrorFormatter {
|
| }
|
| out.write('at $sourceName');
|
| out.write(':${location.lineNumber}:${location.columnNumber} ');
|
| - out.write('(${error.errorCode.name.toLowerCase()}).');
|
| + out.write('${ansi.bullet} ${error.errorCode.name.toLowerCase()}');
|
| out.writeln();
|
|
|
| // If verbose, also print any associated correction.
|
|
|