| 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";
|
| }
|
|
|