| 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 /// Dart classes representing the souce spans and source files. | 5 /// Dart classes representing the souce spans and source files. |
| 6 library source_maps.span; | 6 library source_maps.span; |
| 7 | 7 |
| 8 import 'dart:utf' show stringToCodepoints; | 8 import 'dart:utf' show stringToCodepoints; |
| 9 import 'dart:math' show min, max; | 9 import 'dart:math' show min, max; |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 String get formatLocation => start.formatString; | 62 String get formatLocation => start.formatString; |
| 63 | 63 |
| 64 String getLocationMessage(String message, | 64 String getLocationMessage(String message, |
| 65 {bool useColors: false, String color}) { | 65 {bool useColors: false, String color}) { |
| 66 return '$formatLocation: $message'; | 66 return '$formatLocation: $message'; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool operator ==(Span other) => | 69 bool operator ==(Span other) => |
| 70 sourceUrl == other.sourceUrl && start == other.start && end == other.end; | 70 sourceUrl == other.sourceUrl && start == other.start && end == other.end; |
| 71 | 71 |
| 72 int get hashCode => sourceUrl.hashCode + start + (31 * (end - start)); |
| 73 |
| 72 String toString() => '<$runtimeType: $start $end $formatLocation $text>'; | 74 String toString() => '<$runtimeType: $start $end $formatLocation $text>'; |
| 73 } | 75 } |
| 74 | 76 |
| 75 /// A location in the source text | 77 /// A location in the source text |
| 76 abstract class Location implements Comparable { | 78 abstract class Location implements Comparable { |
| 77 /// Url of the source containing this span. | 79 /// Url of the source containing this span. |
| 78 String get sourceUrl; | 80 String get sourceUrl; |
| 79 | 81 |
| 80 /// The offset of this location, 0-based. | 82 /// The offset of this location, 0-based. |
| 81 final int offset; | 83 final int offset; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 int getOffset(int line, int column) => | 347 int getOffset(int line, int column) => |
| 346 super.getOffset(line - _baseLine, | 348 super.getOffset(line - _baseLine, |
| 347 line == _baseLine ? column - _baseColumn : column) + _baseOffset; | 349 line == _baseLine ? column - _baseColumn : column) + _baseOffset; |
| 348 | 350 |
| 349 /// Retrieve the text associated with the specified range. This method | 351 /// Retrieve the text associated with the specified range. This method |
| 350 /// operates on the real offsets from the original file, so that error | 352 /// operates on the real offsets from the original file, so that error |
| 351 /// messages can be reported accurately. | 353 /// messages can be reported accurately. |
| 352 String getText(int start, [int end]) => | 354 String getText(int start, [int end]) => |
| 353 super.getText(start - _baseOffset, end == null ? null : end - _baseOffset); | 355 super.getText(start - _baseOffset, end == null ? null : end - _baseOffset); |
| 354 } | 356 } |
| OLD | NEW |