Skip to content

Commit

Permalink
Stop deleting the terminating period on diagnostic messages
Browse files Browse the repository at this point in the history
We have messages that contain more than one sentence, and sometimes
include end-of-line markers. We really need to do more to improve the
output in these cases, but this is a start.

Change-Id: I4750feae0a8e6665a8243c6d15726350b26a558b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
  • Loading branch information
bwilkerson authored and commit-bot@chromium.org committed Aug 21, 2019
1 parent d252efa commit 1953309
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
13 changes: 4 additions & 9 deletions pkg/analyzer_cli/lib/src/error_formatter.dart
Expand Up @@ -248,14 +248,14 @@ class HumanErrorFormatter extends ErrorFormatter {
stats.hintCount++;
}

// warning • 'foo' is not a bar at lib/foo.dart:1:2 • foo_warning
// warning • 'foo' is not a bar. • lib/foo.dart:1:2 • foo_warning
String issueColor = (error.isError == ErrorSeverity.ERROR ||
error.isWarning == ErrorSeverity.WARNING)
? ansi.red
: '';
out.write(' $issueColor${error.severity}${ansi.none} '
'${ansi.bullet} ${ansi.bold}${error.message}${ansi.none} ');
out.write('at ${error.sourcePath}');
out.write('${ansi.bullet} ${error.sourcePath}');
out.write(':${error.line}:${error.column} ');
out.write('${ansi.bullet} ${error.errorCode}');
out.writeln();
Expand Down Expand Up @@ -298,12 +298,7 @@ class HumanErrorFormatter extends ErrorFormatter {
}
}

// 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);
}
// warning • 'foo' is not a bar. • lib/foo.dart:1:2 • foo_warning
String sourcePath;
if (source.uriKind == UriKind.DART_URI) {
sourcePath = source.uri.toString();
Expand Down Expand Up @@ -334,7 +329,7 @@ class HumanErrorFormatter extends ErrorFormatter {
offset: error.offset,
line: location.lineNumber,
column: location.columnNumber,
message: message,
message: error.message,
contextMessages: contextMessages,
errorCode: error.errorCode.name.toLowerCase(),
correction: error.correction,
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer_cli/test/reporter_test.dart
Expand Up @@ -45,7 +45,7 @@ main() {
reporter.flush();

expect(out.toString().trim(),
'error • MSG at /foo/bar/baz.dart:3:3 • mock_code');
'error • MSG /foo/bar/baz.dart:3:3 • mock_code');
});

test('hint', () {
Expand All @@ -54,7 +54,7 @@ main() {
reporter.flush();

expect(out.toString().trim(),
'hint • MSG at /foo/bar/baz.dart:3:3 • mock_code');
'hint • MSG /foo/bar/baz.dart:3:3 • mock_code');
});

test('stats', () {
Expand All @@ -64,7 +64,7 @@ main() {
stats.print(out);
expect(
out.toString().trim(),
'hint • MSG at /foo/bar/baz.dart:3:3 • mock_code\n'
'hint • MSG /foo/bar/baz.dart:3:3 • mock_code\n'
'1 hint found.');
});
});
Expand Down

0 comments on commit 1953309

Please sign in to comment.