| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 source_span.location; | 5 library source_span.location; |
| 6 | 6 |
| 7 import 'span.dart'; | 7 import 'span.dart'; |
| 8 | 8 |
| 9 // A class that describes a single location within a source file. | 9 // TODO(nweiz): Use SourceLocationMixin once we decide to cut a release with |
| 10 // breaking changes. See SourceLocationMixin for details. |
| 11 |
| 12 /// A class that describes a single location within a source file. |
| 13 /// |
| 14 /// This class should not be extended. Instead, [SourceLocationBase] should be |
| 15 /// extended instead. |
| 10 class SourceLocation implements Comparable<SourceLocation> { | 16 class SourceLocation implements Comparable<SourceLocation> { |
| 11 /// URL of the source containing this location. | 17 /// URL of the source containing this location. |
| 12 /// | 18 /// |
| 13 /// This may be null, indicating that the source URL is unknown or | 19 /// This may be null, indicating that the source URL is unknown or |
| 14 /// unavailable. | 20 /// unavailable. |
| 15 final Uri sourceUrl; | 21 final Uri sourceUrl; |
| 16 | 22 |
| 17 /// The 0-based offset of this location in the source. | 23 /// The 0-based offset of this location in the source. |
| 18 final int offset; | 24 final int offset; |
| 19 | 25 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 84 } |
| 79 | 85 |
| 80 bool operator ==(other) => | 86 bool operator ==(other) => |
| 81 other is SourceLocation && sourceUrl == other.sourceUrl && | 87 other is SourceLocation && sourceUrl == other.sourceUrl && |
| 82 offset == other.offset; | 88 offset == other.offset; |
| 83 | 89 |
| 84 int get hashCode => sourceUrl.hashCode + offset; | 90 int get hashCode => sourceUrl.hashCode + offset; |
| 85 | 91 |
| 86 String toString() => '<$runtimeType: $offset $toolString>'; | 92 String toString() => '<$runtimeType: $offset $toolString>'; |
| 87 } | 93 } |
| 94 |
| 95 /// A base class for source locations with [offset], [line], and [column] known |
| 96 /// at construction time. |
| 97 class SourceLocationBase extends SourceLocation { |
| 98 SourceLocationBase(int offset, {sourceUrl, int line, int column}) |
| 99 : super(offset, sourceUrl: sourceUrl, line: line, column: column); |
| 100 } |
| OLD | NEW |