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

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

Issue 1307123004: Add SourceLocationMixin and SourceLocationBase. (Closed) Base URL: git@github.com:dart-lang/source_span@master
Patch Set: Code review changes Created 5 years, 3 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 | « lib/src/file.dart ('k') | lib/src/location_mixin.dart » ('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 // 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
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 }
OLDNEW
« no previous file with comments | « lib/src/file.dart ('k') | lib/src/location_mixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698