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 // A class that describes a single location within a source file. |
10 class SourceLocation implements Comparable<SourceLocation> { | 10 class SourceLocation implements Comparable<SourceLocation> { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 /// | 70 /// |
71 /// [other] must have the same source URL as [this]. | 71 /// [other] must have the same source URL as [this]. |
72 int compareTo(SourceLocation other) { | 72 int compareTo(SourceLocation other) { |
73 if (sourceUrl != other.sourceUrl) { | 73 if (sourceUrl != other.sourceUrl) { |
74 throw new ArgumentError("Source URLs \"${sourceUrl}\" and " | 74 throw new ArgumentError("Source URLs \"${sourceUrl}\" and " |
75 "\"${other.sourceUrl}\" don't match."); | 75 "\"${other.sourceUrl}\" don't match."); |
76 } | 76 } |
77 return offset - other.offset; | 77 return offset - other.offset; |
78 } | 78 } |
79 | 79 |
80 bool operator ==(other) => | 80 bool operator ==(other) => other is SourceLocation && |
81 other is SourceLocation && sourceUrl == other.sourceUrl && | 81 sourceUrl == other.sourceUrl && |
82 offset == other.offset; | 82 offset == other.offset; |
83 | 83 |
84 int get hashCode => sourceUrl.hashCode + offset; | 84 int get hashCode => sourceUrl.hashCode + offset; |
85 | 85 |
86 String toString() => '<$runtimeType: $offset $toolString>'; | 86 String toString() => '<$runtimeType: $offset $toolString>'; |
87 } | 87 } |
OLD | NEW |