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

Unified Diff: lib/src/location.dart

Issue 1728113002: Allow some fields to be overridden in strong mode. (Closed) Base URL: git@github.com:dart-lang/source_span@master
Patch Set: Make more fields virtual Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/span.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/span.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698