Index: lib/src/location.dart |
diff --git a/lib/src/location.dart b/lib/src/location.dart |
index 2d23db1a3d7b67cb6d0146c285a6ef245ce71bef..0dbf44c2806dd90653f5b62c1b272ee99631dc2a 100644 |
--- a/lib/src/location.dart |
+++ b/lib/src/location.dart |
@@ -12,20 +12,27 @@ import 'span.dart'; |
/// This class should not be extended. Instead, [SourceLocationBase] should be |
/// extended instead. |
class SourceLocation implements Comparable<SourceLocation> { |
+ // These fields go through getters so that subclasses of [SourceLocationBase] |
+ // can override them. |
+ |
/// URL of the source containing this location. |
/// |
/// This may be null, indicating that the source URL is unknown or |
/// unavailable. |
- final Uri sourceUrl; |
+ Uri get sourceUrl => _sourceUrl; |
+ final Uri _sourceUrl; |
Lasse Reichstein Nielsen
2016/03/01 15:22:42
What does this change?
A field already introduces
nweiz
2016/03/01 19:16:09
Yes, it does. I'll forward you the email thread wh
|
/// The 0-based offset of this location in the source. |
- final int offset; |
+ int get offset => _offset; |
+ final int _offset; |
/// The 0-based line of this location in the source. |
- final int line; |
+ int get line => _line; |
+ final int _line; |
/// The 0-based column of this location in the source |
- final int column; |
+ int get column => _column; |
+ final int _column; |
/// Returns a representation of this location in the `source:line:column` |
/// format used by text editors. |
@@ -43,10 +50,10 @@ class SourceLocation implements Comparable<SourceLocation> { |
/// |
/// [sourceUrl] may be either a [String], a [Uri], or `null`. |
SourceLocation(int offset, {sourceUrl, int line, int column}) |
- : sourceUrl = sourceUrl is String ? Uri.parse(sourceUrl) : sourceUrl, |
- offset = offset, |
- line = line == null ? 0 : line, |
- column = column == null ? offset : column { |
+ : _sourceUrl = sourceUrl is String ? Uri.parse(sourceUrl) : sourceUrl, |
+ _offset = offset, |
+ _line = line == null ? 0 : line, |
+ _column = column == null ? offset : column { |
if (offset < 0) { |
throw new RangeError("Offset may not be negative, was $offset."); |
} else if (line != null && line < 0) { |