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

Unified Diff: pkg/source_maps/lib/builder.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/polymer/pubspec.yaml ('k') | pkg/source_maps/lib/parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/source_maps/lib/builder.dart
diff --git a/pkg/source_maps/lib/builder.dart b/pkg/source_maps/lib/builder.dart
index 494a6b6e957fcf6bb60e7514655f4848ebd80d3b..091e220c5c13d57133fff267aa8ff153d93506c9 100644
--- a/pkg/source_maps/lib/builder.dart
+++ b/pkg/source_maps/lib/builder.dart
@@ -9,9 +9,10 @@ library source_maps.builder;
import 'dart:convert';
+import 'package:source_span/source_span.dart';
+
import 'parser.dart';
-import 'span.dart';
-import 'src/span_wrapper.dart';
+import 'src/source_map_span.dart';
/// Builds a source map given a set of mappings.
class SourceMapBuilder {
@@ -19,39 +20,33 @@ class SourceMapBuilder {
final List<Entry> _entries = <Entry>[];
/// Adds an entry mapping the [targetOffset] to [source].
- ///
- /// [source] can be either a [Location] or a [SourceLocation]. Using a
- /// [Location] is deprecated and will be unsupported in version 0.10.0.
- void addFromOffset(source, targetFile, int targetOffset, String identifier) {
+ void addFromOffset(SourceLocation source, SourceFile targetFile,
+ int targetOffset, String identifier) {
if (targetFile == null) {
throw new ArgumentError('targetFile cannot be null');
}
- _entries.add(new Entry(source,
- new FileLocation(targetFile, targetOffset), identifier));
+ _entries.add(
+ new Entry(source, targetFile.location(targetOffset), identifier));
}
/// Adds an entry mapping [target] to [source].
///
- /// [source] and [target] can be either a [Span] or a [SourceSpan]. Using a
- /// [Span] is deprecated and will be unsupported in version 0.10.0.
- ///
- /// If [isIdentifier] is true, this entry is considered to represent an
- /// identifier whose value will be stored in the source map.
- void addSpan(source, target, {bool isIdentifier}) {
- source = SpanWrapper.wrap(source);
- target = SpanWrapper.wrap(target);
- if (isIdentifier == null) isIdentifier = source.isIdentifier;
+ /// If [isIdentifier] is true or if [target] is a [SourceMapSpan] with
+ /// `isIdentifier` set to true, this entry is considered to represent an
+ /// identifier whose value will be stored in the source map. [isIdenfier]
+ /// takes precedence over [target]'s `isIdentifier` value.
+ void addSpan(SourceSpan source, SourceSpan target, {bool isIdentifier}) {
+ if (isIdentifier == null) {
+ isIdentifier = source is SourceMapSpan ? source.isIdentifier : false;
+ }
var name = isIdentifier ? source.text : null;
_entries.add(new Entry(source.start, target.start, name));
}
/// Adds an entry mapping [target] to [source].
- ///
- /// [source] and [target] can be either a [Location] or a [SourceLocation].
- /// Using a [Location] is deprecated and will be unsupported in version
- /// 0.10.0.
- void addLocation(source, target, String identifier) {
+ void addLocation(SourceLocation source, SourceLocation target,
+ String identifier) {
_entries.add(new Entry(source, target, identifier));
}
@@ -67,22 +62,16 @@ class SourceMapBuilder {
/// An entry in the source map builder.
class Entry implements Comparable {
/// Span denoting the original location in the input source file
- final Location source;
+ final SourceLocation source;
/// Span indicating the corresponding location in the target file.
- final Location target;
+ final SourceLocation target;
/// An identifier name, when this location is the start of an identifier.
final String identifierName;
/// Creates a new [Entry] mapping [target] to [source].
- ///
- /// [source] and [target] can be either a [Location] or a [SourceLocation].
- /// Using a [Location] is deprecated and will be unsupported in version
- /// 0.10.0.
- Entry(source, target, this.identifierName)
- : source = LocationWrapper.wrap(source),
- target = LocationWrapper.wrap(target);
+ Entry(this.source, this.target, this.identifierName);
/// Implements [Comparable] to ensure that entries are ordered by their
/// location in the target file. We sort primarily by the target offset
@@ -91,7 +80,8 @@ class Entry implements Comparable {
int compareTo(Entry other) {
int res = target.compareTo(other.target);
if (res != 0) return res;
- res = source.sourceUrl.compareTo(other.source.sourceUrl);
+ res = source.sourceUrl.toString().compareTo(
+ other.source.sourceUrl.toString());
if (res != 0) return res;
return source.compareTo(other.source);
}
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/source_maps/lib/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698