Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2661)

Unified Diff: pkg/analyzer_cli/lib/src/error_formatter.dart

Issue 2770493003: fixes #29095, machine mode escapes newline/returns (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20a0efbd68140e664bacef1269335975bcf50427..722fbd2da540f2b0b4611dcb5d641a6fe9425ef4 100644
--- a/pkg/analyzer_cli/lib/src/error_formatter.dart
+++ b/pkg/analyzer_cli/lib/src/error_formatter.dart
@@ -108,6 +108,8 @@ class AnalysisStats {
class ErrorFormatter {
static final int _pipeCodeUnit = '|'.codeUnitAt(0);
static final int _slashCodeUnit = '\\'.codeUnitAt(0);
+ static final int _newline = '\n'.codeUnitAt(0);
+ static final int _return = '\r'.codeUnitAt(0);
final StringSink out;
final CommandLineOptions options;
@@ -144,7 +146,7 @@ class ErrorFormatter {
out.write('|');
out.write(error.errorCode.name);
out.write('|');
- out.write(escapePipe(source.fullName));
+ out.write(escapeForMachineMode(source.fullName));
out.write('|');
out.write(location.lineNumber);
out.write('|');
@@ -152,7 +154,7 @@ class ErrorFormatter {
out.write('|');
out.write(length);
out.write('|');
- out.write(escapePipe(error.message));
+ out.write(escapeForMachineMode(error.message));
out.writeln();
} else {
// Get display name.
@@ -252,13 +254,19 @@ class ErrorFormatter {
}
}
- static String escapePipe(String input) {
+ static String escapeForMachineMode(String input) {
StringBuffer result = new StringBuffer();
for (int c in input.codeUnits) {
- if (c == _slashCodeUnit || c == _pipeCodeUnit) {
- result.write('\\');
+ if (c == _newline) {
+ result.write(r'\n');
+ } else if (c == _return) {
+ result.write(r'\r');
+ } else {
+ if (c == _slashCodeUnit || c == _pipeCodeUnit) {
+ result.write('\\');
+ }
+ result.writeCharCode(c);
}
- result.writeCharCode(c);
}
return result.toString();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698