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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/service/object.dart

Issue 359833002: Observatory: Lexicaly sort all kinds of lists (imports, libraries, classes, functions, fields). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of service; 5 part of service;
6 6
7 /// A [ServiceObject] is an object known to the VM service and is tied 7 /// A [ServiceObject] is an object known to the VM service and is tied
8 /// to an owning [Isolate]. 8 /// to an owning [Isolate].
9 abstract class ServiceObject extends Observable { 9 abstract class ServiceObject extends Observable {
10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) {
11 return o1.name.compareTo(o2.name);
12 }
13
14 List unifyByName(List list) {
15 list.sort(LexicalSortName);
16 return list.fold([], (newList, e) {
17 if (!newList.isEmpty && newList.last.name == e.name){
18 return newList;
19 }
20 newList.add(e);
21 return newList;
22 });
23 }
24
10 /// The owner of this [ServiceObject]. This can be an [Isolate], a 25 /// The owner of this [ServiceObject]. This can be an [Isolate], a
11 /// [VM], or null. 26 /// [VM], or null.
12 @reflectable ServiceObjectOwner get owner => _owner; 27 @reflectable ServiceObjectOwner get owner => _owner;
13 ServiceObjectOwner _owner; 28 ServiceObjectOwner _owner;
14 29
15 /// The [VM] which owns this [ServiceObject]. 30 /// The [VM] which owns this [ServiceObject].
16 @reflectable VM get vm => _owner.vm; 31 @reflectable VM get vm => _owner.vm;
17 32
18 /// The [Isolate] which owns this [ServiceObject]. May be null. 33 /// The [Isolate] which owns this [ServiceObject]. May be null.
19 @reflectable Isolate get isolate => _owner.isolate; 34 @reflectable Isolate get isolate => _owner.isolate;
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 } 791 }
777 } 792 }
778 } 793 }
779 // Isolate status 794 // Isolate status
780 pauseEvent = map['pauseEvent']; 795 pauseEvent = map['pauseEvent'];
781 running = (!_isPaused && map['topFrame'] != null); 796 running = (!_isPaused && map['topFrame'] != null);
782 idle = (!_isPaused && map['topFrame'] == null); 797 idle = (!_isPaused && map['topFrame'] == null);
783 error = map['error']; 798 error = map['error'];
784 799
785 libraries.clear(); 800 libraries.clear();
786 for (var lib in map['libraries']) { 801 libraries.addAll(map['libraries']);
787 libraries.add(lib); 802 libraries.sort(ServiceObject.LexicalSortName);
788 }
789 libraries.sort((a,b) => a.name.compareTo(b.name));
790 } 803 }
791 804
792 Future<TagProfile> updateTagProfile() { 805 Future<TagProfile> updateTagProfile() {
793 return vm.getAsMap(relativeLink('profile/tag')).then((ObservableMap m) { 806 return vm.getAsMap(relativeLink('profile/tag')).then((ObservableMap m) {
794 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; 807 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0;
795 tagProfile._processTagProfile(seconds, m); 808 tagProfile._processTagProfile(seconds, m);
796 return tagProfile; 809 return tagProfile;
797 }); 810 });
798 } 811 }
799 812
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 if (name.isEmpty) { 1000 if (name.isEmpty) {
988 name = shortUrl; 1001 name = shortUrl;
989 } 1002 }
990 vmName = map['name']; 1003 vmName = map['name'];
991 if (mapIsRef) { 1004 if (mapIsRef) {
992 return; 1005 return;
993 } 1006 }
994 _loaded = true; 1007 _loaded = true;
995 _upgradeCollection(map, isolate); 1008 _upgradeCollection(map, isolate);
996 imports.clear(); 1009 imports.clear();
997 imports.addAll(map['imports']); 1010 imports.addAll(unifyByName(map['imports']));
Cutch 2014/06/30 23:26:44 Why are there duplicate names?
Michael Lippautz (Google) 2014/06/30 23:42:10 The vm may return duplicates for libraries that al
998 scripts.clear(); 1011 scripts.clear();
999 scripts.addAll(map['scripts']); 1012 scripts.addAll(unifyByName(map['scripts']));
1000 classes.clear(); 1013 classes.clear();
1001 classes.addAll(map['classes']); 1014 classes.addAll(map['classes']);
1015 classes.sort(ServiceObject.LexicalSortName);
1002 variables.clear(); 1016 variables.clear();
1003 variables.addAll(map['variables']); 1017 variables.addAll(map['variables']);
1018 variables.sort(ServiceObject.LexicalSortName);
1004 functions.clear(); 1019 functions.clear();
1005 functions.addAll(map['functions']); 1020 functions.addAll(map['functions']);
1021 functions.sort(ServiceObject.LexicalSortName);
1006 } 1022 }
1007 } 1023 }
1008 1024
1009 class AllocationCount extends Observable { 1025 class AllocationCount extends Observable {
1010 @observable int instances = 0; 1026 @observable int instances = 0;
1011 @observable int bytes = 0; 1027 @observable int bytes = 0;
1012 1028
1013 void reset() { 1029 void reset() {
1014 instances = 0; 1030 instances = 0;
1015 bytes = 0; 1031 bytes = 0;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 isAbstract = map['abstract']; 1119 isAbstract = map['abstract'];
1104 isConst = map['const']; 1120 isConst = map['const'];
1105 isFinalized = map['finalized']; 1121 isFinalized = map['finalized'];
1106 isPatch = map['patch']; 1122 isPatch = map['patch'];
1107 isImplemented = map['implemented']; 1123 isImplemented = map['implemented'];
1108 1124
1109 tokenPos = map['tokenPos']; 1125 tokenPos = map['tokenPos'];
1110 1126
1111 subClasses.clear(); 1127 subClasses.clear();
1112 subClasses.addAll(map['subclasses']); 1128 subClasses.addAll(map['subclasses']);
1129 subClasses.sort(ServiceObject.LexicalSortName);
1113 1130
1114 fields.clear(); 1131 fields.clear();
1115 fields.addAll(map['fields']); 1132 fields.addAll(map['fields']);
1133 fields.sort(ServiceObject.LexicalSortName);
1116 1134
1117 functions.clear(); 1135 functions.clear();
1118 functions.addAll(map['functions']); 1136 functions.addAll(map['functions']);
1137 functions.sort(ServiceObject.LexicalSortName);
1119 1138
1120 superClass = map['super']; 1139 superClass = map['super'];
1121 if (superClass != null) { 1140 if (superClass != null) {
1122 superClass._addToChildren(this); 1141 superClass._addToChildren(this);
1123 } 1142 }
1124 error = map['error']; 1143 error = map['error'];
1125 1144
1126 var allocationStats = map['allocationStats']; 1145 var allocationStats = map['allocationStats'];
1127 if (allocationStats != null) { 1146 if (allocationStats != null) {
1128 newSpace.update(allocationStats['new']); 1147 newSpace.update(allocationStats['new']);
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 var v = list[i]; 1859 var v = list[i];
1841 if ((v is ObservableMap) && _isServiceMap(v)) { 1860 if ((v is ObservableMap) && _isServiceMap(v)) {
1842 list[i] = owner.getFromMap(v); 1861 list[i] = owner.getFromMap(v);
1843 } else if (v is ObservableList) { 1862 } else if (v is ObservableList) {
1844 _upgradeObservableList(v, owner); 1863 _upgradeObservableList(v, owner);
1845 } else if (v is ObservableMap) { 1864 } else if (v is ObservableMap) {
1846 _upgradeObservableMap(v, owner); 1865 _upgradeObservableMap(v, owner);
1847 } 1866 }
1848 } 1867 }
1849 } 1868 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698