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

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 removeDuplicatesAndSortLexical(List<ServiceObject> list) {
15 return list.toSet().toList()..sort(LexicalSortName);
16 }
17
10 /// The owner of this [ServiceObject]. This can be an [Isolate], a 18 /// The owner of this [ServiceObject]. This can be an [Isolate], a
11 /// [VM], or null. 19 /// [VM], or null.
12 @reflectable ServiceObjectOwner get owner => _owner; 20 @reflectable ServiceObjectOwner get owner => _owner;
13 ServiceObjectOwner _owner; 21 ServiceObjectOwner _owner;
14 22
15 /// The [VM] which owns this [ServiceObject]. 23 /// The [VM] which owns this [ServiceObject].
16 @reflectable VM get vm => _owner.vm; 24 @reflectable VM get vm => _owner.vm;
17 25
18 /// The [Isolate] which owns this [ServiceObject]. May be null. 26 /// The [Isolate] which owns this [ServiceObject]. May be null.
19 @reflectable Isolate get isolate => _owner.isolate; 27 @reflectable Isolate get isolate => _owner.isolate;
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 822 }
815 } 823 }
816 } 824 }
817 // Isolate status 825 // Isolate status
818 pauseEvent = map['pauseEvent']; 826 pauseEvent = map['pauseEvent'];
819 running = (!_isPaused && map['topFrame'] != null); 827 running = (!_isPaused && map['topFrame'] != null);
820 idle = (!_isPaused && map['topFrame'] == null); 828 idle = (!_isPaused && map['topFrame'] == null);
821 error = map['error']; 829 error = map['error'];
822 830
823 libraries.clear(); 831 libraries.clear();
824 for (var lib in map['libraries']) { 832 libraries.addAll(map['libraries']);
825 libraries.add(lib); 833 libraries.sort(ServiceObject.LexicalSortName);
826 }
827 libraries.sort((a,b) => a.name.compareTo(b.name));
828 } 834 }
829 835
830 Future<TagProfile> updateTagProfile() { 836 Future<TagProfile> updateTagProfile() {
831 return vm.getAsMap(relativeLink('profile/tag')).then((ObservableMap m) { 837 return vm.getAsMap(relativeLink('profile/tag')).then((ObservableMap m) {
832 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; 838 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0;
833 tagProfile._processTagProfile(seconds, m); 839 tagProfile._processTagProfile(seconds, m);
834 return tagProfile; 840 return tagProfile;
835 }); 841 });
836 } 842 }
837 843
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 if (name.isEmpty) { 1054 if (name.isEmpty) {
1049 name = shortUrl; 1055 name = shortUrl;
1050 } 1056 }
1051 vmName = map['name']; 1057 vmName = map['name'];
1052 if (mapIsRef) { 1058 if (mapIsRef) {
1053 return; 1059 return;
1054 } 1060 }
1055 _loaded = true; 1061 _loaded = true;
1056 _upgradeCollection(map, isolate); 1062 _upgradeCollection(map, isolate);
1057 imports.clear(); 1063 imports.clear();
1058 imports.addAll(map['imports']); 1064 imports.addAll(removeDuplicatesAndSortLexical(map['imports']));
1059 scripts.clear(); 1065 scripts.clear();
1060 scripts.addAll(map['scripts']); 1066 scripts.addAll(removeDuplicatesAndSortLexical(map['scripts']));
1061 classes.clear(); 1067 classes.clear();
1062 classes.addAll(map['classes']); 1068 classes.addAll(map['classes']);
1069 classes.sort(ServiceObject.LexicalSortName);
1063 variables.clear(); 1070 variables.clear();
1064 variables.addAll(map['variables']); 1071 variables.addAll(map['variables']);
1072 variables.sort(ServiceObject.LexicalSortName);
1065 functions.clear(); 1073 functions.clear();
1066 functions.addAll(map['functions']); 1074 functions.addAll(map['functions']);
1075 functions.sort(ServiceObject.LexicalSortName);
1067 } 1076 }
1068 } 1077 }
1069 1078
1070 class AllocationCount extends Observable { 1079 class AllocationCount extends Observable {
1071 @observable int instances = 0; 1080 @observable int instances = 0;
1072 @observable int bytes = 0; 1081 @observable int bytes = 0;
1073 1082
1074 void reset() { 1083 void reset() {
1075 instances = 0; 1084 instances = 0;
1076 bytes = 0; 1085 bytes = 0;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 isAbstract = map['abstract']; 1173 isAbstract = map['abstract'];
1165 isConst = map['const']; 1174 isConst = map['const'];
1166 isFinalized = map['finalized']; 1175 isFinalized = map['finalized'];
1167 isPatch = map['patch']; 1176 isPatch = map['patch'];
1168 isImplemented = map['implemented']; 1177 isImplemented = map['implemented'];
1169 1178
1170 tokenPos = map['tokenPos']; 1179 tokenPos = map['tokenPos'];
1171 1180
1172 subClasses.clear(); 1181 subClasses.clear();
1173 subClasses.addAll(map['subclasses']); 1182 subClasses.addAll(map['subclasses']);
1183 subClasses.sort(ServiceObject.LexicalSortName);
1174 1184
1175 fields.clear(); 1185 fields.clear();
1176 fields.addAll(map['fields']); 1186 fields.addAll(map['fields']);
1187 fields.sort(ServiceObject.LexicalSortName);
1177 1188
1178 functions.clear(); 1189 functions.clear();
1179 functions.addAll(map['functions']); 1190 functions.addAll(map['functions']);
1191 functions.sort(ServiceObject.LexicalSortName);
1180 1192
1181 superClass = map['super']; 1193 superClass = map['super'];
1182 if (superClass != null) { 1194 if (superClass != null) {
1183 superClass._addToChildren(this); 1195 superClass._addToChildren(this);
1184 } 1196 }
1185 error = map['error']; 1197 error = map['error'];
1186 1198
1187 var allocationStats = map['allocationStats']; 1199 var allocationStats = map['allocationStats'];
1188 if (allocationStats != null) { 1200 if (allocationStats != null) {
1189 newSpace.update(allocationStats['new']); 1201 newSpace.update(allocationStats['new']);
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 var v = list[i]; 1914 var v = list[i];
1903 if ((v is ObservableMap) && _isServiceMap(v)) { 1915 if ((v is ObservableMap) && _isServiceMap(v)) {
1904 list[i] = owner.getFromMap(v); 1916 list[i] = owner.getFromMap(v);
1905 } else if (v is ObservableList) { 1917 } else if (v is ObservableList) {
1906 _upgradeObservableList(v, owner); 1918 _upgradeObservableList(v, owner);
1907 } else if (v is ObservableMap) { 1919 } else if (v is ObservableMap) {
1908 _upgradeObservableMap(v, owner); 1920 _upgradeObservableMap(v, owner);
1909 } 1921 }
1910 } 1922 }
1911 } 1923 }
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