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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 1160943002: Give structured information about imports and export in the service's library response. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add test Created 5 years, 6 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
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 /// An RpcException represents an exceptional event that happened 7 /// An RpcException represents an exceptional event that happened
8 /// while invoking an rpc. 8 /// while invoking an rpc.
9 abstract class RpcException implements Exception { 9 abstract class RpcException implements Exception {
10 RpcException(this.message); 10 RpcException(this.message);
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 1578
1579 String toString() { 1579 String toString() {
1580 if (number != null) { 1580 if (number != null) {
1581 return 'Breakpoint ${number} at ${script.name}(token:${tokenPos})'; 1581 return 'Breakpoint ${number} at ${script.name}(token:${tokenPos})';
1582 } else { 1582 } else {
1583 return 'Uninitialized breakpoint'; 1583 return 'Uninitialized breakpoint';
1584 } 1584 }
1585 } 1585 }
1586 } 1586 }
1587 1587
1588
1589 class LibraryDependency {
1590 @reflectable final bool isImport;
1591 @reflectable final bool isDeferred;
1592 @reflectable final String prefix;
1593 @reflectable final Library target;
1594
1595 bool get isExport => !isImport;
1596
1597 LibraryDependency._(this.isImport, this.isDeferred, this.prefix, this.target);
1598
1599 static _fromMap(map) => new LibraryDependency._(map["isImport"],
1600 map["isDeferred"],
1601 map["prefix"],
1602 map["target"]);
1603 }
1604
1605
1588 class Library extends ServiceObject with Coverage { 1606 class Library extends ServiceObject with Coverage {
1589 @observable String uri; 1607 @observable String uri;
1590 @reflectable final imports = new ObservableList<Library>(); 1608 @reflectable final dependencies = new ObservableList<LibraryDependency>();
1591 @reflectable final scripts = new ObservableList<Script>(); 1609 @reflectable final scripts = new ObservableList<Script>();
1592 @reflectable final classes = new ObservableList<Class>(); 1610 @reflectable final classes = new ObservableList<Class>();
1593 @reflectable final variables = new ObservableList<Field>(); 1611 @reflectable final variables = new ObservableList<Field>();
1594 @reflectable final functions = new ObservableList<ServiceFunction>(); 1612 @reflectable final functions = new ObservableList<ServiceFunction>();
1595 1613
1596 bool get canCache => true; 1614 bool get canCache => true;
1597 bool get immutable => false; 1615 bool get immutable => false;
1598 1616
1599 Library._empty(ServiceObjectOwner owner) : super._empty(owner); 1617 Library._empty(ServiceObjectOwner owner) : super._empty(owner);
1600 1618
1601 void _update(ObservableMap map, bool mapIsRef) { 1619 void _update(ObservableMap map, bool mapIsRef) {
1602 uri = map['uri']; 1620 uri = map['uri'];
1603 var shortUri = uri; 1621 var shortUri = uri;
1604 if (uri.startsWith('file://') || 1622 if (uri.startsWith('file://') ||
1605 uri.startsWith('http://')) { 1623 uri.startsWith('http://')) {
1606 shortUri = uri.substring(uri.lastIndexOf('/') + 1); 1624 shortUri = uri.substring(uri.lastIndexOf('/') + 1);
1607 } 1625 }
1608 name = map['name']; 1626 name = map['name'];
1609 if (name.isEmpty) { 1627 if (name.isEmpty) {
1610 // When there is no name for a library, use the shortUri. 1628 // When there is no name for a library, use the shortUri.
1611 name = shortUri; 1629 name = shortUri;
1612 } 1630 }
1613 vmName = (map.containsKey('vmName') ? map['vmName'] : name); 1631 vmName = (map.containsKey('vmName') ? map['vmName'] : name);
1614 if (mapIsRef) { 1632 if (mapIsRef) {
1615 return; 1633 return;
1616 } 1634 }
1617 _loaded = true; 1635 _loaded = true;
1618 _upgradeCollection(map, isolate); 1636 _upgradeCollection(map, isolate);
1619 imports.clear(); 1637 dependencies.clear();
1620 imports.addAll(removeDuplicatesAndSortLexical(map['imports'])); 1638 dependencies.addAll(map["dependencies"].map(LibraryDependency._fromMap));
1621 scripts.clear(); 1639 scripts.clear();
1622 scripts.addAll(removeDuplicatesAndSortLexical(map['scripts'])); 1640 scripts.addAll(removeDuplicatesAndSortLexical(map['scripts']));
1623 classes.clear(); 1641 classes.clear();
1624 classes.addAll(map['classes']); 1642 classes.addAll(map['classes']);
1625 classes.sort(ServiceObject.LexicalSortName); 1643 classes.sort(ServiceObject.LexicalSortName);
1626 variables.clear(); 1644 variables.clear();
1627 variables.addAll(map['variables']); 1645 variables.addAll(map['variables']);
1628 variables.sort(ServiceObject.LexicalSortName); 1646 variables.sort(ServiceObject.LexicalSortName);
1629 functions.clear(); 1647 functions.clear();
1630 functions.addAll(map['functions']); 1648 functions.addAll(map['functions']);
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 var v = list[i]; 3175 var v = list[i];
3158 if ((v is ObservableMap) && _isServiceMap(v)) { 3176 if ((v is ObservableMap) && _isServiceMap(v)) {
3159 list[i] = owner.getFromMap(v); 3177 list[i] = owner.getFromMap(v);
3160 } else if (v is ObservableList) { 3178 } else if (v is ObservableList) {
3161 _upgradeObservableList(v, owner); 3179 _upgradeObservableList(v, owner);
3162 } else if (v is ObservableMap) { 3180 } else if (v is ObservableMap) {
3163 _upgradeObservableMap(v, owner); 3181 _upgradeObservableMap(v, owner);
3164 } 3182 }
3165 } 3183 }
3166 } 3184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698