Run dartfmt --fix (#6)
diff --git a/lib/source_map_stack_trace.dart b/lib/source_map_stack_trace.dart index d0252e0..f32f2bf 100644 --- a/lib/source_map_stack_trace.dart +++ b/lib/source_map_stack_trace.dart
@@ -23,22 +23,22 @@ /// [packageRoot] is deprecated and shouldn't be used in new code. This throws /// an [ArgumentError] if [packageRoot] and [packageResolver] are both passed. StackTrace mapStackTrace(Mapping sourceMap, StackTrace stackTrace, - {bool minified: false, + {bool minified = false, SyncPackageResolver packageResolver, sdkRoot, @Deprecated("Use the packageResolver parameter instead.") packageRoot}) { if (packageRoot != null) { if (packageResolver != null) { - throw new ArgumentError( + throw ArgumentError( "packageResolver and packageRoot may not both be passed."); } - packageResolver = new SyncPackageResolver.root(packageRoot); + packageResolver = SyncPackageResolver.root(packageRoot); } if (stackTrace is Chain) { - return new Chain(stackTrace.traces.map((trace) { - return new Trace.from(mapStackTrace(sourceMap, trace, + return Chain(stackTrace.traces.map((trace) { + return Trace.from(mapStackTrace(sourceMap, trace, minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot)); @@ -46,14 +46,13 @@ } if (sdkRoot != null && sdkRoot is! String && sdkRoot is! Uri) { - throw new ArgumentError( - 'sdkRoot must be a String or a Uri, was "$sdkRoot".'); + throw ArgumentError('sdkRoot must be a String or a Uri, was "$sdkRoot".'); } var sdkLib = sdkRoot == null ? null : "$sdkRoot/lib"; - var trace = new Trace.from(stackTrace); - return new Trace(trace.frames.map((frame) { + var trace = Trace.from(stackTrace); + return Trace(trace.frames.map((frame) { // If there's no line information, there's no way to translate this frame. // We could return it as-is, but these lines are usually not useful anyways. if (frame.line == null) return null; @@ -91,7 +90,7 @@ } } - return new Frame( + return Frame( Uri.parse(sourceUrl), span.start.line + 1, span.start.column + 1, @@ -108,27 +107,26 @@ String _prettifyMember(String member) { return member // Get rid of the noise that Firefox sometimes adds. - .replaceAll(new RegExp(r"/?<$"), "") + .replaceAll(RegExp(r"/?<$"), "") // Get rid of arity indicators and named arguments. - .replaceAll(new RegExp(r"\$\d+(\$[a-zA-Z_0-9]+)*$"), "") + .replaceAll(RegExp(r"\$\d+(\$[a-zA-Z_0-9]+)*$"), "") // Convert closures to <fn>. .replaceAllMapped( - new RegExp(r"(_+)closure\d*\.call$"), + RegExp(r"(_+)closure\d*\.call$"), // The number of underscores before "closure" indicates how nested it // is. (match) => ".<fn>" * match[1].length) // Get rid of explicitly-generated calls. - .replaceAll(new RegExp(r"\.call$"), "") + .replaceAll(RegExp(r"\.call$"), "") // Get rid of the top-level method prefix. - .replaceAll(new RegExp(r"^dart\."), "") + .replaceAll(RegExp(r"^dart\."), "") // Get rid of library namespaces. - .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "") + .replaceAll(RegExp(r"[a-zA-Z_0-9]+\$"), "") // Get rid of the static method prefix. The class name also exists in the // invocation, so we're not getting rid of any information. - .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "") + .replaceAll(RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "") // Convert underscores after identifiers to dots. This runs the risk of // incorrectly converting members that contain underscores, but those are // contrary to the style guide anyway. - .replaceAllMapped( - new RegExp(r"([a-zA-Z0-9]+)_"), (match) => match[1] + "."); + .replaceAllMapped(RegExp(r"([a-zA-Z0-9]+)_"), (match) => match[1] + "."); }
diff --git a/pubspec.yaml b/pubspec.yaml index 77cf804..676d9fc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,5 +1,5 @@ name: source_map_stack_trace -version: 1.1.5 +version: 1.1.6-dev description: A package for applying source maps to stack traces. author: Dart Team <misc@dartlang.org>
diff --git a/test/source_map_stack_trace_test.dart b/test/source_map_stack_trace_test.dart index 18a5652..2b7da56 100644 --- a/test/source_map_stack_trace_test.dart +++ b/test/source_map_stack_trace_test.dart
@@ -11,18 +11,18 @@ import 'package:test/test.dart'; /// A simple [Mapping] for tests that don't need anything special. -final _simpleMapping = parseJson((new SourceMapBuilder() +final _simpleMapping = parseJson((SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"), + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(18, line: 15, column: 0), "\n" * 10))) + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(18, line: 15, column: 0), "\n" * 10))) .build("foo.dart.js.map")); void main() { test("maps a JS line and column to a Dart line and span", () { - var trace = new Trace.parse("foo.dart.js 10:11 foo"); + var trace = Trace.parse("foo.dart.js 10:11 foo"); var frame = _mapTrace(_simpleMapping, trace).frames.first; expect(frame.uri, equals(Uri.parse("foo.dart"))); @@ -33,7 +33,7 @@ }); test("ignores JS frames without line info", () { - var trace = new Trace.parse(""" + var trace = Trace.parse(""" foo.dart.js 10:11 foo foo.dart.js bar foo.dart.js 10:11 baz @@ -46,7 +46,7 @@ }); test("ignores JS frames without corresponding spans", () { - var trace = new Trace.parse(""" + var trace = Trace.parse(""" foo.dart.js 10:11 foo foo.dart.js 1:1 bar foo.dart.js 10:11 baz @@ -60,37 +60,37 @@ }); test("include frames from JS files not covered by the source map bundle", () { - var trace = new Trace.parse(""" + var trace = Trace.parse(""" foo.dart.js 10:11 foo jquery.js 10:1 foo bar.dart.js 10:11 foo """); - var builder = new SourceMapBuilder() + var builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var sourceMapJson1 = builder.build("foo.dart.js.map"); sourceMapJson1['file'] = "foo.dart.js"; - builder = new SourceMapBuilder() + builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "packages/bar/bar.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var sourceMapJson2 = builder.build("bar.dart.js.map"); sourceMapJson2['file'] = "bar.dart.js"; var bundle = [sourceMapJson1, sourceMapJson2]; var mapping = parseJsonExtended(bundle); var frames = _mapTrace(mapping, trace, - packageResolver: new SyncPackageResolver.root("packages/")) + packageResolver: SyncPackageResolver.root("packages/")) .frames; expect(frames.length, equals(3)); @@ -111,14 +111,14 @@ }); test("falls back to column 0 for unlisted column", () { - var trace = new Trace.parse("foo.dart.js 10 foo"); - var builder = new SourceMapBuilder() + var trace = Trace.parse("foo.dart.js 10 foo"); + var builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"), + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var mapping = parseJson(builder.build("foo.dart.js.map")); var frame = _mapTrace(mapping, trace).frames.first; @@ -128,15 +128,15 @@ }); test("uses package: URIs for frames within packageRoot", () { - var trace = new Trace.parse("foo.dart.js 10 foo"); - var builder = new SourceMapBuilder() + var trace = Trace.parse("foo.dart.js 10 foo"); + var builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var mapping = parseJson(builder.build("foo.dart.js.map")); var frame = @@ -147,19 +147,19 @@ }); test("uses package: URIs for frames within packageResolver.packageRoot", () { - var trace = new Trace.parse("foo.dart.js 10 foo"); - var builder = new SourceMapBuilder() + var trace = Trace.parse("foo.dart.js 10 foo"); + var builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var mapping = parseJson(builder.build("foo.dart.js.map")); var mappedTrace = _mapTrace(mapping, trace, - packageResolver: new SyncPackageResolver.root("packages/")); + packageResolver: SyncPackageResolver.root("packages/")); var frame = mappedTrace.frames.first; expect(frame.uri, equals(Uri.parse("package:foo/foo.dart"))); expect(frame.line, equals(2)); @@ -168,20 +168,20 @@ test("uses package: URIs for frames within a packageResolver.packageMap URL", () { - var trace = new Trace.parse("foo.dart.js 10 foo"); - var builder = new SourceMapBuilder() + var trace = Trace.parse("foo.dart.js 10 foo"); + var builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "packages/foo/foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var mapping = parseJson(builder.build("foo.dart.js.map")); var mappedTrace = _mapTrace(mapping, trace, packageResolver: - new SyncPackageResolver.config({"foo": Uri.parse("packages/foo")})); + SyncPackageResolver.config({"foo": Uri.parse("packages/foo")})); var frame = mappedTrace.frames.first; expect(frame.uri, equals(Uri.parse("package:foo/foo.dart"))); expect(frame.line, equals(2)); @@ -189,15 +189,15 @@ }); test("uses dart: URIs for frames within sdkRoot", () { - var trace = new Trace.parse("foo.dart.js 10 foo"); - var builder = new SourceMapBuilder() + var trace = Trace.parse("foo.dart.js 10 foo"); + var builder = SourceMapBuilder() ..addSpan( - new SourceMapSpan.identifier( - new SourceLocation(1, + SourceMapSpan.identifier( + SourceLocation(1, line: 1, column: 3, sourceUrl: "sdk/lib/async/foo.dart"), "qux"), - new SourceSpan(new SourceLocation(8, line: 5, column: 0), - new SourceLocation(12, line: 9, column: 1), "\n" * 4)); + SourceSpan(SourceLocation(8, line: 5, column: 0), + SourceLocation(12, line: 9, column: 1), "\n" * 4)); var mapping = parseJson(builder.build("foo.dart.js.map")); var frame = _mapTrace(mapping, trace, sdkRoot: "sdk/").frames.first; @@ -207,9 +207,9 @@ }); test("converts a stack chain", () { - var trace = new Chain([ - new Trace.parse("foo.dart.js 10:11 foo"), - new Trace.parse("foo.dart.js 10:11 bar") + var trace = Chain([ + Trace.parse("foo.dart.js 10:11 foo"), + Trace.parse("foo.dart.js 10:11 bar") ]); var traces = _mapChain(_simpleMapping, trace).traces; @@ -282,11 +282,11 @@ /// Like [mapStackTrace], but is guaranteed to return a [Trace] so it can be /// inspected. Trace _mapTrace(Mapping sourceMap, StackTrace stackTrace, - {bool minified: false, + {bool minified = false, SyncPackageResolver packageResolver, sdkRoot, packageRoot}) { - return new Trace.from(mapStackTrace(sourceMap, stackTrace, + return Trace.from(mapStackTrace(sourceMap, stackTrace, minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot, @@ -296,11 +296,11 @@ /// Like [mapStackTrace], but is guaranteed to return a [Chain] so it can be /// inspected. Chain _mapChain(Mapping sourceMap, StackTrace stackTrace, - {bool minified: false, + {bool minified = false, SyncPackageResolver packageResolver, sdkRoot, packageRoot}) { - return new Chain.forTrace(mapStackTrace(sourceMap, stackTrace, + return Chain.forTrace(mapStackTrace(sourceMap, stackTrace, minified: minified, packageResolver: packageResolver, sdkRoot: sdkRoot, @@ -309,6 +309,6 @@ /// Runs the mapper's prettification logic on [member] and returns the result. String _prettify(String member) { - var trace = new Trace([new Frame(Uri.parse("foo.dart.js"), 10, 11, member)]); + var trace = Trace([Frame(Uri.parse("foo.dart.js"), 10, 11, member)]); return _mapTrace(_simpleMapping, trace).frames.first.member; }