Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1295)

Unified Diff: third_party/dart-packages/stack_trace/stack_trace/src/trace.dart

Issue 971083002: Create an apptesting framework for dart. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Update upload_binaries.py to add the apptest.dartzip artifact. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/dart-packages/stack_trace/stack_trace/src/trace.dart
diff --git a/sky/tests/resources/third_party/stack_trace/src/trace.dart b/third_party/dart-packages/stack_trace/stack_trace/src/trace.dart
similarity index 83%
copy from sky/tests/resources/third_party/stack_trace/src/trace.dart
copy to third_party/dart-packages/stack_trace/stack_trace/src/trace.dart
index 2690ece17a2fac811a86413328eb2fd3fd7a1b58..53dbe33e4c2e9c1724e806e364bf9f5ac95fc209 100644
--- a/sky/tests/resources/third_party/stack_trace/src/trace.dart
+++ b/third_party/dart-packages/stack_trace/stack_trace/src/trace.dart
@@ -203,25 +203,43 @@ class Trace implements StackTrace {
/// core library or from this package, as in [foldFrames]. Remaining core
/// library frames have their libraries, "-patch" suffixes, and line numbers
/// removed.
- Trace get terse {
- return new Trace(foldFrames((frame) {
- return frame.isCore || frame.package == 'stack_trace';
- }).frames.map((frame) {
- if (!frame.isCore) return frame;
- var library = frame.library.replaceAll(_terseRegExp, '');
- return new Frame(Uri.parse(library), null, null, frame.member);
- }));
- }
+ ///
+ /// For custom folding, see [foldFrames].
+ Trace get terse => foldFrames((_) => false, terse: true);
/// Returns a new [Trace] based on [this] where multiple stack frames matching
- /// [predicate] are folded together. This means that whenever there are
- /// multiple frames in a row that match [predicate], only the last one is
- /// kept.
+ /// [predicate] are folded together.
+ ///
+ /// This means that whenever there are multiple frames in a row that match
+ /// [predicate], only the last one is kept. This is useful for limiting the
+ /// amount of library code that appears in a stack trace by only showing user
+ /// code and code that's called by user code.
///
- /// This is useful for limiting the amount of library code that appears in a
- /// stack trace by only showing user code and code that's called by user code.
- Trace foldFrames(bool predicate(Frame frame)) {
- var newFrames = <Frame>[];
+ /// If [terse] is true, this will also fold together frames from the core
+ /// library or from this package, and simplify core library frames as in
+ /// [Trace.terse].
+ Trace foldFrames(bool predicate(Frame frame), {bool terse: false}) {
+ if (terse) {
+ var oldPredicate = predicate;
+ predicate = (frame) {
+ if (oldPredicate(frame)) return true;
+
+ if (frame.isCore) return true;
+ if (frame.package == 'stack_trace') return true;
+
+ // Ignore async stack frames without any line or column information.
+ // These come from the VM's async/await implementation and represent
+ // internal frames. They only ever show up in stack chains and are
+ // always surrounded by other traces that are actually useful, so we can
+ // just get rid of them.
+ // TODO(nweiz): Get rid of this logic some time after issue 22009 is
+ // fixed.
+ if (!frame.member.contains('<async>')) return false;
+ return frame.line == null;
+ };
+ }
+
+ var newFrames = [];
for (var frame in frames.reversed) {
if (!predicate(frame)) {
newFrames.add(frame);
@@ -231,6 +249,14 @@ class Trace implements StackTrace {
}
}
+ if (terse) {
+ newFrames = newFrames.map((frame) {
+ if (!frame.isCore) return frame;
+ var library = frame.library.replaceAll(_terseRegExp, '');
+ return new Frame(Uri.parse(library), null, null, frame.member);
+ }).toList();
+ }
+
return new Trace(newFrames.reversed);
}

Powered by Google App Engine
This is Rietveld 408576698