OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.util.stack_trace_mapper; | |
6 | |
7 import 'package:source_map_stack_trace/source_map_stack_trace.dart' as mapper; | 5 import 'package:source_map_stack_trace/source_map_stack_trace.dart' as mapper; |
8 import 'package:source_maps/source_maps.dart'; | 6 import 'package:source_maps/source_maps.dart'; |
9 | 7 |
10 /// A class for mapping JS stack traces to Dart stack traces using source maps. | 8 /// A class for mapping JS stack traces to Dart stack traces using source maps. |
11 class StackTraceMapper { | 9 class StackTraceMapper { |
12 /// The parsed source map. | 10 /// The parsed source map. |
13 final Mapping _mapping; | 11 final Mapping _mapping; |
14 | 12 |
15 /// The URI of the package root, as passed to dart2js. | 13 /// The URI of the package root, as passed to dart2js. |
16 final Uri _packageRoot; | 14 final Uri _packageRoot; |
17 | 15 |
18 /// The URI of the SDK root from which dart2js loaded its sources. | 16 /// The URI of the SDK root from which dart2js loaded its sources. |
19 final Uri _sdkRoot; | 17 final Uri _sdkRoot; |
20 | 18 |
21 StackTraceMapper(String contents, {Uri mapUrl, Uri packageRoot, Uri sdkRoot}) | 19 StackTraceMapper(String contents, {Uri mapUrl, Uri packageRoot, Uri sdkRoot}) |
22 : _mapping = parse(contents, mapUrl: mapUrl), | 20 : _mapping = parse(contents, mapUrl: mapUrl), |
23 _packageRoot = packageRoot, | 21 _packageRoot = packageRoot, |
24 _sdkRoot = sdkRoot; | 22 _sdkRoot = sdkRoot; |
25 | 23 |
26 /// Converts [trace] into a Dart stack trace. | 24 /// Converts [trace] into a Dart stack trace. |
27 StackTrace mapStackTrace(StackTrace trace) => | 25 StackTrace mapStackTrace(StackTrace trace) => |
28 mapper.mapStackTrace(_mapping, trace, | 26 mapper.mapStackTrace(_mapping, trace, |
29 packageRoot: _packageRoot, sdkRoot: _sdkRoot); | 27 packageRoot: _packageRoot, sdkRoot: _sdkRoot); |
30 } | 28 } |
OLD | NEW |