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

Side by Side Diff: lib/src/trace.dart

Issue 1171873002: Support parsing empty stack chains. (Closed) Base URL: git@github.com:dart-lang/stack_trace@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/src/chain.dart ('k') | test/chain_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 trace; 5 library trace;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'chain.dart'; 10 import 'chain.dart';
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 Trace.parseSafari6_0(String trace) 181 Trace.parseSafari6_0(String trace)
182 : this(trace.trim().split("\n") 182 : this(trace.trim().split("\n")
183 .where((line) => line != '[native code]') 183 .where((line) => line != '[native code]')
184 .map((line) => new Frame.parseFirefox(line))); 184 .map((line) => new Frame.parseFirefox(line)));
185 185
186 /// Parses this package's string representation of a stack trace. 186 /// Parses this package's string representation of a stack trace.
187 /// 187 ///
188 /// This also parses string representations of [Chain]s. They parse to the 188 /// This also parses string representations of [Chain]s. They parse to the
189 /// same trace that [Chain.toTrace] would return. 189 /// same trace that [Chain.toTrace] would return.
190 Trace.parseFriendly(String trace) 190 Trace.parseFriendly(String trace)
191 : this(trace.trim().split("\n") 191 : this(trace.isEmpty
192 // Filter out asynchronous gaps from [Chain]s. 192 ? []
193 .where((line) => !line.startsWith('=====')) 193 : trace.trim().split("\n")
194 .map((line) => new Frame.parseFriendly(line))); 194 // Filter out asynchronous gaps from [Chain]s.
195 .where((line) => !line.startsWith('====='))
196 .map((line) => new Frame.parseFriendly(line)));
195 197
196 /// Returns a new [Trace] comprised of [frames]. 198 /// Returns a new [Trace] comprised of [frames].
197 Trace(Iterable<Frame> frames) 199 Trace(Iterable<Frame> frames)
198 : frames = new UnmodifiableListView<Frame>(frames.toList()); 200 : frames = new UnmodifiableListView<Frame>(frames.toList());
199 201
200 /// Returns a VM-style [StackTrace] object. 202 /// Returns a VM-style [StackTrace] object.
201 /// 203 ///
202 /// The return value's [toString] method will always return a string 204 /// The return value's [toString] method will always return a string
203 /// representation in the Dart VM's stack trace format, regardless of what 205 /// representation in the Dart VM's stack trace format, regardless of what
204 /// platform is being used. 206 /// platform is being used.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // Figure out the longest path so we know how much to pad. 276 // Figure out the longest path so we know how much to pad.
275 var longest = frames.map((frame) => frame.location.length) 277 var longest = frames.map((frame) => frame.location.length)
276 .fold(0, math.max); 278 .fold(0, math.max);
277 279
278 // Print out the stack trace nicely formatted. 280 // Print out the stack trace nicely formatted.
279 return frames.map((frame) { 281 return frames.map((frame) {
280 return '${padRight(frame.location, longest)} ${frame.member}\n'; 282 return '${padRight(frame.location, longest)} ${frame.member}\n';
281 }).join(); 283 }).join();
282 } 284 }
283 } 285 }
OLDNEW
« no previous file with comments | « lib/src/chain.dart ('k') | test/chain_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698