Run dartfmt --fix (#35)
- Drop optional new.
- Use `=` over `:` for named parameter default values.
diff --git a/lib/builder.dart b/lib/builder.dart
index 0769d50..67b4850 100644
--- a/lib/builder.dart
+++ b/lib/builder.dart
@@ -22,10 +22,9 @@
void addFromOffset(SourceLocation source, SourceFile targetFile,
int targetOffset, String identifier) {
if (targetFile == null) {
- throw new ArgumentError('targetFile cannot be null');
+ throw ArgumentError('targetFile cannot be null');
}
- _entries
- .add(new Entry(source, targetFile.location(targetOffset), identifier));
+ _entries.add(Entry(source, targetFile.location(targetOffset), identifier));
}
/// Adds an entry mapping [target] to [source].
@@ -40,18 +39,18 @@
}
var name = isIdentifier ? source.text : null;
- _entries.add(new Entry(source.start, target.start, name));
+ _entries.add(Entry(source.start, target.start, name));
}
/// Adds an entry mapping [target] to [source].
void addLocation(
SourceLocation source, SourceLocation target, String identifier) {
- _entries.add(new Entry(source, target, identifier));
+ _entries.add(Entry(source, target, identifier));
}
/// Encodes all mappings added to this builder as a json map.
Map build(String fileUrl) {
- return new SingleMapping.fromEntries(this._entries, fileUrl).toJson();
+ return SingleMapping.fromEntries(this._entries, fileUrl).toJson();
}
/// Encodes all mappings added to this builder as a json string.
diff --git a/lib/parser.dart b/lib/parser.dart
index 7fe4565..755674e 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -43,7 +43,7 @@
Mapping parseJsonExtended(/*List|Map*/ json,
{Map<String, Map> otherMaps, mapUrl}) {
if (json is List) {
- return new MappingBundle.fromJson(json, mapUrl: mapUrl);
+ return MappingBundle.fromJson(json, mapUrl: mapUrl);
}
return parseJson(json as Map);
}
@@ -55,7 +55,7 @@
/// map will be interpreted as relative to this URL when generating spans.
Mapping parseJson(Map map, {Map<String, Map> otherMaps, mapUrl}) {
if (map['version'] != 3) {
- throw new ArgumentError('unexpected source map version: ${map["version"]}. '
+ throw ArgumentError('unexpected source map version: ${map["version"]}. '
'Only version 3 is supported.');
}
@@ -63,13 +63,13 @@
if (map.containsKey('mappings') ||
map.containsKey('sources') ||
map.containsKey('names')) {
- throw new FormatException('map containing "sections" '
+ throw FormatException('map containing "sections" '
'cannot contain "mappings", "sources", or "names".');
}
- return new MultiSectionMapping.fromJson(map['sections'], otherMaps,
+ return MultiSectionMapping.fromJson(map['sections'], otherMaps,
mapUrl: mapUrl);
}
- return new SingleMapping.fromJson(map, mapUrl: mapUrl);
+ return SingleMapping.fromJson(map, mapUrl: mapUrl);
}
/// A mapping parsed out of a source map.
@@ -107,13 +107,13 @@
{mapUrl}) {
for (var section in sections) {
var offset = section['offset'];
- if (offset == null) throw new FormatException('section missing offset');
+ if (offset == null) throw FormatException('section missing offset');
var line = section['offset']['line'];
- if (line == null) throw new FormatException('offset missing line');
+ if (line == null) throw FormatException('offset missing line');
var column = section['offset']['column'];
- if (column == null) throw new FormatException('offset missing column');
+ if (column == null) throw FormatException('offset missing column');
_lineStart.add(line);
_columnStart.add(column);
@@ -122,10 +122,10 @@
var map = section['map'];
if (url != null && map != null) {
- throw new FormatException("section can't use both url and map entries");
+ throw FormatException("section can't use both url and map entries");
} else if (url != null) {
if (otherMaps == null || otherMaps[url] == null) {
- throw new FormatException(
+ throw FormatException(
'section contains refers to $url, but no map was '
'given for it. Make sure a map is passed in "otherMaps"');
}
@@ -133,11 +133,11 @@
} else if (map != null) {
_maps.add(parseJson(map, otherMaps: otherMaps, mapUrl: mapUrl));
} else {
- throw new FormatException('section missing url or map');
+ throw FormatException('section missing url or map');
}
}
if (_lineStart.length == 0) {
- throw new FormatException('expected at least one section');
+ throw FormatException('expected at least one section');
}
}
@@ -160,7 +160,7 @@
}
String toString() {
- var buff = new StringBuffer("$runtimeType : [");
+ var buff = StringBuffer("$runtimeType : [");
for (int i = 0; i < _lineStart.length; i++) {
buff
..write('(')
@@ -197,7 +197,7 @@
List toJson() => _mappings.values.map((v) => v.toJson()).toList();
String toString() {
- var buff = new StringBuffer();
+ var buff = StringBuffer();
for (var map in _mappings.values) {
buff.write(map.toString());
}
@@ -209,7 +209,7 @@
SourceMapSpan spanFor(int line, int column,
{Map<String, SourceFile> files, String uri}) {
if (uri == null) {
- throw new ArgumentError.notNull('uri');
+ throw ArgumentError.notNull('uri');
}
// Find the longest suffix of the uri that matches the sourcemap
@@ -243,9 +243,9 @@
// of the input line and column to minimize the chances that two different
// line and column locations are mapped to the same offset.
var offset = line * 1000000 + column;
- var location = new SourceLocation(offset,
+ var location = SourceLocation(offset,
line: line, column: column, sourceUrl: Uri.parse(uri));
- return new SourceMapSpan(location, location, "");
+ return SourceMapSpan(location, location, "");
}
}
@@ -287,7 +287,7 @@
factory SingleMapping.fromEntries(Iterable<builder.Entry> entries,
[String fileUrl]) {
// The entries needs to be sorted by the target offsets.
- var sourceEntries = new List.from(entries)..sort();
+ var sourceEntries = List.from(entries)..sort();
var lines = <TargetLineEntry>[];
// Indices associated with file urls that will be part of the source map. We
@@ -307,11 +307,11 @@
if (lineNum == null || sourceEntry.target.line > lineNum) {
lineNum = sourceEntry.target.line;
targetEntries = <TargetEntry>[];
- lines.add(new TargetLineEntry(lineNum, targetEntries));
+ lines.add(TargetLineEntry(lineNum, targetEntries));
}
if (sourceEntry.source == null) {
- targetEntries.add(new TargetEntry(sourceEntry.target.column));
+ targetEntries.add(TargetEntry(sourceEntry.target.column));
} else {
var sourceUrl = sourceEntry.source.sourceUrl;
var urlId = urls.putIfAbsent(
@@ -325,34 +325,30 @@
var srcNameId = sourceEntry.identifierName == null
? null
: names.putIfAbsent(sourceEntry.identifierName, () => names.length);
- targetEntries.add(new TargetEntry(sourceEntry.target.column, urlId,
+ targetEntries.add(TargetEntry(sourceEntry.target.column, urlId,
sourceEntry.source.line, sourceEntry.source.column, srcNameId));
}
}
- return new SingleMapping._(
- fileUrl,
- urls.values.map((i) => files[i]).toList(),
- urls.keys.toList(),
- names.keys.toList(),
- lines);
+ return SingleMapping._(fileUrl, urls.values.map((i) => files[i]).toList(),
+ urls.keys.toList(), names.keys.toList(), lines);
}
SingleMapping.fromJson(Map map, {mapUrl})
: targetUrl = map['file'],
- urls = new List<String>.from(map['sources']),
- names = new List<String>.from(map['names']),
- files = new List(map['sources'].length),
+ urls = List<String>.from(map['sources']),
+ names = List<String>.from(map['names']),
+ files = List(map['sources'].length),
sourceRoot = map['sourceRoot'],
lines = <TargetLineEntry>[],
_mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl,
extensions = {} {
var sourcesContent = map['sourcesContent'] == null
? const []
- : new List<String>.from(map['sourcesContent']);
+ : List<String>.from(map['sourcesContent']);
for (var i = 0; i < urls.length && i < sourcesContent.length; i++) {
var source = sourcesContent[i];
if (source == null) continue;
- files[i] = new SourceFile.fromString(source, url: urls[i]);
+ files[i] = SourceFile.fromString(source, url: urls[i]);
}
int line = 0;
@@ -361,13 +357,13 @@
int srcLine = 0;
int srcColumn = 0;
int srcNameId = 0;
- var tokenizer = new _MappingTokenizer(map['mappings']);
+ var tokenizer = _MappingTokenizer(map['mappings']);
var entries = <TargetEntry>[];
while (tokenizer.hasTokens) {
if (tokenizer.nextKind.isNewLine) {
if (!entries.isEmpty) {
- lines.add(new TargetLineEntry(line, entries));
+ lines.add(TargetLineEntry(line, entries));
entries = <TargetEntry>[];
}
line++;
@@ -390,11 +386,11 @@
if (tokenizer.nextKind.isNewSegment) throw _segmentError(0, line);
column += tokenizer._consumeValue();
if (!tokenizer.nextKind.isValue) {
- entries.add(new TargetEntry(column));
+ entries.add(TargetEntry(column));
} else {
srcUrlId += tokenizer._consumeValue();
if (srcUrlId >= urls.length) {
- throw new StateError(
+ throw StateError(
'Invalid source url id. $targetUrl, $line, $srcUrlId');
}
if (!tokenizer.nextKind.isValue) throw _segmentError(2, line);
@@ -402,21 +398,20 @@
if (!tokenizer.nextKind.isValue) throw _segmentError(3, line);
srcColumn += tokenizer._consumeValue();
if (!tokenizer.nextKind.isValue) {
- entries.add(new TargetEntry(column, srcUrlId, srcLine, srcColumn));
+ entries.add(TargetEntry(column, srcUrlId, srcLine, srcColumn));
} else {
srcNameId += tokenizer._consumeValue();
if (srcNameId >= names.length) {
- throw new StateError(
- 'Invalid name id: $targetUrl, $line, $srcNameId');
+ throw StateError('Invalid name id: $targetUrl, $line, $srcNameId');
}
entries.add(
- new TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId));
+ TargetEntry(column, srcUrlId, srcLine, srcColumn, srcNameId));
}
}
if (tokenizer.nextKind.isNewSegment) tokenizer._consumeNewSegment();
}
if (!entries.isEmpty) {
- lines.add(new TargetLineEntry(line, entries));
+ lines.add(TargetLineEntry(line, entries));
}
map.forEach((name, value) {
@@ -428,8 +423,8 @@
///
/// If [sourcesContent] is `true`, this includes the source file contents from
/// [files] in the map if possible.
- Map toJson({bool includeSourceContents: false}) {
- var buff = new StringBuffer();
+ Map toJson({bool includeSourceContents = false}) {
+ var buff = StringBuffer();
var line = 0;
var column = 0;
var srcLine = 0;
@@ -492,7 +487,7 @@
}
_segmentError(int seen, int line) =>
- new StateError('Invalid entry in sourcemap, expected 1, 4, or 5'
+ StateError('Invalid entry in sourcemap, expected 1, 4, or 5'
' values, but got $seen.\ntargeturl: $targetUrl, line: $line');
/// Returns [TargetLineEntry] which includes the location in the target [line]
@@ -529,29 +524,28 @@
var start = file.getOffset(entry.sourceLine, entry.sourceColumn);
if (entry.sourceNameId != null) {
var text = names[entry.sourceNameId];
- return new SourceMapFileSpan(
- files[url].span(start, start + text.length),
+ return SourceMapFileSpan(files[url].span(start, start + text.length),
isIdentifier: true);
} else {
- return new SourceMapFileSpan(files[url].location(start).pointSpan());
+ return SourceMapFileSpan(files[url].location(start).pointSpan());
}
} else {
- var start = new SourceLocation(0,
+ var start = SourceLocation(0,
sourceUrl: _mapUrl == null ? url : _mapUrl.resolve(url),
line: entry.sourceLine,
column: entry.sourceColumn);
// Offset and other context is not available.
if (entry.sourceNameId != null) {
- return new SourceMapSpan.identifier(start, names[entry.sourceNameId]);
+ return SourceMapSpan.identifier(start, names[entry.sourceNameId]);
} else {
- return new SourceMapSpan(start, start, '');
+ return SourceMapSpan(start, start, '');
}
}
}
String toString() {
- return (new StringBuffer("$runtimeType : [")
+ return (StringBuffer("$runtimeType : [")
..write('targetUrl: ')
..write(targetUrl)
..write(', sourceRoot: ')
@@ -567,7 +561,7 @@
}
String get debugString {
- var buff = new StringBuffer();
+ var buff = StringBuffer();
for (var lineEntry in lines) {
var line = lineEntry.line;
for (var entry in lineEntry.entries) {
@@ -624,7 +618,7 @@
'($column, $sourceUrlId, $sourceLine, $sourceColumn, $sourceNameId)';
}
-/** A character iterator over a string that can peek one character ahead. */
+/// A character iterator over a string that can peek one character ahead.
class _MappingTokenizer implements Iterator<String> {
final String _internal;
final int _length;
@@ -660,7 +654,7 @@
// Print the state of the iterator, with colors indicating the current
// position.
String toString() {
- var buff = new StringBuffer();
+ var buff = StringBuffer();
for (int i = 0; i < index; i++) {
buff.write(_internal[i]);
}
@@ -676,15 +670,15 @@
}
class _TokenKind {
- static const _TokenKind LINE = const _TokenKind(isNewLine: true);
- static const _TokenKind SEGMENT = const _TokenKind(isNewSegment: true);
- static const _TokenKind EOF = const _TokenKind(isEof: true);
- static const _TokenKind VALUE = const _TokenKind();
+ static const _TokenKind LINE = _TokenKind(isNewLine: true);
+ static const _TokenKind SEGMENT = _TokenKind(isNewSegment: true);
+ static const _TokenKind EOF = _TokenKind(isEof: true);
+ static const _TokenKind VALUE = _TokenKind();
final bool isNewLine;
final bool isNewSegment;
final bool isEof;
bool get isValue => !isNewLine && !isNewSegment && !isEof;
const _TokenKind(
- {this.isNewLine: false, this.isNewSegment: false, this.isEof: false});
+ {this.isNewLine = false, this.isNewSegment = false, this.isEof = false});
}
diff --git a/lib/printer.dart b/lib/printer.dart
index 6187dba..beadbdd 100644
--- a/lib/printer.dart
+++ b/lib/printer.dart
@@ -17,8 +17,8 @@
/// maps locations.
class Printer {
final String filename;
- final StringBuffer _buff = new StringBuffer();
- final SourceMapBuilder _maps = new SourceMapBuilder();
+ final StringBuffer _buff = StringBuffer();
+ final SourceMapBuilder _maps = SourceMapBuilder();
String get text => _buff.toString();
String get map => _maps.toJson(filename);
@@ -38,7 +38,7 @@
/// adds a source map location on each new line, projecting that every new
/// line in the target file (printed here) corresponds to a new line in the
/// source file.
- void add(String str, {projectMarks: false}) {
+ void add(String str, {projectMarks = false}) {
var chars = str.runes.toList();
var length = chars.length;
for (int i = 0; i < length; i++) {
@@ -52,7 +52,7 @@
var file = (_loc as FileLocation).file;
mark(file.location(file.getOffset(_loc.line + 1)));
} else {
- mark(new SourceLocation(0,
+ mark(SourceLocation(0,
sourceUrl: _loc.sourceUrl, line: _loc.line + 1, column: 0));
}
}
@@ -84,10 +84,8 @@
loc = mark.start;
if (mark is SourceMapSpan && mark.isIdentifier) identifier = mark.text;
}
- _maps.addLocation(
- loc,
- new SourceLocation(_buff.length, line: _line, column: _column),
- identifier);
+ _maps.addLocation(loc,
+ SourceLocation(_buff.length, line: _line, column: _column), identifier);
_loc = loc;
}
}
@@ -113,7 +111,7 @@
/// Item used to indicate that the following item is copied from the original
/// source code, and hence we should preserve source-maps on every new line.
- static final _ORIGINAL = new Object();
+ static final _ORIGINAL = Object();
NestedPrinter([this.indent = 0]);
@@ -133,7 +131,7 @@
/// Setting [isOriginal] will make this printer propagate source map locations
/// on every line-break.
void add(object,
- {SourceLocation location, SourceSpan span, bool isOriginal: false}) {
+ {SourceLocation location, SourceSpan span, bool isOriginal = false}) {
if (object is! String || location != null || span != null || isOriginal) {
_flush();
assert(location == null || span == null);
@@ -180,7 +178,7 @@
/// Appends a string merging it with any previous strings, if possible.
void _appendString(String s) {
- if (_buff == null) _buff = new StringBuffer();
+ if (_buff == null) _buff = StringBuffer();
_buff.write(s);
}
@@ -200,7 +198,7 @@
/// printer, including source map location tokens.
String toString() {
_flush();
- return (new StringBuffer()..writeAll(_items)).toString();
+ return (StringBuffer()..writeAll(_items)).toString();
}
/// [Printer] used during the last call to [build], if any.
@@ -216,7 +214,7 @@
/// calling this function, you can use [text] and [map] to retrieve the
/// geenrated code and source map information, respectively.
void build(String filename) {
- writeTo(printer = new Printer(filename));
+ writeTo(printer = Printer(filename));
}
/// Implements the [NestedItem] interface.
@@ -237,7 +235,7 @@
// every new-line.
propagate = true;
} else {
- throw new UnsupportedError('Unknown item type: $item');
+ throw UnsupportedError('Unknown item type: $item');
}
}
}
diff --git a/lib/refactor.dart b/lib/refactor.dart
index d6b129a..34eabf8 100644
--- a/lib/refactor.dart
+++ b/lib/refactor.dart
@@ -30,7 +30,7 @@
/// with the [replacement]. [replacement] can be either a string or a
/// [NestedPrinter].
void edit(int begin, int end, replacement) {
- _edits.add(new _TextEdit(begin, end, replacement));
+ _edits.add(_TextEdit(begin, end, replacement));
}
/// Create a source map [SourceLocation] for [offset].
@@ -45,7 +45,7 @@
/// Throws [UnsupportedError] if the edits were overlapping. If no edits were
/// made, the printer simply contains the original string.
NestedPrinter commit() {
- var printer = new NestedPrinter();
+ var printer = NestedPrinter();
if (_edits.length == 0) {
return printer..add(original, location: _loc(0), isOriginal: true);
}
@@ -56,7 +56,7 @@
int consumed = 0;
for (var edit in _edits) {
if (consumed > edit.begin) {
- var sb = new StringBuffer();
+ var sb = StringBuffer();
sb
..write(file.location(edit.begin).toolString)
..write(': overlapping edits. Insert at offset ')
@@ -65,7 +65,7 @@
..write(consumed)
..write(' input characters. List of edits:');
for (var e in _edits) sb..write('\n ')..write(e);
- throw new UnsupportedError(sb.toString());
+ throw UnsupportedError(sb.toString());
}
// Add characters from the original string between this edit and the last
diff --git a/lib/src/source_map_span.dart b/lib/src/source_map_span.dart
index 37107e1..ba67027 100644
--- a/lib/src/source_map_span.dart
+++ b/lib/src/source_map_span.dart
@@ -17,7 +17,7 @@
final bool isIdentifier;
SourceMapSpan(SourceLocation start, SourceLocation end, String text,
- {this.isIdentifier: false})
+ {this.isIdentifier = false})
: super(start, end, text);
/// Creates a [SourceMapSpan] for an identifier with value [text] starting at
@@ -27,7 +27,7 @@
SourceMapSpan.identifier(SourceLocation start, String text)
: this(
start,
- new SourceLocation(start.offset + text.length,
+ SourceLocation(start.offset + text.length,
sourceUrl: start.sourceUrl,
line: start.line,
column: start.column + text.length),
@@ -48,7 +48,7 @@
Uri get sourceUrl => _inner.sourceUrl;
int get length => _inner.length;
- SourceMapFileSpan(this._inner, {this.isIdentifier: false});
+ SourceMapFileSpan(this._inner, {this.isIdentifier = false});
int compareTo(SourceSpan other) => _inner.compareTo(other);
String highlight({color}) => _inner.highlight(color: color);
diff --git a/lib/src/vlq.dart b/lib/src/vlq.dart
index 0c54dbf..ebae139 100644
--- a/lib/src/vlq.dart
+++ b/lib/src/vlq.dart
@@ -40,7 +40,7 @@
/// Creates the VLQ encoding of [value] as a sequence of characters
Iterable<String> encodeVlq(int value) {
if (value < MIN_INT32 || value > MAX_INT32) {
- throw new ArgumentError('expected 32 bit int, got: $value');
+ throw ArgumentError('expected 32 bit int, got: $value');
}
var res = <String>[];
int signBit = 0;
@@ -69,10 +69,10 @@
bool stop = false;
int shift = 0;
while (!stop) {
- if (!chars.moveNext()) throw new StateError('incomplete VLQ value');
+ if (!chars.moveNext()) throw StateError('incomplete VLQ value');
var char = chars.current;
if (!_digits.containsKey(char)) {
- throw new FormatException('invalid character in VLQ encoding: $char');
+ throw FormatException('invalid character in VLQ encoding: $char');
}
var digit = _digits[char];
stop = (digit & VLQ_CONTINUATION_BIT) == 0;
@@ -95,7 +95,7 @@
// TODO(sigmund): can we detect this earlier?
if (result < MIN_INT32 || result > MAX_INT32) {
- throw new FormatException(
+ throw FormatException(
'expected an encoded 32 bit int, but we got: $result');
}
return result;
diff --git a/pubspec.yaml b/pubspec.yaml
index 0a35df6..cf79766 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,12 @@
name: source_maps
-version: 0.10.8
+version: 0.10.9-dev
description: Library to programmatically manipulate source map files.
author: Dart Team <misc@dartlang.org>
homepage: http://github.com/dart-lang/source_maps
environment:
- sdk: '>=2.0.0-dev.17.0 <3.0.0'
+ sdk: '>=2.0.0 <3.0.0'
dependencies:
source_span: ^1.3.0
diff --git a/test/builder_test.dart b/test/builder_test.dart
index 1e2efdd..0b2a965 100644
--- a/test/builder_test.dart
+++ b/test/builder_test.dart
@@ -11,7 +11,7 @@
main() {
test('builder - with span', () {
- var map = (new SourceMapBuilder()
+ var map = (SourceMapBuilder()
..addSpan(inputVar1, outputVar1)
..addSpan(inputFunction, outputFunction)
..addSpan(inputVar2, outputVar2)
@@ -21,7 +21,7 @@
});
test('builder - with location', () {
- var str = (new SourceMapBuilder()
+ var str = (SourceMapBuilder()
..addLocation(inputVar1.start, outputVar1.start, 'longVar1')
..addLocation(inputFunction.start, outputFunction.start, 'longName')
..addLocation(inputVar2.start, outputVar2.start, 'longVar2')
diff --git a/test/common.dart b/test/common.dart
index 01ffdad..8217c0e 100644
--- a/test/common.dart
+++ b/test/common.dart
@@ -19,11 +19,11 @@
return longVar1 + longVar2;
}
''';
-var input = new SourceFile(INPUT, url: 'input.dart');
+var input = SourceFile(INPUT, url: 'input.dart');
/// A span in the input file
SourceMapSpan ispan(int start, int end, [bool isIdentifier = false]) =>
- new SourceMapFileSpan(input.span(start, end), isIdentifier: isIdentifier);
+ SourceMapFileSpan(input.span(start, end), isIdentifier: isIdentifier);
SourceMapSpan inputVar1 = ispan(30, 38, true);
SourceMapSpan inputFunction = ispan(74, 82, true);
@@ -40,11 +40,11 @@
var x = 3;
f(y) => x + y;
''';
-var output = new SourceFile(OUTPUT, url: 'output.dart');
+var output = SourceFile(OUTPUT, url: 'output.dart');
/// A span in the output file
SourceMapSpan ospan(int start, int end, [bool isIdentifier = false]) =>
- new SourceMapFileSpan(output.span(start, end), isIdentifier: isIdentifier);
+ SourceMapFileSpan(output.span(start, end), isIdentifier: isIdentifier);
SourceMapSpan outputVar1 = ospan(4, 5, true);
SourceMapSpan outputFunction = ospan(11, 12, true);
@@ -62,11 +62,11 @@
///
/// This mapping is stored in the tests so we can independently test the builder
/// and parser algorithms without relying entirely on end2end tests.
-const Map<String, dynamic> EXPECTED_MAP = const {
+const Map<String, dynamic> EXPECTED_MAP = {
'version': 3,
'sourceRoot': '',
- 'sources': const ['input.dart'],
- 'names': const ['longVar1', 'longName', 'longVar2'],
+ 'sources': ['input.dart'],
+ 'names': ['longVar1', 'longName', 'longVar2'],
'mappings': 'IACIA;AAGAC,EAAaC,MACR',
'file': 'output.dart'
};
diff --git a/test/end2end_test.dart b/test/end2end_test.dart
index 1082c97..5d60165 100644
--- a/test/end2end_test.dart
+++ b/test/end2end_test.dart
@@ -29,7 +29,7 @@
});
test('build + parse', () {
- var map = (new SourceMapBuilder()
+ var map = (SourceMapBuilder()
..addSpan(inputVar1, outputVar1)
..addSpan(inputFunction, outputFunction)
..addSpan(inputVar2, outputVar2)
@@ -43,7 +43,7 @@
});
test('build + parse - no symbols', () {
- var map = (new SourceMapBuilder()
+ var map = (SourceMapBuilder()
..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
@@ -57,7 +57,7 @@
});
test('build + parse, repeated entries', () {
- var map = (new SourceMapBuilder()
+ var map = (SourceMapBuilder()
..addSpan(inputVar1, outputVar1)
..addSpan(inputVar1, outputVar1)
..addSpan(inputFunction, outputFunction)
@@ -75,7 +75,7 @@
});
test('build + parse - no symbols, repeated entries', () {
- var map = (new SourceMapBuilder()
+ var map = (SourceMapBuilder()
..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
@@ -92,7 +92,7 @@
});
test('build + parse with file', () {
- var json = (new SourceMapBuilder()
+ var json = (SourceMapBuilder()
..addSpan(inputVar1, outputVar1)
..addSpan(inputFunction, outputFunction)
..addSpan(inputVar2, outputVar2)
@@ -107,8 +107,8 @@
test('printer projecting marks + parse', () {
var out = INPUT.replaceAll('long', '_s');
- var file = new SourceFile(out, url: 'output2.dart');
- var printer = new Printer('output2.dart');
+ var file = SourceFile(out, url: 'output2.dart');
+ var printer = Printer('output2.dart');
printer.mark(ispan(0, 0));
var segments = INPUT.split('long');
@@ -135,7 +135,7 @@
checkHelper(SourceMapSpan inputSpan, int adjustment) {
var start = inputSpan.start.offset - adjustment;
var end = (inputSpan.end.offset - adjustment) - 2;
- var span = new SourceMapFileSpan(file.span(start, end),
+ var span = SourceMapFileSpan(file.span(start, end),
isIdentifier: inputSpan.isIdentifier);
check(span, mapping, inputSpan, true);
}
diff --git a/test/parser_test.dart b/test/parser_test.dart
index 3901842..d6a8ac1 100644
--- a/test/parser_test.dart
+++ b/test/parser_test.dart
@@ -10,61 +10,61 @@
import 'package:source_span/source_span.dart';
import 'common.dart';
-const Map<String, dynamic> MAP_WITH_NO_SOURCE_LOCATION = const {
+const Map<String, dynamic> MAP_WITH_NO_SOURCE_LOCATION = {
'version': 3,
'sourceRoot': '',
- 'sources': const ['input.dart'],
- 'names': const [],
+ 'sources': ['input.dart'],
+ 'names': [],
'mappings': 'A',
'file': 'output.dart'
};
-const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION = const {
+const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION = {
'version': 3,
'sourceRoot': '',
- 'sources': const ['input.dart'],
- 'names': const [],
+ 'sources': ['input.dart'],
+ 'names': [],
'mappings': 'AAAA',
'file': 'output.dart'
};
-const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME = const {
+const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME = {
'version': 3,
'sourceRoot': '',
- 'sources': const ['input.dart'],
- 'names': const ['var'],
+ 'sources': ['input.dart'],
+ 'names': ['var'],
'mappings': 'AAAAA',
'file': 'output.dart'
};
-const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = const {
+const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME_1 = {
'version': 3,
'sourceRoot': 'pkg/',
- 'sources': const ['input1.dart'],
- 'names': const ['var1'],
+ 'sources': ['input1.dart'],
+ 'names': ['var1'],
'mappings': 'AAAAA',
'file': 'output.dart'
};
-const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = const {
+const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME_2 = {
'version': 3,
'sourceRoot': 'pkg/',
- 'sources': const ['input2.dart'],
- 'names': const ['var2'],
+ 'sources': ['input2.dart'],
+ 'names': ['var2'],
'mappings': 'AAAAA',
'file': 'output2.dart'
};
-const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = const {
+const Map<String, dynamic> MAP_WITH_SOURCE_LOCATION_AND_NAME_3 = {
'version': 3,
'sourceRoot': 'pkg/',
- 'sources': const ['input3.dart'],
- 'names': const ['var3'],
+ 'sources': ['input3.dart'],
+ 'names': ['var3'],
'mappings': 'AAAAA',
'file': '3/output.dart'
};
-const List SOURCE_MAP_BUNDLE = const [
+const List SOURCE_MAP_BUNDLE = [
MAP_WITH_SOURCE_LOCATION_AND_NAME_1,
MAP_WITH_SOURCE_LOCATION_AND_NAME_2,
MAP_WITH_SOURCE_LOCATION_AND_NAME_3,
@@ -135,14 +135,14 @@
});
test('parse with source root', () {
- var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION);
+ var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION);
inputMap['sourceRoot'] = '/pkg/';
var mapping = parseJson(inputMap) as SingleMapping;
expect(mapping.spanFor(0, 0).sourceUrl, Uri.parse("/pkg/input.dart"));
expect(
mapping
.spanForLocation(
- new SourceLocation(0, sourceUrl: Uri.parse("ignored.dart")))
+ SourceLocation(0, sourceUrl: Uri.parse("ignored.dart")))
.sourceUrl,
Uri.parse("/pkg/input.dart"));
@@ -155,7 +155,7 @@
});
test('parse with map URL', () {
- var inputMap = new Map.from(MAP_WITH_SOURCE_LOCATION);
+ var inputMap = Map.from(MAP_WITH_SOURCE_LOCATION);
inputMap['sourceRoot'] = 'pkg/';
var mapping = parseJson(inputMap, mapUrl: "file:///path/to/map");
expect(mapping.spanFor(0, 0).sourceUrl,
@@ -169,20 +169,20 @@
test('simple', () {
expect(
mapping
- .spanForLocation(new SourceLocation(0,
- sourceUrl: new Uri.file('/path/to/output.dart')))
+ .spanForLocation(SourceLocation(0,
+ sourceUrl: Uri.file('/path/to/output.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input1.dart"));
expect(
mapping
- .spanForLocation(new SourceLocation(0,
- sourceUrl: new Uri.file('/path/to/output2.dart')))
+ .spanForLocation(SourceLocation(0,
+ sourceUrl: Uri.file('/path/to/output2.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input2.dart"));
expect(
mapping
- .spanForLocation(new SourceLocation(0,
- sourceUrl: new Uri.file('/path/to/3/output.dart')))
+ .spanForLocation(SourceLocation(0,
+ sourceUrl: Uri.file('/path/to/3/output.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input3.dart"));
@@ -200,19 +200,19 @@
test('package uris', () {
expect(
mapping
- .spanForLocation(new SourceLocation(0,
+ .spanForLocation(SourceLocation(0,
sourceUrl: Uri.parse('package:1/output.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input1.dart"));
expect(
mapping
- .spanForLocation(new SourceLocation(0,
+ .spanForLocation(SourceLocation(0,
sourceUrl: Uri.parse('package:2/output2.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input2.dart"));
expect(
mapping
- .spanForLocation(new SourceLocation(0,
+ .spanForLocation(SourceLocation(0,
sourceUrl: Uri.parse('package:3/output.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input3.dart"));
@@ -263,7 +263,7 @@
});
test('build bundle incrementally', () {
- var mapping = new MappingBundle();
+ var mapping = MappingBundle();
mapping.addMapping(parseJson(MAP_WITH_SOURCE_LOCATION_AND_NAME_1,
mapUrl: "file:///path/to/map"));
@@ -291,19 +291,19 @@
test('different paths', () {
expect(
mapping
- .spanForLocation(new SourceLocation(0,
+ .spanForLocation(SourceLocation(0,
sourceUrl: Uri.parse('http://localhost/output.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input1.dart"));
expect(
mapping
- .spanForLocation(new SourceLocation(0,
+ .spanForLocation(SourceLocation(0,
sourceUrl: Uri.parse('http://localhost/output2.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input2.dart"));
expect(
mapping
- .spanForLocation(new SourceLocation(0,
+ .spanForLocation(SourceLocation(0,
sourceUrl: Uri.parse('http://localhost/3/output.dart')))
.sourceUrl,
Uri.parse("file:///path/to/pkg/input3.dart"));
@@ -343,7 +343,7 @@
});
test('parse extensions', () {
- var map = new Map.from(EXPECTED_MAP);
+ var map = Map.from(EXPECTED_MAP);
map["x_foo"] = "a";
map["x_bar"] = [3];
SingleMapping mapping = parseJson(map);
@@ -355,16 +355,15 @@
group("source files", () {
group("from fromEntries()", () {
test("are null for non-FileLocations", () {
- var mapping = new SingleMapping.fromEntries([
- new Entry(new SourceLocation(10, line: 1, column: 8),
- outputVar1.start, null)
+ var mapping = SingleMapping.fromEntries([
+ Entry(SourceLocation(10, line: 1, column: 8), outputVar1.start, null)
]);
expect(mapping.files, equals([null]));
});
test("use a file location's file", () {
- var mapping = new SingleMapping.fromEntries(
- [new Entry(inputVar1.start, outputVar1.start, null)]);
+ var mapping = SingleMapping.fromEntries(
+ [Entry(inputVar1.start, outputVar1.start, null)]);
expect(mapping.files, equals([input]));
});
});
@@ -377,14 +376,14 @@
});
test("with null sourcesContent values", () {
- var map = new Map.from(EXPECTED_MAP);
+ var map = Map.from(EXPECTED_MAP);
map["sourcesContent"] = [null];
var mapping = parseJson(map) as SingleMapping;
expect(mapping.files, equals([null]));
});
test("with a too-short sourcesContent", () {
- var map = new Map.from(EXPECTED_MAP);
+ var map = Map.from(EXPECTED_MAP);
map["sourcesContent"] = [];
var mapping = parseJson(map) as SingleMapping;
expect(mapping.files, equals([null]));
@@ -392,7 +391,7 @@
});
test("are parsed from sourcesContent", () {
- var map = new Map.from(EXPECTED_MAP);
+ var map = Map.from(EXPECTED_MAP);
map["sourcesContent"] = ["hello, world!"];
var mapping = parseJson(map) as SingleMapping;
diff --git a/test/printer_test.dart b/test/printer_test.dart
index 32db695..a247907 100644
--- a/test/printer_test.dart
+++ b/test/printer_test.dart
@@ -12,7 +12,7 @@
main() {
test('printer', () {
- var printer = new Printer('output.dart');
+ var printer = Printer('output.dart');
printer
..add('var ')
..mark(inputVar1)
@@ -29,7 +29,7 @@
test('printer projecting marks', () {
var out = INPUT.replaceAll('long', '_s');
- var printer = new Printer('output2.dart');
+ var printer = Printer('output2.dart');
var segments = INPUT.split('long');
expect(segments.length, 6);
@@ -56,12 +56,12 @@
expect(printer.map.split(';').length, 8);
asFixed(SourceMapSpan s) =>
- new SourceMapSpan(s.start, s.end, s.text, isIdentifier: s.isIdentifier);
+ SourceMapSpan(s.start, s.end, s.text, isIdentifier: s.isIdentifier);
// The result is the same if we use fixed positions
- var printer2 = new Printer('output2.dart');
+ var printer2 = Printer('output2.dart');
printer2
- ..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan())
+ ..mark(SourceLocation(0, sourceUrl: 'input.dart').pointSpan())
..add(segments[0], projectMarks: true)
..mark(asFixed(inputVar1))
..add('_s')
@@ -84,7 +84,7 @@
group('nested printer', () {
test('simple use', () {
- var printer = new NestedPrinter();
+ var printer = NestedPrinter();
printer
..add('var ')
..add('x = 3;\n', span: inputVar1)
@@ -97,12 +97,12 @@
});
test('nested use', () {
- var printer = new NestedPrinter();
+ var printer = NestedPrinter();
printer
..add('var ')
- ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1))
+ ..add(NestedPrinter()..add('x = 3;\n', span: inputVar1))
..add('f(', span: inputFunction)
- ..add(new NestedPrinter()..add('y) => ', span: inputVar2))
+ ..add(NestedPrinter()..add('y) => ', span: inputVar2))
..add('x + y;\n', span: inputExpr)
..build('output.dart');
expect(printer.text, OUTPUT);
@@ -113,7 +113,7 @@
var out = INPUT.replaceAll('long', '_s');
var lines = INPUT.trim().split('\n');
expect(lines.length, 7);
- var printer = new NestedPrinter();
+ var printer = NestedPrinter();
for (int i = 0; i < lines.length; i++) {
if (i == 5) printer.indent++;
printer.addLine(lines[i].replaceAll('long', '_s').trim());
diff --git a/test/refactor_test.dart b/test/refactor_test.dart
index 857d30d..ba2ddc9 100644
--- a/test/refactor_test.dart
+++ b/test/refactor_test.dart
@@ -17,10 +17,10 @@
group('conflict detection', () {
var original = "0123456789abcdefghij";
- var file = new SourceFile(original);
+ var file = SourceFile(original);
test('no conflict, in order', () {
- var txn = new TextEditTransaction(original, file);
+ var txn = TextEditTransaction(original, file);
txn.edit(2, 4, '.');
txn.edit(5, 5, '|');
txn.edit(6, 6, '-');
@@ -29,7 +29,7 @@
});
test('no conflict, out of order', () {
- var txn = new TextEditTransaction(original, file);
+ var txn = TextEditTransaction(original, file);
txn.edit(2, 4, '.');
txn.edit(5, 5, '|');
@@ -41,7 +41,7 @@
});
test('conflict', () {
- var txn = new TextEditTransaction(original, file);
+ var txn = TextEditTransaction(original, file);
txn.edit(2, 4, '.');
txn.edit(3, 3, '-');
expect(
@@ -54,8 +54,8 @@
test('generated source maps', () {
var original =
"0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n";
- var file = new SourceFile(original);
- var txn = new TextEditTransaction(original, file);
+ var file = SourceFile(original);
+ var txn = TextEditTransaction(original, file);
txn.edit(27, 29, '__\n ');
txn.edit(34, 35, '___');
var printer = (txn.commit()..build(''));