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 import 'package:package_resolver/package_resolver.dart'; | 5 import 'package:package_resolver/package_resolver.dart'; |
6 import 'package:path/path.dart' as p; | 6 import 'package:path/path.dart' as p; |
7 import 'package:source_maps/source_maps.dart'; | 7 import 'package:source_maps/source_maps.dart'; |
8 import 'package:stack_trace/stack_trace.dart'; | 8 import 'package:stack_trace/stack_trace.dart'; |
9 | 9 |
10 /// Convert [stackTrace], a stack trace generated by dart2js-compiled | 10 /// Convert [stackTrace], a stack trace generated by dart2js-compiled |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (span == null) return null; | 69 if (span == null) return null; |
70 | 70 |
71 var sourceUrl = span.sourceUrl.toString(); | 71 var sourceUrl = span.sourceUrl.toString(); |
72 if (sdkRoot != null && p.url.isWithin(sdkLib, sourceUrl)) { | 72 if (sdkRoot != null && p.url.isWithin(sdkLib, sourceUrl)) { |
73 sourceUrl = "dart:" + p.url.relative(sourceUrl, from: sdkLib); | 73 sourceUrl = "dart:" + p.url.relative(sourceUrl, from: sdkLib); |
74 } else if (packageResolver != null) { | 74 } else if (packageResolver != null) { |
75 if (packageResolver.packageRoot != null && | 75 if (packageResolver.packageRoot != null && |
76 p.url.isWithin(packageResolver.packageRoot.toString(), sourceUrl)) { | 76 p.url.isWithin(packageResolver.packageRoot.toString(), sourceUrl)) { |
77 sourceUrl = "package:" + p.url.relative(sourceUrl, | 77 sourceUrl = "package:" + p.url.relative(sourceUrl, |
78 from: packageResolver.packageRoot.toString()); | 78 from: packageResolver.packageRoot.toString()); |
79 } else { | 79 } else if (packageResolver.packageConfig != null) { |
80 for (var package in packageResolver.packageConfigMap.keys) { | 80 for (var package in packageResolver.packageConfigMap.keys) { |
81 var packageUrl = packageResolver.packageConfigMap[package].toString(); | 81 var packageUrl = packageResolver.packageConfigMap[package].toString(); |
82 if (!p.url.isWithin(packageUrl, sourceUrl)) continue; | 82 if (!p.url.isWithin(packageUrl, sourceUrl)) continue; |
83 | 83 |
84 sourceUrl = "package:$package/" + | 84 sourceUrl = "package:$package/" + |
85 p.url.relative(sourceUrl, from: packageUrl); | 85 p.url.relative(sourceUrl, from: packageUrl); |
86 break; | 86 break; |
87 } | 87 } |
88 } | 88 } |
89 } | 89 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "") | 121 .replaceAll(new RegExp(r"[a-zA-Z_0-9]+\$"), "") |
122 // Get rid of the static method prefix. The class name also exists in the | 122 // Get rid of the static method prefix. The class name also exists in the |
123 // invocation, so we're not getting rid of any information. | 123 // invocation, so we're not getting rid of any information. |
124 .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "") | 124 .replaceAll(new RegExp(r"^[a-zA-Z_0-9]+.(static|dart)."), "") |
125 // Convert underscores after identifiers to dots. This runs the risk of | 125 // Convert underscores after identifiers to dots. This runs the risk of |
126 // incorrectly converting members that contain underscores, but those are | 126 // incorrectly converting members that contain underscores, but those are |
127 // contrary to the style guide anyway. | 127 // contrary to the style guide anyway. |
128 .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"), | 128 .replaceAllMapped(new RegExp(r"([a-zA-Z0-9]+)_"), |
129 (match) => match[1] + "."); | 129 (match) => match[1] + "."); |
130 } | 130 } |
OLD | NEW |