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

Unified Diff: pkg/source_maps/lib/src/source_map_span.dart

Issue 421723004: Remove support for the old Span classes from source_maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 5 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 | « pkg/source_maps/lib/span.dart ('k') | pkg/source_maps/lib/src/span_wrapper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/source_maps/lib/src/source_map_span.dart
diff --git a/pkg/source_maps/lib/src/source_map_span.dart b/pkg/source_maps/lib/src/source_map_span.dart
new file mode 100644
index 0000000000000000000000000000000000000000..20eb17ad0ddb3c2e115cf84b12fcb4d2029a3ed9
--- /dev/null
+++ b/pkg/source_maps/lib/src/source_map_span.dart
@@ -0,0 +1,59 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library source_maps.source_map_span;
+
+import 'package:source_span/source_span.dart';
+
+/// A [SourceSpan] for spans coming from or being written to source maps.
+///
+/// These spans have an extra piece of metadata: whether or not they represent
+/// an identifier (see [isIdentifier]).
+class SourceMapSpan extends SourceSpanBase {
+ /// Whether this span represents an identifier.
+ ///
+ /// If this is `true`, [text] is the value of the identifier.
+ final bool isIdentifier;
+
+ SourceMapSpan(SourceLocation start, SourceLocation end, String text,
+ {this.isIdentifier: false})
+ : super(start, end, text);
+
+ /// Creates a [SourceMapSpan] for an identifier with value [text] starting at
+ /// [start].
+ ///
+ /// The [end] location is determined by adding [text] to [start].
+ SourceMapSpan.identifier(SourceLocation start, String text)
+ : this(
+ start,
+ new SourceLocation(start.offset + text.length,
+ sourceUrl: start.sourceUrl,
+ line: start.line,
+ column: start.column + text.length),
+ text,
+ isIdentifier: true);
+}
+
+/// A wrapper aruond a [FileSpan] that implements [SourceMapSpan].
+class SourceMapFileSpan implements SourceMapSpan, FileSpan {
+ final FileSpan _inner;
+ final bool isIdentifier;
+
+ SourceFile get file => _inner.file;
+ FileLocation get start => _inner.start;
+ FileLocation get end => _inner.end;
+ String get text => _inner.text;
+ Uri get sourceUrl => _inner.sourceUrl;
+ int get length => _inner.length;
+
+ SourceMapFileSpan(this._inner, {this.isIdentifier: false});
+
+ int compareTo(SourceSpan other) => _inner.compareTo(other);
+ SourceSpan union(SourceSpan other) => _inner.union(other);
+ FileSpan expand(FileSpan other) => _inner.expand(other);
+ String message(String message, {color}) =>
+ _inner.message(message, color: color);
+ String toString() => _inner.toString()
+ .replaceAll("FileSpan", "SourceMapFileSpan");
+}
« no previous file with comments | « pkg/source_maps/lib/span.dart ('k') | pkg/source_maps/lib/src/span_wrapper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698