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

Unified Diff: tool/input_sdk/private/debugger.dart

Issue 2189673002: StackTrace formatters (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: StackTrace lines as individual children Created 4 years, 5 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
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/debugger.dart
diff --git a/tool/input_sdk/private/debugger.dart b/tool/input_sdk/private/debugger.dart
index 0f470d9d1e2905d32b76e9ae5321459f4c9ff229..8e1d912b1b2f0c4e890c61f4f44eb05f9e1959c7 100644
--- a/tool/input_sdk/private/debugger.dart
+++ b/tool/input_sdk/private/debugger.dart
@@ -312,7 +312,7 @@ class JsonMLFormatter {
// This is stylistically a bit ugly but it eases distinguishing Dart and
// JS objects.
var element = new JsonMLElement('span')
- ..setStyle('background-color: #d9edf7')
+ ..setStyle('background-color: #d9edf7;')
..createTextChild(c);
return element.toJsonML();
}
@@ -325,7 +325,10 @@ class JsonMLFormatter {
'padding-left: 0px;'
'margin-top: 0px;'
'margin-bottom: 0px;'
- 'margin-left: 12px');
+ 'margin-left: 12px;');
+ if (object is StackTrace) {
+ body.addStyle('color: rgb(196, 26, 22);');
+ }
var children = _simpleFormatter.children(object);
for (NameValuePair child in children) {
var li = body.createChild('li');
@@ -374,6 +377,7 @@ class DartFormatter {
new IterableFormatter(),
new MapEntryFormatter(),
new IterableSpanFormatter(),
+ new StackTraceFormatter(),
new ClassMetadataFormatter(),
new HeritageClauseFormatter(),
new LibraryModuleFormatter(),
@@ -835,6 +839,25 @@ class IterableSpanFormatter implements Formatter {
List<NameValuePair> children(object) => object.children();
}
+class StackTraceFormatter implements Formatter {
+ accept(object) => object is StackTrace;
+
+ String preview(object) => 'StackTrace';
+
+ bool hasChildren(object) => true;
+
+ List<NameValuePair> children(object) {
+ // Using the stack_trace formatting would be ideal, but adding the
+ // dependency or re-writing the code is too messy, so each line of the
+ // StackTrace will be added as its own child.
+ var children = <NameValuePair>[];
+ for (var line in object.toString().replaceAll('at ', '').split('\n')) {
bmilligan 2016/07/27 21:39:23 Is there a better way to do this than iterating th
Jacob 2016/07/27 21:42:37 It is safer to first split by \n then replace repl
Alan Knight 2016/07/27 21:43:36 I think you're looking for iterable.map
bmilligan 2016/07/27 22:08:39 Done.
bmilligan 2016/07/27 22:08:40 Done.
+ children.add(new NameValuePair(value: line, hideName: true));
+ }
+ return children;
+ }
+}
+
/// This entry point is automatically invoked by the code generated by
/// Dart Dev Compiler
registerDevtoolsFormatter() {
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698