dartfmt
diff --git a/lib/builder.dart b/lib/builder.dart
index c8596fe..cdba2d2 100644
--- a/lib/builder.dart
+++ b/lib/builder.dart
@@ -16,7 +16,6 @@
/// Builds a source map given a set of mappings.
class SourceMapBuilder {
-
final List<Entry> _entries = <Entry>[];
/// Adds an entry mapping the [targetOffset] to [source].
@@ -25,8 +24,8 @@
if (targetFile == null) {
throw new ArgumentError('targetFile cannot be null');
}
- _entries.add(
- new Entry(source, targetFile.location(targetOffset), identifier));
+ _entries
+ .add(new Entry(source, targetFile.location(targetOffset), identifier));
}
/// Adds an entry mapping [target] to [source].
@@ -45,8 +44,8 @@
}
/// Adds an entry mapping [target] to [source].
- void addLocation(SourceLocation source, SourceLocation target,
- String identifier) {
+ void addLocation(
+ SourceLocation source, SourceLocation target, String identifier) {
_entries.add(new Entry(source, target, identifier));
}
@@ -80,8 +79,9 @@
int compareTo(Entry other) {
int res = target.compareTo(other.target);
if (res != 0) return res;
- res = source.sourceUrl.toString().compareTo(
- other.source.sourceUrl.toString());
+ res = source.sourceUrl
+ .toString()
+ .compareTo(other.source.sourceUrl.toString());
if (res != 0) return res;
return source.compareTo(other.source);
}
diff --git a/lib/printer.dart b/lib/printer.dart
index 906e260..6187dba 100644
--- a/lib/printer.dart
+++ b/lib/printer.dart
@@ -63,7 +63,6 @@
_buff.write(str);
}
-
/// Append a [total] number of spaces in the target file. Typically used for
/// formatting indentation.
void addSpaces(int total) {
@@ -101,7 +100,6 @@
/// peices of the code are generated independently on separate printers, and are
/// finally put together in the end.
class NestedPrinter implements NestedItem {
-
/// Items recoded by this printer, which can be [String] literals,
/// [NestedItem]s, and source map information like [SourceLocation] and
/// [SourceSpan].
@@ -134,8 +132,8 @@
/// Indicate [isOriginal] when [object] is copied directly from the user code.
/// Setting [isOriginal] will make this printer propagate source map locations
/// on every line-break.
- void add(object, {SourceLocation location, SourceSpan span,
- bool isOriginal: false}) {
+ void add(object,
+ {SourceLocation location, SourceSpan span, bool isOriginal: false}) {
if (object is! String || location != null || span != null || isOriginal) {
_flush();
assert(location == null || span == null);
diff --git a/lib/refactor.dart b/lib/refactor.dart
index a33b86b..d6b129a 100644
--- a/lib/refactor.dart
+++ b/lib/refactor.dart
@@ -41,7 +41,7 @@
/// rewritten string and source map information. [filename] is given to the
/// underlying printer to indicate the name of the generated file that will
/// contains the source map information.
- ///
+ ///
/// Throws [UnsupportedError] if the edits were overlapping. If no edits were
/// made, the printer simply contains the original string.
NestedPrinter commit() {
@@ -57,12 +57,13 @@
for (var edit in _edits) {
if (consumed > edit.begin) {
var sb = new StringBuffer();
- sb..write(file.location(edit.begin).toolString)
- ..write(': overlapping edits. Insert at offset ')
- ..write(edit.begin)
- ..write(' but have consumed ')
- ..write(consumed)
- ..write(' input characters. List of edits:');
+ sb
+ ..write(file.location(edit.begin).toolString)
+ ..write(': overlapping edits. Insert at offset ')
+ ..write(edit.begin)
+ ..write(' but have consumed ')
+ ..write(consumed)
+ ..write(' input characters. List of edits:');
for (var e in _edits) sb..write('\n ')..write(e);
throw new UnsupportedError(sb.toString());
}
@@ -70,8 +71,9 @@
// Add characters from the original string between this edit and the last
// one, if any.
var betweenEdits = original.substring(consumed, edit.begin);
- printer..add(betweenEdits, location: _loc(consumed), isOriginal: true)
- ..add(edit.replace, location: _loc(edit.begin));
+ printer
+ ..add(betweenEdits, location: _loc(consumed), isOriginal: true)
+ ..add(edit.replace, location: _loc(edit.begin));
consumed = edit.end;
}
diff --git a/lib/src/vlq.dart b/lib/src/vlq.dart
index e4ab4eb..0c54dbf 100644
--- a/lib/src/vlq.dart
+++ b/lib/src/vlq.dart
@@ -2,7 +2,6 @@
// 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.
-
/// Utilities to encode and decode VLQ values used in source maps.
///
/// Sourcemaps are encoded with variable length numbers as base64 encoded
diff --git a/test/builder_test.dart b/test/builder_test.dart
index dcc583c..7c27e4e 100644
--- a/test/builder_test.dart
+++ b/test/builder_test.dart
@@ -12,20 +12,20 @@
main() {
test('builder - with span', () {
var map = (new SourceMapBuilder()
- ..addSpan(inputVar1, outputVar1)
- ..addSpan(inputFunction, outputFunction)
- ..addSpan(inputVar2, outputVar2)
- ..addSpan(inputExpr, outputExpr))
+ ..addSpan(inputVar1, outputVar1)
+ ..addSpan(inputFunction, outputFunction)
+ ..addSpan(inputVar2, outputVar2)
+ ..addSpan(inputExpr, outputExpr))
.build(output.url.toString());
expect(map, equals(EXPECTED_MAP));
});
test('builder - with location', () {
var str = (new SourceMapBuilder()
- ..addLocation(inputVar1.start, outputVar1.start, 'longVar1')
- ..addLocation(inputFunction.start, outputFunction.start, 'longName')
- ..addLocation(inputVar2.start, outputVar2.start, 'longVar2')
- ..addLocation(inputExpr.start, outputExpr.start, null))
+ ..addLocation(inputVar1.start, outputVar1.start, 'longVar1')
+ ..addLocation(inputFunction.start, outputFunction.start, 'longName')
+ ..addLocation(inputVar2.start, outputVar2.start, 'longVar2')
+ ..addLocation(inputExpr.start, outputExpr.start, null))
.toJson(output.url.toString());
expect(str, JSON.encode(EXPECTED_MAP));
});
diff --git a/test/common.dart b/test/common.dart
index 3bc512c..01ffdad 100644
--- a/test/common.dart
+++ b/test/common.dart
@@ -63,19 +63,19 @@
/// 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 {
- 'version': 3,
- 'sourceRoot': '',
- 'sources': const ['input.dart'],
- 'names': const ['longVar1','longName','longVar2'],
- 'mappings': 'IACIA;AAGAC,EAAaC,MACR',
- 'file': 'output.dart'
+ 'version': 3,
+ 'sourceRoot': '',
+ 'sources': const ['input.dart'],
+ 'names': const ['longVar1', 'longName', 'longVar2'],
+ 'mappings': 'IACIA;AAGAC,EAAaC,MACR',
+ 'file': 'output.dart'
};
check(SourceSpan outputSpan, Mapping mapping, SourceMapSpan inputSpan,
bool realOffsets) {
var line = outputSpan.start.line;
var column = outputSpan.start.column;
- var files = realOffsets ? {'input.dart': input} : null;
+ var files = realOffsets ? {'input.dart': input} : null;
var span = mapping.spanFor(line, column, files: files);
var span2 = mapping.spanForLocation(outputSpan.start, files: files);
diff --git a/test/end2end_test.dart b/test/end2end_test.dart
index 8caf2e9..dd5bced 100644
--- a/test/end2end_test.dart
+++ b/test/end2end_test.dart
@@ -30,10 +30,10 @@
test('build + parse', () {
var map = (new SourceMapBuilder()
- ..addSpan(inputVar1, outputVar1)
- ..addSpan(inputFunction, outputFunction)
- ..addSpan(inputVar2, outputVar2)
- ..addSpan(inputExpr, outputExpr))
+ ..addSpan(inputVar1, outputVar1)
+ ..addSpan(inputFunction, outputFunction)
+ ..addSpan(inputVar2, outputVar2)
+ ..addSpan(inputExpr, outputExpr))
.build(output.url.toString());
var mapping = parseJson(map);
check(outputVar1, mapping, inputVar1, false);
@@ -44,10 +44,10 @@
test('build + parse - no symbols', () {
var map = (new SourceMapBuilder()
- ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
- ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
- ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
- ..addSpan(inputExpr, outputExpr))
+ ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
+ ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
+ ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
+ ..addSpan(inputExpr, outputExpr))
.build(output.url.toString());
var mapping = parseJson(map);
check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false);
@@ -58,14 +58,14 @@
test('build + parse, repeated entries', () {
var map = (new SourceMapBuilder()
- ..addSpan(inputVar1, outputVar1)
- ..addSpan(inputVar1, outputVar1)
- ..addSpan(inputFunction, outputFunction)
- ..addSpan(inputFunction, outputFunction)
- ..addSpan(inputVar2, outputVar2)
- ..addSpan(inputVar2, outputVar2)
- ..addSpan(inputExpr, outputExpr)
- ..addSpan(inputExpr, outputExpr))
+ ..addSpan(inputVar1, outputVar1)
+ ..addSpan(inputVar1, outputVar1)
+ ..addSpan(inputFunction, outputFunction)
+ ..addSpan(inputFunction, outputFunction)
+ ..addSpan(inputVar2, outputVar2)
+ ..addSpan(inputVar2, outputVar2)
+ ..addSpan(inputExpr, outputExpr)
+ ..addSpan(inputExpr, outputExpr))
.build(output.url.toString());
var mapping = parseJson(map);
check(outputVar1, mapping, inputVar1, false);
@@ -76,13 +76,13 @@
test('build + parse - no symbols, repeated entries', () {
var map = (new SourceMapBuilder()
- ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
- ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
- ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
- ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
- ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
- ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
- ..addSpan(inputExpr, outputExpr))
+ ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
+ ..addSpan(inputVar1NoSymbol, outputVar1NoSymbol)
+ ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
+ ..addSpan(inputFunctionNoSymbol, outputFunctionNoSymbol)
+ ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
+ ..addSpan(inputVar2NoSymbol, outputVar2NoSymbol)
+ ..addSpan(inputExpr, outputExpr))
.build(output.url.toString());
var mapping = parseJson(map);
check(outputVar1NoSymbol, mapping, inputVar1NoSymbol, false);
@@ -93,10 +93,10 @@
test('build + parse with file', () {
var json = (new SourceMapBuilder()
- ..addSpan(inputVar1, outputVar1)
- ..addSpan(inputFunction, outputFunction)
- ..addSpan(inputVar2, outputVar2)
- ..addSpan(inputExpr, outputExpr))
+ ..addSpan(inputVar1, outputVar1)
+ ..addSpan(inputFunction, outputFunction)
+ ..addSpan(inputVar2, outputVar2)
+ ..addSpan(inputExpr, outputExpr))
.toJson(output.url.toString());
var mapping = parse(json);
check(outputVar1, mapping, inputVar1, true);
@@ -156,7 +156,7 @@
var oOffset = out.length - 2;
var iOffset = INPUT.length - 2;
check(file.span(oOffset, oOffset), mapping, ispan(iOffset, iOffset), true);
- check(file.span(oOffset + 1, oOffset + 1), mapping,
- ispan(iOffset, iOffset), true);
+ check(file.span(oOffset + 1, oOffset + 1), mapping, ispan(iOffset, iOffset),
+ true);
});
}
diff --git a/test/printer_test.dart b/test/printer_test.dart
index 25036ee..3fd768d 100644
--- a/test/printer_test.dart
+++ b/test/printer_test.dart
@@ -13,15 +13,16 @@
main() {
test('printer', () {
var printer = new Printer('output.dart');
- printer..add('var ')
- ..mark(inputVar1)
- ..add('x = 3;\n')
- ..mark(inputFunction)
- ..add('f(')
- ..mark(inputVar2)
- ..add('y) => ')
- ..mark(inputExpr)
- ..add('x + y;\n');
+ printer
+ ..add('var ')
+ ..mark(inputVar1)
+ ..add('x = 3;\n')
+ ..mark(inputFunction)
+ ..add('f(')
+ ..mark(inputVar2)
+ ..add('y) => ')
+ ..mark(inputExpr)
+ ..add('x + y;\n');
expect(printer.text, OUTPUT);
expect(printer.map, JSON.encode(EXPECTED_MAP));
});
@@ -32,48 +33,50 @@
var segments = INPUT.split('long');
expect(segments.length, 6);
- printer..mark(ispan(0, 0))
- ..add(segments[0], projectMarks: true)
- ..mark(inputVar1)
- ..add('_s')
- ..add(segments[1], projectMarks: true)
- ..mark(inputFunction)
- ..add('_s')
- ..add(segments[2], projectMarks: true)
- ..mark(inputVar2)
- ..add('_s')
- ..add(segments[3], projectMarks: true)
- ..mark(inputExpr)
- ..add('_s')
- ..add(segments[4], projectMarks: true)
- ..add('_s')
- ..add(segments[5], projectMarks: true);
+ printer
+ ..mark(ispan(0, 0))
+ ..add(segments[0], projectMarks: true)
+ ..mark(inputVar1)
+ ..add('_s')
+ ..add(segments[1], projectMarks: true)
+ ..mark(inputFunction)
+ ..add('_s')
+ ..add(segments[2], projectMarks: true)
+ ..mark(inputVar2)
+ ..add('_s')
+ ..add(segments[3], projectMarks: true)
+ ..mark(inputExpr)
+ ..add('_s')
+ ..add(segments[4], projectMarks: true)
+ ..add('_s')
+ ..add(segments[5], projectMarks: true);
expect(printer.text, out);
// 8 new lines in the source map:
expect(printer.map.split(';').length, 8);
- asFixed(SourceMapSpan s) => new SourceMapSpan(s.start, s.end, s.text,
- isIdentifier: s.isIdentifier);
+ asFixed(SourceMapSpan s) =>
+ new 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');
- printer2..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan())
- ..add(segments[0], projectMarks: true)
- ..mark(asFixed(inputVar1))
- ..add('_s')
- ..add(segments[1], projectMarks: true)
- ..mark(asFixed(inputFunction))
- ..add('_s')
- ..add(segments[2], projectMarks: true)
- ..mark(asFixed(inputVar2))
- ..add('_s')
- ..add(segments[3], projectMarks: true)
- ..mark(asFixed(inputExpr))
- ..add('_s')
- ..add(segments[4], projectMarks: true)
- ..add('_s')
- ..add(segments[5], projectMarks: true);
+ printer2
+ ..mark(new SourceLocation(0, sourceUrl: 'input.dart').pointSpan())
+ ..add(segments[0], projectMarks: true)
+ ..mark(asFixed(inputVar1))
+ ..add('_s')
+ ..add(segments[1], projectMarks: true)
+ ..mark(asFixed(inputFunction))
+ ..add('_s')
+ ..add(segments[2], projectMarks: true)
+ ..mark(asFixed(inputVar2))
+ ..add('_s')
+ ..add(segments[3], projectMarks: true)
+ ..mark(asFixed(inputExpr))
+ ..add('_s')
+ ..add(segments[4], projectMarks: true)
+ ..add('_s')
+ ..add(segments[5], projectMarks: true);
expect(printer2.text, out);
expect(printer2.map, printer.map);
@@ -82,24 +85,26 @@
group('nested printer', () {
test('simple use', () {
var printer = new NestedPrinter();
- printer..add('var ')
- ..add('x = 3;\n', span: inputVar1)
- ..add('f(', span: inputFunction)
- ..add('y) => ', span: inputVar2)
- ..add('x + y;\n', span: inputExpr)
- ..build('output.dart');
+ printer
+ ..add('var ')
+ ..add('x = 3;\n', span: inputVar1)
+ ..add('f(', span: inputFunction)
+ ..add('y) => ', span: inputVar2)
+ ..add('x + y;\n', span: inputExpr)
+ ..build('output.dart');
expect(printer.text, OUTPUT);
expect(printer.map, JSON.encode(EXPECTED_MAP));
});
test('nested use', () {
var printer = new NestedPrinter();
- printer..add('var ')
- ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1))
- ..add('f(', span: inputFunction)
- ..add(new NestedPrinter()..add('y) => ', span: inputVar2))
- ..add('x + y;\n', span: inputExpr)
- ..build('output.dart');
+ printer
+ ..add('var ')
+ ..add(new NestedPrinter()..add('x = 3;\n', span: inputVar1))
+ ..add('f(', span: inputFunction)
+ ..add(new NestedPrinter()..add('y) => ', span: inputVar2))
+ ..add('x + y;\n', span: inputExpr)
+ ..build('output.dart');
expect(printer.text, OUTPUT);
expect(printer.map, JSON.encode(EXPECTED_MAP));
});
diff --git a/test/refactor_test.dart b/test/refactor_test.dart
index 03292d1..afaeec2 100644
--- a/test/refactor_test.dart
+++ b/test/refactor_test.dart
@@ -33,15 +33,16 @@
txn.edit(6, 7, '_');
txn.edit(6, 6, '-');
expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij");
-
});
test('conflict', () {
var txn = new TextEditTransaction(original, file);
txn.edit(2, 4, '.');
txn.edit(3, 3, '-');
- expect(() => txn.commit(), throwsA(predicate(
- (e) => e.toString().contains('overlapping edits'))));
+ expect(
+ () => txn.commit(),
+ throwsA(
+ predicate((e) => e.toString().contains('overlapping edits'))));
});
});
@@ -60,40 +61,48 @@
// Line 1 and 2 are unmodified: mapping any column returns the beginning
// of the corresponding line:
- expect(_span(1, 1, map, file),
+ expect(
+ _span(1, 1, map, file),
"line 1, column 1: \n"
"0123456789\n"
"^");
- expect(_span(1, 5, map, file),
+ expect(
+ _span(1, 5, map, file),
"line 1, column 1: \n"
"0123456789\n"
"^");
- expect(_span(2, 1, map, file),
+ expect(
+ _span(2, 1, map, file),
"line 2, column 1: \n"
"0*23456789\n"
"^");
- expect(_span(2, 8, map, file),
+ expect(
+ _span(2, 8, map, file),
"line 2, column 1: \n"
"0*23456789\n"
"^");
// Line 3 is modified part way: mappings before the edits have the right
// mapping, after the edits the mapping is null.
- expect(_span(3, 1, map, file),
+ expect(
+ _span(3, 1, map, file),
"line 3, column 1: \n"
"01*3456789\n"
"^");
- expect(_span(3, 5, map, file),
+ expect(
+ _span(3, 5, map, file),
"line 3, column 1: \n"
"01*3456789\n"
"^");
// Start of edits map to beginning of the edit secion:
- expect(_span(3, 6, map, file),
+ expect(
+ _span(3, 6, map, file),
"line 3, column 6: \n"
"01*3456789\n"
" ^");
- expect(_span(3, 7, map, file),
+ expect(
+ _span(3, 7, map, file),
"line 3, column 6: \n"
"01*3456789\n"
" ^");
@@ -101,42 +110,50 @@
// Lines added have no mapping (they should inherit the last mapping),
// but the end of the edit region continues were we left off:
expect(_span(4, 1, map, file), isNull);
- expect(_span(4, 5, map, file),
+ expect(
+ _span(4, 5, map, file),
"line 3, column 8: \n"
"01*3456789\n"
" ^");
// Subsequent lines are still mapped correctly:
// a (in a___cd...)
- expect(_span(5, 1, map, file),
+ expect(
+ _span(5, 1, map, file),
"line 4, column 1: \n"
"abcdefghij\n"
"^");
// _ (in a___cd...)
- expect(_span(5, 2, map, file),
+ expect(
+ _span(5, 2, map, file),
"line 4, column 2: \n"
"abcdefghij\n"
" ^");
// _ (in a___cd...)
- expect(_span(5, 3, map, file),
+ expect(
+ _span(5, 3, map, file),
"line 4, column 2: \n"
"abcdefghij\n"
" ^");
// _ (in a___cd...)
- expect(_span(5, 4, map, file),
+ expect(
+ _span(5, 4, map, file),
"line 4, column 2: \n"
"abcdefghij\n"
" ^");
// c (in a___cd...)
- expect(_span(5, 5, map, file),
+ expect(
+ _span(5, 5, map, file),
"line 4, column 3: \n"
"abcdefghij\n"
" ^");
- expect(_span(6, 1, map, file),
+ expect(
+ _span(6, 1, map, file),
"line 5, column 1: \n"
"abcd*fghij\n"
"^");
- expect(_span(6, 8, map, file),
+ expect(
+ _span(6, 8, map, file),
"line 5, column 1: \n"
"abcd*fghij\n"
"^");
diff --git a/test/utils_test.dart b/test/utils_test.dart
index cbbb40a..6790082 100644
--- a/test/utils_test.dart
+++ b/test/utils_test.dart
@@ -51,4 +51,3 @@
}
return list.length;
}
-
diff --git a/test/vlq_test.dart b/test/vlq_test.dart
index d1b543d..30b6d45 100644
--- a/test/vlq_test.dart
+++ b/test/vlq_test.dart
@@ -42,7 +42,6 @@
expect(() => encodeVlq(min_int - 1), throws);
expect(() => encodeVlq(min_int - 2), throws);
-
// if we allowed more than 32 bits, these would be the expected encodings
// for the large numbers above.
expect(() => decodeVlq('ggggggE'.split('').iterator), throws);