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

Unified Diff: pkg/stack_trace/lib/src/trace.dart

Issue 75863004: Add a stack chain class to the stack trace package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month 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
« no previous file with comments | « pkg/stack_trace/lib/src/stack_zone_specification.dart ('k') | pkg/stack_trace/lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/stack_trace/lib/src/trace.dart
diff --git a/pkg/stack_trace/lib/src/trace.dart b/pkg/stack_trace/lib/src/trace.dart
index c3db43ecd0eb243f7d092f9ba2de1aaccded502c..88b9275182b64262268c3a2c6ba892ad99754e66 100644
--- a/pkg/stack_trace/lib/src/trace.dart
+++ b/pkg/stack_trace/lib/src/trace.dart
@@ -7,6 +7,7 @@ library trace;
import 'dart:collection';
import 'dart:math' as math;
+import 'chain.dart';
import 'frame.dart';
import 'lazy_trace.dart';
import 'utils.dart';
@@ -92,6 +93,7 @@ class Trace implements StackTrace {
/// a [Trace], it will be returned as-is.
factory Trace.from(StackTrace trace) {
if (trace is Trace) return trace;
+ if (trace is Chain) return trace.toTrace();
return new LazyTrace(() => new Trace.parse(trace.toString()));
}
@@ -172,9 +174,14 @@ class Trace implements StackTrace {
.where((line) => line != '[native code]')
.map((line) => new Frame.parseFirefox(line)));
- /// Parses this package's a string representation of a stack trace.
+ /// Parses this package's string representation of a stack trace.
+ ///
+ /// This also parses string representations of [Chain]s. They parse to the
+ /// same trace that [Chain.toTrace] would return.
Trace.parseFriendly(String trace)
: this(trace.trim().split("\n")
+ // Filter out asynchronous gaps from [Chain]s.
+ .where((line) => !line.startsWith('====='))
.map((line) => new Frame.parseFriendly(line)));
/// Returns a new [Trace] comprised of [frames].
@@ -191,10 +198,13 @@ class Trace implements StackTrace {
/// Returns a terser version of [this].
///
/// This is accomplished by folding together multiple stack frames from the
- /// core library, as in [foldFrames]. Remaining core library frames have their
- /// libraries, "-patch" suffixes, and line numbers removed.
+ /// 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) => frame.isCore).frames.map((frame) {
+ 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);
« no previous file with comments | « pkg/stack_trace/lib/src/stack_zone_specification.dart ('k') | pkg/stack_trace/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698