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

Unified Diff: pkg/analyzer/lib/src/error.dart

Issue 189913004: Change to dart command line analyzer- Remove the rich toString in AnalyzerError to prevent .content… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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/lib/src/error.dart
diff --git a/pkg/analyzer/lib/src/error.dart b/pkg/analyzer/lib/src/error.dart
index 483c433d50963ff2924652029842f11ddb1308ec..ef0a3d3c198e1722e28d51167dd44c235c714e19 100644
--- a/pkg/analyzer/lib/src/error.dart
+++ b/pkg/analyzer/lib/src/error.dart
@@ -44,45 +44,50 @@ class AnalyzerError implements Exception {
String toString() {
var builder = new StringBuffer();
- var content = error.source.contents.data;
- var beforeError = content.substring(0, error.offset);
- var lineNumber = "\n".allMatches(beforeError).length + 1;
- builder.writeln("Error on line $lineNumber of ${error.source.fullName}: "
- "${error.message}");
-
- var errorLineIndex = beforeError.lastIndexOf("\n") + 1;
- var errorEndOfLineIndex = content.indexOf("\n", error.offset);
- if (errorEndOfLineIndex == -1) errorEndOfLineIndex = content.length;
- var errorLine = content.substring(
- errorLineIndex, errorEndOfLineIndex);
- var errorColumn = error.offset - errorLineIndex;
- var errorLength = error.length;
-
- // Ensure that the error line we display isn't too long.
- if (errorLine.length > _MAX_ERROR_LINE_LENGTH) {
- var leftLength = errorColumn;
- var rightLength = errorLine.length - leftLength;
- if (leftLength > _MAX_ERROR_LINE_LENGTH ~/ 2 &&
- rightLength > _MAX_ERROR_LINE_LENGTH ~/ 2) {
- errorLine = "..." + errorLine.substring(
- errorColumn - _MAX_ERROR_LINE_LENGTH ~/ 2 + 3,
- errorColumn + _MAX_ERROR_LINE_LENGTH ~/ 2 - 3)
- + "...";
- errorColumn = _MAX_ERROR_LINE_LENGTH ~/ 2;
- } else if (rightLength > _MAX_ERROR_LINE_LENGTH ~/ 2) {
- errorLine = errorLine.substring(0, _MAX_ERROR_LINE_LENGTH - 3) + "...";
- } else {
- assert(leftLength > _MAX_ERROR_LINE_LENGTH ~/ 2);
- errorColumn -= errorLine.length - _MAX_ERROR_LINE_LENGTH;
- errorLine = "..." + errorLine.substring(
- errorLine.length - _MAX_ERROR_LINE_LENGTH + 3, errorLine.length);
- }
- errorLength = math.min(errorLength, _MAX_ERROR_LINE_LENGTH - errorColumn);
- }
- builder.writeln(errorLine);
-
- for (var i = 0; i < errorColumn; i++) builder.write(" ");
- for (var i = 0; i < errorLength; i++) builder.write("^");
+
+ // Print a less friendly string representation to ensure that
+ // error.source.contents is not executed, as .contents it isn't async
+ builder.writeln("Error in ${error.source.fullName}: ${error.message}");
+
+// var content = error.source.contents.data;
+// var beforeError = content.substring(0, error.offset);
+// var lineNumber = "\n".allMatches(beforeError).length + 1;
+// builder.writeln("Error on line $lineNumber of ${error.source.fullName}: "
+// "${error.message}");
+
+// var errorLineIndex = beforeError.lastIndexOf("\n") + 1;
+// var errorEndOfLineIndex = content.indexOf("\n", error.offset);
+// if (errorEndOfLineIndex == -1) errorEndOfLineIndex = content.length;
+// var errorLine = content.substring(
+// errorLineIndex, errorEndOfLineIndex);
+// var errorColumn = error.offset - errorLineIndex;
+// var errorLength = error.length;
+//
+// // Ensure that the error line we display isn't too long.
+// if (errorLine.length > _MAX_ERROR_LINE_LENGTH) {
+// var leftLength = errorColumn;
+// var rightLength = errorLine.length - leftLength;
+// if (leftLength > _MAX_ERROR_LINE_LENGTH ~/ 2 &&
+// rightLength > _MAX_ERROR_LINE_LENGTH ~/ 2) {
+// errorLine = "..." + errorLine.substring(
+// errorColumn - _MAX_ERROR_LINE_LENGTH ~/ 2 + 3,
+// errorColumn + _MAX_ERROR_LINE_LENGTH ~/ 2 - 3)
+// + "...";
+// errorColumn = _MAX_ERROR_LINE_LENGTH ~/ 2;
+// } else if (rightLength > _MAX_ERROR_LINE_LENGTH ~/ 2) {
+// errorLine = errorLine.substring(0, _MAX_ERROR_LINE_LENGTH - 3) + "...";
+// } else {
+// assert(leftLength > _MAX_ERROR_LINE_LENGTH ~/ 2);
+// errorColumn -= errorLine.length - _MAX_ERROR_LINE_LENGTH;
+// errorLine = "..." + errorLine.substring(
+// errorLine.length - _MAX_ERROR_LINE_LENGTH + 3, errorLine.length);
+// }
+// errorLength = math.min(errorLength, _MAX_ERROR_LINE_LENGTH - errorColumn);
+// }
+// builder.writeln(errorLine);
+//
+// for (var i = 0; i < errorColumn; i++) builder.write(" ");
+// for (var i = 0; i < errorLength; i++) builder.write("^");
builder.writeln();
return builder.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