| OLD | NEW |
| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (!predicate(frame)) { | 245 if (!predicate(frame)) { |
| 246 newFrames.add(frame); | 246 newFrames.add(frame); |
| 247 } else if (newFrames.isEmpty || !predicate(newFrames.last)) { | 247 } else if (newFrames.isEmpty || !predicate(newFrames.last)) { |
| 248 newFrames.add(new Frame( | 248 newFrames.add(new Frame( |
| 249 frame.uri, frame.line, frame.column, frame.member)); | 249 frame.uri, frame.line, frame.column, frame.member)); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 if (terse) { | 253 if (terse) { |
| 254 newFrames = newFrames.map((frame) { | 254 newFrames = newFrames.map((frame) { |
| 255 if (!frame.isCore) return frame; | 255 if (!predicate(frame)) return frame; |
| 256 var library = frame.library.replaceAll(_terseRegExp, ''); | 256 var library = frame.library.replaceAll(_terseRegExp, ''); |
| 257 return new Frame(Uri.parse(library), null, null, frame.member); | 257 return new Frame(Uri.parse(library), null, null, frame.member); |
| 258 }).toList(); | 258 }).toList(); |
| 259 if (newFrames.first.isCore && newFrames.length > 1) newFrames.removeAt(0); | 259 if (newFrames.first.isCore && newFrames.length > 1) newFrames.removeAt(0); |
| 260 } | 260 } |
| 261 | 261 |
| 262 return new Trace(newFrames.reversed); | 262 return new Trace(newFrames.reversed); |
| 263 } | 263 } |
| 264 | 264 |
| 265 /// Returns a human-readable string representation of [this]. | 265 /// Returns a human-readable string representation of [this]. |
| 266 String toString() { | 266 String toString() { |
| 267 // Figure out the longest path so we know how much to pad. | 267 // Figure out the longest path so we know how much to pad. |
| 268 var longest = frames.map((frame) => frame.location.length) | 268 var longest = frames.map((frame) => frame.location.length) |
| 269 .fold(0, math.max); | 269 .fold(0, math.max); |
| 270 | 270 |
| 271 // Print out the stack trace nicely formatted. | 271 // Print out the stack trace nicely formatted. |
| 272 return frames.map((frame) { | 272 return frames.map((frame) { |
| 273 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 273 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
| 274 }).join(); | 274 }).join(); |
| 275 } | 275 } |
| 276 } | 276 } |
| OLD | NEW |