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

Side by Side Diff: lib/src/location.dart

Issue 881673002: Cleanup equality operator to accept any Object rather than just a SourceLocation. (Closed) Base URL: git@github.com:dart-lang/source_span.git@master
Patch Set: PTAL Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ==(SourceLocation other) => 80 bool operator ==(other) =>
81 sourceUrl == other.sourceUrl && offset == other.offset; 81 other is SourceLocation && sourceUrl == other.sourceUrl &&
82 offset == other.offset;
82 83
83 int get hashCode => sourceUrl.hashCode + offset; 84 int get hashCode => sourceUrl.hashCode + offset;
84 85
85 String toString() => '<$runtimeType: $offset $toolString>'; 86 String toString() => '<$runtimeType: $offset $toolString>';
86 } 87 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698