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

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

Issue 2823293003: Parse escapes in analyzer machine output and handle Windows file names. (Closed)
Patch Set: Update parsing of escapes. 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..85e4dcc6a46528ccaf974839bb86d9275f2664f9 100644
--- a/pkg/testing/lib/src/analyze.dart
+++ b/pkg/testing/lib/src/analyze.dart
@@ -68,19 +68,44 @@ class AnalyzerDiagnostic {
final String message;
+ static final Pattern potentialSplitPattern = new RegExp(r"\\|\|");
+
+ static final Pattern unescapePattern = new RegExp(r"\\(.)");
+
AnalyzerDiagnostic(this.kind, this.detailedKind, this.code, this.uri,
this.line, this.startColumn, this.endColumn, this.message);
+ AnalyzerDiagnostic.malformed(String line)
+ : this(null, null, null, null, -1, -1, -1, line);
+
factory AnalyzerDiagnostic.fromLine(String line) {
- List<String> parts = line.split("|");
+ List<String> parts = <String>[];
+ int start = 0;
+ int index = line.indexOf(potentialSplitPattern);
+ addPart() {
+ parts.add(line
+ .substring(start, index == -1 ? null : index)
+ .replaceAllMapped(unescapePattern, (Match m) => m[1]));
+ }
+
+ while (index != -1) {
+ if (line[index] == "\\") {
+ index = line.indexOf(potentialSplitPattern, index + 2);
+ } else {
+ addPart();
+ start = index + 1;
+ index = line.indexOf(potentialSplitPattern, start);
+ }
+ }
+ addPart();
if (parts.length != 8) {
- throw "Malformed output: $line";
+ return new AnalyzerDiagnostic.malformed(line);
}
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 +113,9 @@ class AnalyzerDiagnostic {
}
String toString() {
- return "$uri:$line:$startColumn: "
+ return kind == null
+ ? "Malformed output from dartanalyzer:\n$message"
+ : "${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