| 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 library error; | 4 library error; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 | 8 |
| 9 import 'generated/error.dart'; | 9 import 'generated/error.dart'; |
| 10 import 'generated/source.dart'; | 10 import 'generated/source.dart'; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 AnalyzerError(this.error); | 41 AnalyzerError(this.error); |
| 42 | 42 |
| 43 String get message => toString(); | 43 String get message => toString(); |
| 44 | 44 |
| 45 String toString() { | 45 String toString() { |
| 46 var builder = new StringBuffer(); | 46 var builder = new StringBuffer(); |
| 47 | 47 |
| 48 // Print a less friendly string representation to ensure that | 48 // Print a less friendly string representation to ensure that |
| 49 // error.source.contents is not executed, as .contents it isn't async | 49 // error.source.contents is not executed, as .contents it isn't async |
| 50 builder.writeln("Error in ${error.source.fullName}: ${error.message}"); | 50 builder.write("Error in ${error.source.shortName}: ${error.message}"); |
| 51 | 51 |
| 52 // var content = error.source.contents.data; | 52 // var content = error.source.contents.data; |
| 53 // var beforeError = content.substring(0, error.offset); | 53 // var beforeError = content.substring(0, error.offset); |
| 54 // var lineNumber = "\n".allMatches(beforeError).length + 1; | 54 // var lineNumber = "\n".allMatches(beforeError).length + 1; |
| 55 // builder.writeln("Error on line $lineNumber of ${error.source.fullName}: " | 55 // builder.writeln("Error on line $lineNumber of ${error.source.fullName}: " |
| 56 // "${error.message}"); | 56 // "${error.message}"); |
| 57 | 57 |
| 58 // var errorLineIndex = beforeError.lastIndexOf("\n") + 1; | 58 // var errorLineIndex = beforeError.lastIndexOf("\n") + 1; |
| 59 // var errorEndOfLineIndex = content.indexOf("\n", error.offset); | 59 // var errorEndOfLineIndex = content.indexOf("\n", error.offset); |
| 60 // if (errorEndOfLineIndex == -1) errorEndOfLineIndex = content.length; | 60 // if (errorEndOfLineIndex == -1) errorEndOfLineIndex = content.length; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // A content receiver that collects all the content into a string. | 97 // A content receiver that collects all the content into a string. |
| 98 class _ContentReceiver implements Source_ContentReceiver { | 98 class _ContentReceiver implements Source_ContentReceiver { |
| 99 final _buffer = new StringBuffer(); | 99 final _buffer = new StringBuffer(); |
| 100 | 100 |
| 101 String get result => _buffer.toString(); | 101 String get result => _buffer.toString(); |
| 102 | 102 |
| 103 void accept(String contents, _) => | 103 void accept(String contents, _) => |
| 104 _buffer.write(contents.substring(0, contents.length)); | 104 _buffer.write(contents.substring(0, contents.length)); |
| 105 } | 105 } |
| OLD | NEW |