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

Side by Side Diff: tool/input_sdk/private/debugger.dart

Issue 2176233002: Library children object fix (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Refactoring library children method Created 4 years, 4 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/runtime/dart_sdk.js ('k') | tool/sdk_expected_errors.txt » ('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) 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 547
548 bool hasChildren(object) => true; 548 bool hasChildren(object) => true;
549 549
550 String preview(object) => object.name; 550 String preview(object) => object.name;
551 551
552 List<NameValuePair> children(object) { 552 List<NameValuePair> children(object) {
553 var children = new LinkedHashSet<NameValuePair>(); 553 var children = new LinkedHashSet<NameValuePair>();
554 var entry = object.object; 554 var entry = object.object;
555 for (var name in getOwnPropertyNames(entry)) { 555 for (var name in getOwnPropertyNames(entry)) {
556 var value = safeGetProperty(entry, name); 556 var value = safeGetProperty(entry, name);
557 if (value != null) { 557 if (value != null) {
Alan Knight 2016/07/25 20:53:00 You could even split this up more/ reduce the leve
bmilligan 2016/07/25 23:28:31 The generic types that get caught in the the first
558 var genericTypeConstructor = dart.getGenericTypeCtor(value); 558 var genericTypeConstructor = dart.getGenericTypeCtor(value);
559 if (genericTypeConstructor != null) { 559 if (genericTypeConstructor != null) {
560 genericName = name; 560 genericClassHandler(name, genericTypeConstructor);
561 // Using JS toString() eliminates the leading metadata that is generat ed
562 // with the toString function provided in operations.dart.
563 // Splitting by => and taking the first element gives the list of
564 // arguments in the constructor.
565 genericArguments =
566 JS('String', '#.toString()', genericTypeConstructor)
567 .split(' =>')
568 .first
569 .replaceAll(new RegExp(r'[(|)]'), '');
570 } else if (value is Type) { 561 } else if (value is Type) {
571 var typeName = getTypeName(value); 562 addClassChild(name, value, children);
Alan Knight 2016/07/25 20:53:00 Good, but maybe for consistency with the clause be
bmilligan 2016/07/25 23:28:31 Done.
572 // Generic class names are generated with a $ at the end, so the
573 // corresponding non-generic class can be identified by adding $.
574 if ('$name\$' == genericName) {
575 typeName = '$typeName<$genericArguments>';
576 }
577 children.add(new NameValuePair(
578 name: typeName, value: new ClassMetadata(value, name: typeName)));
579 } else { 563 } else {
580 children.add( 564 children.add(new NameValuePair(name: name, value: value));
581 new NameValuePair(name: name, value: new ClassMetadata(value)));
582 } 565 }
583 } 566 }
584 } 567 }
585 return children.toList(); 568 return children.toList();
586 } 569 }
570
571 genericClassHandler(String name, Object genericTypeConstructor) {
Alan Knight 2016/07/25 20:53:00 "Handler" is another one of those non-value-adding
bmilligan 2016/07/25 23:28:31 Done.
572 genericName = name;
573 // Using JS toString() eliminates the leading metadata that is generated
574 // with the toString function provided in operations.dart.
575 // Splitting by => and taking the first element gives the list of
576 // arguments in the constructor.
577 genericArguments = JS('String', '#.toString()', genericTypeConstructor)
578 .split(' =>')
579 .first
580 .replaceAll(new RegExp(r'[(|)]'), '');
581 }
582
583 addClassChild(
584 String name, Object child, LinkedHashSet<NameValuePair> children) {
585 var typeName = getTypeName(child);
586 // Generic class names are generated with a $ at the end, so the
587 // corresponding non-generic class can be identified by adding $.
588 if ('$name\$' == genericName) {
589 typeName = '$typeName<$genericArguments>';
590 }
591 children.add(new NameValuePair(
592 name: typeName, value: new ClassMetadata(child, name: typeName)));
593 }
587 } 594 }
588 595
589 /// Formatter for Dart Function objects. 596 /// Formatter for Dart Function objects.
590 /// Dart functions happen to be regular JavaScript Function objects but 597 /// Dart functions happen to be regular JavaScript Function objects but
591 /// we can distinguish them based on whether they have been tagged with 598 /// we can distinguish them based on whether they have been tagged with
592 /// runtime type information. 599 /// runtime type information.
593 class FunctionFormatter extends Formatter { 600 class FunctionFormatter extends Formatter {
594 accept(object) { 601 accept(object) {
595 if (_typeof(object) != 'function') return false; 602 if (_typeof(object) != 'function') return false;
596 return dart.getReifiedType(object) != null; 603 return dart.getReifiedType(object) != null;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 826
820 List<NameValuePair> children(object) => object.children(); 827 List<NameValuePair> children(object) => object.children();
821 } 828 }
822 829
823 /// This entry point is automatically invoked by the code generated by 830 /// This entry point is automatically invoked by the code generated by
824 /// Dart Dev Compiler 831 /// Dart Dev Compiler
825 registerDevtoolsFormatter() { 832 registerDevtoolsFormatter() {
826 var formatters = [_devtoolsFormatter]; 833 var formatters = [_devtoolsFormatter];
827 JS('', 'dart.global.devtoolsFormatters = #', formatters); 834 JS('', 'dart.global.devtoolsFormatters = #', formatters);
828 } 835 }
OLDNEW
« 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