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

Unified Diff: lib/src/file.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/source_span.dart ('k') | lib/src/location.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/file.dart
diff --git a/lib/src/file.dart b/lib/src/file.dart
index c2b97e78223ab05150b7f34909fbf21cb78312cd..95fa92ca3b12a7586ca4d3e995c9407039cd69f1 100644
--- a/lib/src/file.dart
+++ b/lib/src/file.dart
@@ -8,6 +8,7 @@ import 'dart:math' as math;
import 'dart:typed_data';
import 'location.dart';
+import 'location_mixin.dart';
import 'span.dart';
import 'span_mixin.dart';
import 'span_with_context.dart';
@@ -212,17 +213,19 @@ class SourceFile {
/// and column values based on its offset and the contents of [file].
///
/// A [FileLocation] can be created using [SourceFile.location].
-class FileLocation extends SourceLocation {
+class FileLocation extends SourceLocationMixin implements SourceLocation {
/// The [file] that [this] belongs to.
final SourceFile file;
+ final int offset;
Uri get sourceUrl => file.url;
int get line => file.getLine(offset);
int get column => file.getColumn(offset);
- FileLocation._(this.file, int offset)
- : super(offset) {
- if (offset > file.length) {
+ FileLocation._(this.file, this.offset) {
+ if (offset < 0) {
+ throw new RangeError("Offset may not be negative, was $offset.");
+ } else if (offset > file.length) {
throw new RangeError("Offset $offset must not be greater than the number "
"of characters in the file, ${file.length}.");
}
« no previous file with comments | « lib/source_span.dart ('k') | lib/src/location.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698