Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library error_formatter; | 5 library error_formatter; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'generated/java_io.dart'; | 10 import 'generated/java_io.dart'; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 out.write(escapePipe(source.fullName)); | 117 out.write(escapePipe(source.fullName)); |
| 118 out.write('|'); | 118 out.write('|'); |
| 119 out.write(location.lineNumber); | 119 out.write(location.lineNumber); |
| 120 out.write('|'); | 120 out.write('|'); |
| 121 out.write(location.columnNumber); | 121 out.write(location.columnNumber); |
| 122 out.write('|'); | 122 out.write('|'); |
| 123 out.write(length); | 123 out.write(length); |
| 124 out.write('|'); | 124 out.write('|'); |
| 125 out.writeln(escapePipe(error.message)); | 125 out.writeln(escapePipe(error.message)); |
| 126 } else { | 126 } else { |
| 127 // [warning] 'foo' is not a method or function (/Users/devoncarew/temp/foo .dart:-1:-1) | 127 // [warning] 'foo' is not a method or function (/Users/devoncarew/temp/foo .dart:-1:-1) |
|
scheglov
2013/05/30 16:20:57
Update this comment too?
devoncarew
2013/05/30 16:24:51
Done.
| |
| 128 out.write('['); | 128 out.write('[${severity.displayName}] ${error.message} '); |
| 129 out.write(severity.displayName); | 129 out.write('(${source.fullName}'); |
| 130 out.write('] '); | 130 out.write(', line ${location.lineNumber}, col ${location.columnNumber})'); |
| 131 out.write(error.message); | |
| 132 out.write(' ('); | |
| 133 out.write(source.fullName); | |
| 134 out.write(':'); | |
| 135 out.write(location.lineNumber); | |
| 136 out.write(':'); | |
| 137 out.write(location.columnNumber); | |
| 138 out.writeln(')'); | |
| 139 } | 131 } |
| 140 } | 132 } |
| 141 | 133 |
| 142 static String escapePipe(String input) { | 134 static String escapePipe(String input) { |
| 143 var result = new StringBuffer(); | 135 var result = new StringBuffer(); |
| 144 for (var c in input.codeUnits) { | 136 for (var c in input.codeUnits) { |
| 145 if (c == '\\' || c == '|') { | 137 if (c == '\\' || c == '|') { |
| 146 result.write('\\'); | 138 result.write('\\'); |
| 147 } | 139 } |
| 148 result.writeCharCode(c); | 140 result.writeCharCode(c); |
| 149 } | 141 } |
| 150 return result.toString(); | 142 return result.toString(); |
| 151 } | 143 } |
| 152 | 144 |
| 153 static String pluralize(String word, int count) { | 145 static String pluralize(String word, int count) { |
| 154 if (count == 1) { | 146 if (count == 1) { |
| 155 return word; | 147 return word; |
| 156 } else { | 148 } else { |
| 157 return word + "s"; | 149 return word + "s"; |
| 158 } | 150 } |
| 159 } | 151 } |
| 160 } | 152 } |
| OLD | NEW |