Skip to content

Commit 92c4e59

Browse files
authored
Run dartfmt --fix (flutter#6)
1 parent 1877186 commit 92c4e59

File tree

3 files changed

+78
-80
lines changed

3 files changed

+78
-80
lines changed

lib/source_map_stack_trace.dart

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,36 @@ import 'package:stack_trace/stack_trace.dart';
2323
/// [packageRoot] is deprecated and shouldn't be used in new code. This throws
2424
/// an [ArgumentError] if [packageRoot] and [packageResolver] are both passed.
2525
StackTrace mapStackTrace(Mapping sourceMap, StackTrace stackTrace,
26-
{bool minified: false,
26+
{bool minified = false,
2727
SyncPackageResolver packageResolver,
2828
sdkRoot,
2929
@Deprecated("Use the packageResolver parameter instead.") packageRoot}) {
3030
if (packageRoot != null) {
3131
if (packageResolver != null) {
32-
throw new ArgumentError(
32+
throw ArgumentError(
3333
"packageResolver and packageRoot may not both be passed.");
3434
}
3535

36-
packageResolver = new SyncPackageResolver.root(packageRoot);
36+
packageResolver = SyncPackageResolver.root(packageRoot);
3737
}
3838

3939
if (stackTrace is Chain) {
40-
return new Chain(stackTrace.traces.map((trace) {
41-
return new Trace.from(mapStackTrace(sourceMap, trace,
40+
return Chain(stackTrace.traces.map((trace) {
41+
return Trace.from(mapStackTrace(sourceMap, trace,
4242
minified: minified,
4343
packageResolver: packageResolver,
4444
sdkRoot: sdkRoot));
4545
}));
4646
}
4747

4848
if (sdkRoot != null && sdkRoot is! String && sdkRoot is! Uri) {
49-
throw new ArgumentError(
50-
'sdkRoot must be a String or a Uri, was "$sdkRoot".');
49+
throw ArgumentError('sdkRoot must be a String or a Uri, was "$sdkRoot".');
5150
}
5251

5352
var sdkLib = sdkRoot == null ? null : "$sdkRoot/lib";
5453

55-
var trace = new Trace.from(stackTrace);
56-
return new Trace(trace.frames.map((frame) {
54+
var trace = Trace.from(stackTrace);
55+
return Trace(trace.frames.map((frame) {
5756
// If there's no line information, there's no way to translate this frame.
5857
// We could return it as-is, but these lines are usually not useful anyways.
5958
if (frame.line == null) return null;
@@ -91,7 +90,7 @@ StackTrace mapStackTrace(Mapping sourceMap, StackTrace stackTrace,
9190
}
9291
}
9392

94-
return new Frame(
93+
return Frame(
9594
Uri.parse(sourceUrl),
9695
span.start.line + 1,
9796
span.start.column + 1,
@@ -108,27 +107,26 @@ StackTrace mapStackTrace(Mapping sourceMap, StackTrace stackTrace,
108107
String _prettifyMember(String member) {
109108
return member
110109
// Get rid of the noise that Firefox sometimes adds.
111-
.replaceAll(new RegExp(r"/?<$"), "")
110+
.replaceAll(RegExp(r"/?<$"), "")
112111
// Get rid of arity indicators and named arguments.
113-
.replaceAll(new RegExp(r"\$\d+(\$[a-zA-Z_0-9]+)*$"), "")
112+
.replaceAll(RegExp(r"\$\d+(\$[a-zA-Z_0-9]+)*$"), "")
114113
// Convert closures to <fn>.
115114
.replaceAllMapped(
116-
new RegExp(r"(_+)closure\d*\.call$"),
115+
RegExp(r"(_+)closure\d*\.call$"),
117116
// The number of underscores before "closure" indicates how nested it
118117
// is.
119118
(match) => ".<fn>" * match[1].length)
120119
// Get rid of explicitly-generated calls.
121-
.replaceAll(new RegExp(r"\.call$"), "")
120+
.replaceAll(RegExp(r"\.call$"), "")
122121
// Get rid of the top-level method prefix.
123-
.replaceAll(new RegExp(r"^dart\."), "")
122+
.replaceAll(RegExp(r"^dart\."), "")
124123
// Get rid of library namespaces.
125-
.replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "")
124+
.replaceAll(RegExp(r"[a-zA-Z_0-9]+\$"), "")
126125
// Get rid of the static method prefix. The class name also exists in the
127126
// invocation, so we're not getting rid of any information.
128-
.replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "")
127+
.replaceAll(RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "")
129128
// Convert underscores after identifiers to dots. This runs the risk of
130129
// incorrectly converting members that contain underscores, but those are
131130
// contrary to the style guide anyway.
132-
.replaceAllMapped(
133-
new RegExp(r"([a-zA-Z0-9]+)_"), (match) => match[1] + ".");
131+
.replaceAllMapped(RegExp(r"([a-zA-Z0-9]+)_"), (match) => match[1] + ".");
134132
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: source_map_stack_trace
2-
version: 1.1.5
2+
version: 1.1.6-dev
33

44
description: A package for applying source maps to stack traces.
55
author: Dart Team <[email protected]>

test/source_map_stack_trace_test.dart

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import 'package:source_map_stack_trace/source_map_stack_trace.dart';
1111
import 'package:test/test.dart';
1212

1313
/// A simple [Mapping] for tests that don't need anything special.
14-
final _simpleMapping = parseJson((new SourceMapBuilder()
14+
final _simpleMapping = parseJson((SourceMapBuilder()
1515
..addSpan(
16-
new SourceMapSpan.identifier(
17-
new SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"),
16+
SourceMapSpan.identifier(
17+
SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"),
1818
"qux"),
19-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
20-
new SourceLocation(18, line: 15, column: 0), "\n" * 10)))
19+
SourceSpan(SourceLocation(8, line: 5, column: 0),
20+
SourceLocation(18, line: 15, column: 0), "\n" * 10)))
2121
.build("foo.dart.js.map"));
2222

2323
void main() {
2424
test("maps a JS line and column to a Dart line and span", () {
25-
var trace = new Trace.parse("foo.dart.js 10:11 foo");
25+
var trace = Trace.parse("foo.dart.js 10:11 foo");
2626
var frame = _mapTrace(_simpleMapping, trace).frames.first;
2727
expect(frame.uri, equals(Uri.parse("foo.dart")));
2828

@@ -33,7 +33,7 @@ void main() {
3333
});
3434

3535
test("ignores JS frames without line info", () {
36-
var trace = new Trace.parse("""
36+
var trace = Trace.parse("""
3737
foo.dart.js 10:11 foo
3838
foo.dart.js bar
3939
foo.dart.js 10:11 baz
@@ -46,7 +46,7 @@ foo.dart.js 10:11 baz
4646
});
4747

4848
test("ignores JS frames without corresponding spans", () {
49-
var trace = new Trace.parse("""
49+
var trace = Trace.parse("""
5050
foo.dart.js 10:11 foo
5151
foo.dart.js 1:1 bar
5252
foo.dart.js 10:11 baz
@@ -60,37 +60,37 @@ foo.dart.js 10:11 baz
6060
});
6161

6262
test("include frames from JS files not covered by the source map bundle", () {
63-
var trace = new Trace.parse("""
63+
var trace = Trace.parse("""
6464
foo.dart.js 10:11 foo
6565
jquery.js 10:1 foo
6666
bar.dart.js 10:11 foo
6767
""");
68-
var builder = new SourceMapBuilder()
68+
var builder = SourceMapBuilder()
6969
..addSpan(
70-
new SourceMapSpan.identifier(
71-
new SourceLocation(1,
70+
SourceMapSpan.identifier(
71+
SourceLocation(1,
7272
line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
7373
"qux"),
74-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
75-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
74+
SourceSpan(SourceLocation(8, line: 5, column: 0),
75+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
7676
var sourceMapJson1 = builder.build("foo.dart.js.map");
7777
sourceMapJson1['file'] = "foo.dart.js";
7878

79-
builder = new SourceMapBuilder()
79+
builder = SourceMapBuilder()
8080
..addSpan(
81-
new SourceMapSpan.identifier(
82-
new SourceLocation(1,
81+
SourceMapSpan.identifier(
82+
SourceLocation(1,
8383
line: 1, column: 3, sourceUrl: "packages/bar/bar.dart"),
8484
"qux"),
85-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
86-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
85+
SourceSpan(SourceLocation(8, line: 5, column: 0),
86+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
8787
var sourceMapJson2 = builder.build("bar.dart.js.map");
8888
sourceMapJson2['file'] = "bar.dart.js";
8989

9090
var bundle = [sourceMapJson1, sourceMapJson2];
9191
var mapping = parseJsonExtended(bundle);
9292
var frames = _mapTrace(mapping, trace,
93-
packageResolver: new SyncPackageResolver.root("packages/"))
93+
packageResolver: SyncPackageResolver.root("packages/"))
9494
.frames;
9595

9696
expect(frames.length, equals(3));
@@ -111,14 +111,14 @@ bar.dart.js 10:11 foo
111111
});
112112

113113
test("falls back to column 0 for unlisted column", () {
114-
var trace = new Trace.parse("foo.dart.js 10 foo");
115-
var builder = new SourceMapBuilder()
114+
var trace = Trace.parse("foo.dart.js 10 foo");
115+
var builder = SourceMapBuilder()
116116
..addSpan(
117-
new SourceMapSpan.identifier(
118-
new SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"),
117+
SourceMapSpan.identifier(
118+
SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"),
119119
"qux"),
120-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
121-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
120+
SourceSpan(SourceLocation(8, line: 5, column: 0),
121+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
122122

123123
var mapping = parseJson(builder.build("foo.dart.js.map"));
124124
var frame = _mapTrace(mapping, trace).frames.first;
@@ -128,15 +128,15 @@ bar.dart.js 10:11 foo
128128
});
129129

130130
test("uses package: URIs for frames within packageRoot", () {
131-
var trace = new Trace.parse("foo.dart.js 10 foo");
132-
var builder = new SourceMapBuilder()
131+
var trace = Trace.parse("foo.dart.js 10 foo");
132+
var builder = SourceMapBuilder()
133133
..addSpan(
134-
new SourceMapSpan.identifier(
135-
new SourceLocation(1,
134+
SourceMapSpan.identifier(
135+
SourceLocation(1,
136136
line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
137137
"qux"),
138-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
139-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
138+
SourceSpan(SourceLocation(8, line: 5, column: 0),
139+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
140140

141141
var mapping = parseJson(builder.build("foo.dart.js.map"));
142142
var frame =
@@ -147,19 +147,19 @@ bar.dart.js 10:11 foo
147147
});
148148

149149
test("uses package: URIs for frames within packageResolver.packageRoot", () {
150-
var trace = new Trace.parse("foo.dart.js 10 foo");
151-
var builder = new SourceMapBuilder()
150+
var trace = Trace.parse("foo.dart.js 10 foo");
151+
var builder = SourceMapBuilder()
152152
..addSpan(
153-
new SourceMapSpan.identifier(
154-
new SourceLocation(1,
153+
SourceMapSpan.identifier(
154+
SourceLocation(1,
155155
line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
156156
"qux"),
157-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
158-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
157+
SourceSpan(SourceLocation(8, line: 5, column: 0),
158+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
159159

160160
var mapping = parseJson(builder.build("foo.dart.js.map"));
161161
var mappedTrace = _mapTrace(mapping, trace,
162-
packageResolver: new SyncPackageResolver.root("packages/"));
162+
packageResolver: SyncPackageResolver.root("packages/"));
163163
var frame = mappedTrace.frames.first;
164164
expect(frame.uri, equals(Uri.parse("package:foo/foo.dart")));
165165
expect(frame.line, equals(2));
@@ -168,36 +168,36 @@ bar.dart.js 10:11 foo
168168

169169
test("uses package: URIs for frames within a packageResolver.packageMap URL",
170170
() {
171-
var trace = new Trace.parse("foo.dart.js 10 foo");
172-
var builder = new SourceMapBuilder()
171+
var trace = Trace.parse("foo.dart.js 10 foo");
172+
var builder = SourceMapBuilder()
173173
..addSpan(
174-
new SourceMapSpan.identifier(
175-
new SourceLocation(1,
174+
SourceMapSpan.identifier(
175+
SourceLocation(1,
176176
line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"),
177177
"qux"),
178-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
179-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
178+
SourceSpan(SourceLocation(8, line: 5, column: 0),
179+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
180180

181181
var mapping = parseJson(builder.build("foo.dart.js.map"));
182182
var mappedTrace = _mapTrace(mapping, trace,
183183
packageResolver:
184-
new SyncPackageResolver.config({"foo": Uri.parse("packages/foo")}));
184+
SyncPackageResolver.config({"foo": Uri.parse("packages/foo")}));
185185
var frame = mappedTrace.frames.first;
186186
expect(frame.uri, equals(Uri.parse("package:foo/foo.dart")));
187187
expect(frame.line, equals(2));
188188
expect(frame.column, equals(4));
189189
});
190190

191191
test("uses dart: URIs for frames within sdkRoot", () {
192-
var trace = new Trace.parse("foo.dart.js 10 foo");
193-
var builder = new SourceMapBuilder()
192+
var trace = Trace.parse("foo.dart.js 10 foo");
193+
var builder = SourceMapBuilder()
194194
..addSpan(
195-
new SourceMapSpan.identifier(
196-
new SourceLocation(1,
195+
SourceMapSpan.identifier(
196+
SourceLocation(1,
197197
line: 1, column: 3, sourceUrl: "sdk/lib/async/foo.dart"),
198198
"qux"),
199-
new SourceSpan(new SourceLocation(8, line: 5, column: 0),
200-
new SourceLocation(12, line: 9, column: 1), "\n" * 4));
199+
SourceSpan(SourceLocation(8, line: 5, column: 0),
200+
SourceLocation(12, line: 9, column: 1), "\n" * 4));
201201

202202
var mapping = parseJson(builder.build("foo.dart.js.map"));
203203
var frame = _mapTrace(mapping, trace, sdkRoot: "sdk/").frames.first;
@@ -207,9 +207,9 @@ bar.dart.js 10:11 foo
207207
});
208208

209209
test("converts a stack chain", () {
210-
var trace = new Chain([
211-
new Trace.parse("foo.dart.js 10:11 foo"),
212-
new Trace.parse("foo.dart.js 10:11 bar")
210+
var trace = Chain([
211+
Trace.parse("foo.dart.js 10:11 foo"),
212+
Trace.parse("foo.dart.js 10:11 bar")
213213
]);
214214
var traces = _mapChain(_simpleMapping, trace).traces;
215215

@@ -282,11 +282,11 @@ bar.dart.js 10:11 foo
282282
/// Like [mapStackTrace], but is guaranteed to return a [Trace] so it can be
283283
/// inspected.
284284
Trace _mapTrace(Mapping sourceMap, StackTrace stackTrace,
285-
{bool minified: false,
285+
{bool minified = false,
286286
SyncPackageResolver packageResolver,
287287
sdkRoot,
288288
packageRoot}) {
289-
return new Trace.from(mapStackTrace(sourceMap, stackTrace,
289+
return Trace.from(mapStackTrace(sourceMap, stackTrace,
290290
minified: minified,
291291
packageResolver: packageResolver,
292292
sdkRoot: sdkRoot,
@@ -296,11 +296,11 @@ Trace _mapTrace(Mapping sourceMap, StackTrace stackTrace,
296296
/// Like [mapStackTrace], but is guaranteed to return a [Chain] so it can be
297297
/// inspected.
298298
Chain _mapChain(Mapping sourceMap, StackTrace stackTrace,
299-
{bool minified: false,
299+
{bool minified = false,
300300
SyncPackageResolver packageResolver,
301301
sdkRoot,
302302
packageRoot}) {
303-
return new Chain.forTrace(mapStackTrace(sourceMap, stackTrace,
303+
return Chain.forTrace(mapStackTrace(sourceMap, stackTrace,
304304
minified: minified,
305305
packageResolver: packageResolver,
306306
sdkRoot: sdkRoot,
@@ -309,6 +309,6 @@ Chain _mapChain(Mapping sourceMap, StackTrace stackTrace,
309309

310310
/// Runs the mapper's prettification logic on [member] and returns the result.
311311
String _prettify(String member) {
312-
var trace = new Trace([new Frame(Uri.parse("foo.dart.js"), 10, 11, member)]);
312+
var trace = Trace([Frame(Uri.parse("foo.dart.js"), 10, 11, member)]);
313313
return _mapTrace(_simpleMapping, trace).frames.first.member;
314314
}

0 commit comments

Comments
 (0)