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

Unified Diff: pkg/testing/lib/src/analyze.dart

Issue 2823293003: Parse escapes in analyzer machine output and handle Windows file names. (Closed)
Patch Set: Created 3 years, 8 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/testing/lib/src/analyze.dart
diff --git a/pkg/testing/lib/src/analyze.dart b/pkg/testing/lib/src/analyze.dart
index 0a41a57ecf186d0d5761f60cc117076eaf2518bc..6d92e07872917399d61034ce469c29248538e04b 100644
--- a/pkg/testing/lib/src/analyze.dart
+++ b/pkg/testing/lib/src/analyze.dart
@@ -68,19 +68,37 @@ class AnalyzerDiagnostic {
final String message;
+ static final Pattern unescapePattern = new RegExp(r"\\(.)");
+
AnalyzerDiagnostic(this.kind, this.detailedKind, this.code, this.uri,
this.line, this.startColumn, this.endColumn, this.message);
factory AnalyzerDiagnostic.fromLine(String line) {
- List<String> parts = line.split("|");
+ List<String> parts = <String>[];
+ int start = 0;
+ int index = line.indexOf("|");
+ while (index != -1) {
+ if (index > 0 && line[index - 1] == "\\") {
ahe 2017/04/19 04:05:28 This is not correct for cases like this: \\|
+ index = line.indexOf("|", index + 1);
+ } else {
+ parts.add(line
+ .substring(start, index)
+ .replaceAllMapped(unescapePattern, (Match m) => m[1]));
+ start = index + 1;
+ index = line.indexOf("|", start);
+ }
+ }
+ parts.add(line
+ .substring(start)
+ .replaceAllMapped(unescapePattern, (Match m) => m[1]));
if (parts.length != 8) {
- throw "Malformed output: $line";
+ throw "Malformed output: $line $parts";
}
return new AnalyzerDiagnostic(
parts[0],
parts[1],
parts[2],
- Uri.base.resolve(parts[3]),
+ Uri.base.resolveUri(new Uri.file(parts[3])),
int.parse(parts[4]),
int.parse(parts[5]),
int.parse(parts[6]),
@@ -88,7 +106,7 @@ class AnalyzerDiagnostic {
}
String toString() {
- return "$uri:$line:$startColumn: "
+ return "${uri.toFilePath()}:$line:$startColumn: "
"${kind == 'INFO' ? 'warning: hint' : kind.toLowerCase()}:\n"
"[$code] $message";
}
« 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