| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart._debugger; | 5 library dart._debugger; |
| 6 | 6 |
| 7 import 'dart:_foreign_helper' show JS; | 7 import 'dart:_foreign_helper' show JS; |
| 8 import 'dart:_runtime' as dart; | 8 import 'dart:_runtime' as dart; |
| 9 import 'dart:core'; | 9 import 'dart:core'; |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 if (c == null) return null; | 305 if (c == null) return null; |
| 306 | 306 |
| 307 if (config == JsonMLConfig.keyToString) { | 307 if (config == JsonMLConfig.keyToString) { |
| 308 c = object.toString(); | 308 c = object.toString(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 // Indicate this is a Dart Object by using a Dart background color. | 311 // Indicate this is a Dart Object by using a Dart background color. |
| 312 // This is stylistically a bit ugly but it eases distinguishing Dart and | 312 // This is stylistically a bit ugly but it eases distinguishing Dart and |
| 313 // JS objects. | 313 // JS objects. |
| 314 var element = new JsonMLElement('span') | 314 var element = new JsonMLElement('span') |
| 315 ..setStyle('background-color: #d9edf7') | 315 ..setStyle('background-color: #d9edf7;') |
| 316 ..createTextChild(c); | 316 ..createTextChild(c); |
| 317 return element.toJsonML(); | 317 return element.toJsonML(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 bool hasBody(object) => _simpleFormatter.hasChildren(object); | 320 bool hasBody(object) => _simpleFormatter.hasChildren(object); |
| 321 | 321 |
| 322 body(object) { | 322 body(object) { |
| 323 var body = new JsonMLElement('ol') | 323 var body = new JsonMLElement('ol') |
| 324 ..setStyle('list-style-type: none;' | 324 ..setStyle('list-style-type: none;' |
| 325 'padding-left: 0px;' | 325 'padding-left: 0px;' |
| 326 'margin-top: 0px;' | 326 'margin-top: 0px;' |
| 327 'margin-bottom: 0px;' | 327 'margin-bottom: 0px;' |
| 328 'margin-left: 12px'); | 328 'margin-left: 12px;'); |
| 329 if (object is StackTrace) { |
| 330 body.addStyle('color: rgb(196, 26, 22);'); |
| 331 } |
| 329 var children = _simpleFormatter.children(object); | 332 var children = _simpleFormatter.children(object); |
| 330 for (NameValuePair child in children) { | 333 for (NameValuePair child in children) { |
| 331 var li = body.createChild('li'); | 334 var li = body.createChild('li'); |
| 332 var nameSpan = new JsonMLElement('span') | 335 var nameSpan = new JsonMLElement('span') |
| 333 ..createTextChild( | 336 ..createTextChild( |
| 334 child.displayName.isNotEmpty ? '${child.displayName}: ' : '') | 337 child.displayName.isNotEmpty ? '${child.displayName}: ' : '') |
| 335 ..setStyle('color: rgb(136, 19, 145);'); | 338 ..setStyle('color: rgb(136, 19, 145);'); |
| 336 if (_typeof(child.value) == 'object' || | 339 if (_typeof(child.value) == 'object' || |
| 337 _typeof(child.value) == 'function') { | 340 _typeof(child.value) == 'function') { |
| 338 nameSpan.addStyle("padding-left: 13px;"); | 341 nameSpan.addStyle("padding-left: 13px;"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 367 DartFormatter() { | 370 DartFormatter() { |
| 368 // The order of formatters matters as formatters earlier in the list take | 371 // The order of formatters matters as formatters earlier in the list take |
| 369 // precedence. | 372 // precedence. |
| 370 _formatters = [ | 373 _formatters = [ |
| 371 new NamedConstructorFormatter(), | 374 new NamedConstructorFormatter(), |
| 372 new FunctionFormatter(), | 375 new FunctionFormatter(), |
| 373 new MapFormatter(), | 376 new MapFormatter(), |
| 374 new IterableFormatter(), | 377 new IterableFormatter(), |
| 375 new MapEntryFormatter(), | 378 new MapEntryFormatter(), |
| 376 new IterableSpanFormatter(), | 379 new IterableSpanFormatter(), |
| 380 new StackTraceFormatter(), |
| 377 new ClassMetadataFormatter(), | 381 new ClassMetadataFormatter(), |
| 378 new HeritageClauseFormatter(), | 382 new HeritageClauseFormatter(), |
| 379 new LibraryModuleFormatter(), | 383 new LibraryModuleFormatter(), |
| 380 new LibraryFormatter(), | 384 new LibraryFormatter(), |
| 381 new ObjectFormatter(), | 385 new ObjectFormatter(), |
| 382 ]; | 386 ]; |
| 383 } | 387 } |
| 384 | 388 |
| 385 String preview(object) { | 389 String preview(object) { |
| 386 try { | 390 try { |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 | 832 |
| 829 String preview(object) { | 833 String preview(object) { |
| 830 return '[${object.start}...${object.end-1}]'; | 834 return '[${object.start}...${object.end-1}]'; |
| 831 } | 835 } |
| 832 | 836 |
| 833 bool hasChildren(object) => true; | 837 bool hasChildren(object) => true; |
| 834 | 838 |
| 835 List<NameValuePair> children(object) => object.children(); | 839 List<NameValuePair> children(object) => object.children(); |
| 836 } | 840 } |
| 837 | 841 |
| 842 class StackTraceFormatter implements Formatter { |
| 843 accept(object) => object is StackTrace; |
| 844 |
| 845 String preview(object) => 'StackTrace'; |
| 846 |
| 847 bool hasChildren(object) => true; |
| 848 |
| 849 // Using the stack_trace formatting would be ideal, but adding the |
| 850 // dependency or re-writing the code is too messy, so each line of the |
| 851 // StackTrace will be added as its own child. |
| 852 List<NameValuePair> children(object) => object |
| 853 .toString() |
| 854 .split('\n') |
| 855 .map((line) => new NameValuePair( |
| 856 value: line.replaceFirst(new RegExp(r'^\s+at\s'), ''), |
| 857 hideName: true)) |
| 858 .toList(); |
| 859 } |
| 860 |
| 838 /// This entry point is automatically invoked by the code generated by | 861 /// This entry point is automatically invoked by the code generated by |
| 839 /// Dart Dev Compiler | 862 /// Dart Dev Compiler |
| 840 registerDevtoolsFormatter() { | 863 registerDevtoolsFormatter() { |
| 841 var formatters = [_devtoolsFormatter]; | 864 var formatters = [_devtoolsFormatter]; |
| 842 JS('', 'dart.global.devtoolsFormatters = #', formatters); | 865 JS('', 'dart.global.devtoolsFormatters = #', formatters); |
| 843 } | 866 } |
| OLD | NEW |