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

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

Issue 1154163004: Libraries have uris not urls. Scripts have uris not names. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync 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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 String toString() { 1576 String toString() {
1577 if (number != null) { 1577 if (number != null) {
1578 return 'Breakpoint ${number} at ${script.name}(token:${tokenPos})'; 1578 return 'Breakpoint ${number} at ${script.name}(token:${tokenPos})';
1579 } else { 1579 } else {
1580 return 'Uninitialized breakpoint'; 1580 return 'Uninitialized breakpoint';
1581 } 1581 }
1582 } 1582 }
1583 } 1583 }
1584 1584
1585 class Library extends ServiceObject with Coverage { 1585 class Library extends ServiceObject with Coverage {
1586 @observable String url; 1586 @observable String uri;
1587 @reflectable final imports = new ObservableList<Library>(); 1587 @reflectable final imports = new ObservableList<Library>();
1588 @reflectable final scripts = new ObservableList<Script>(); 1588 @reflectable final scripts = new ObservableList<Script>();
1589 @reflectable final classes = new ObservableList<Class>(); 1589 @reflectable final classes = new ObservableList<Class>();
1590 @reflectable final variables = new ObservableList<Field>(); 1590 @reflectable final variables = new ObservableList<Field>();
1591 @reflectable final functions = new ObservableList<ServiceFunction>(); 1591 @reflectable final functions = new ObservableList<ServiceFunction>();
1592 1592
1593 bool get canCache => true; 1593 bool get canCache => true;
1594 bool get immutable => false; 1594 bool get immutable => false;
1595 1595
1596 Library._empty(ServiceObjectOwner owner) : super._empty(owner); 1596 Library._empty(ServiceObjectOwner owner) : super._empty(owner);
1597 1597
1598 void _update(ObservableMap map, bool mapIsRef) { 1598 void _update(ObservableMap map, bool mapIsRef) {
1599 url = map['url']; 1599 uri = map['uri'];
1600 var shortUrl = url; 1600 var shortUri = uri;
1601 if (url.startsWith('file://') || 1601 if (uri.startsWith('file://') ||
1602 url.startsWith('http://')) { 1602 uri.startsWith('http://')) {
1603 shortUrl = url.substring(url.lastIndexOf('/') + 1); 1603 shortUri = uri.substring(uri.lastIndexOf('/') + 1);
1604 } 1604 }
1605 name = map['name']; 1605 name = map['name'];
1606 if (name.isEmpty) { 1606 if (name.isEmpty) {
1607 // When there is no name for a library, use the shortUrl. 1607 // When there is no name for a library, use the shortUri.
1608 name = shortUrl; 1608 name = shortUri;
1609 } 1609 }
1610 vmName = (map.containsKey('vmName') ? map['vmName'] : name); 1610 vmName = (map.containsKey('vmName') ? map['vmName'] : name);
1611 if (mapIsRef) { 1611 if (mapIsRef) {
1612 return; 1612 return;
1613 } 1613 }
1614 _loaded = true; 1614 _loaded = true;
1615 _upgradeCollection(map, isolate); 1615 _upgradeCollection(map, isolate);
1616 imports.clear(); 1616 imports.clear();
1617 imports.addAll(removeDuplicatesAndSortLexical(map['imports'])); 1617 imports.addAll(removeDuplicatesAndSortLexical(map['imports']));
1618 scripts.clear(); 1618 scripts.clear();
1619 scripts.addAll(removeDuplicatesAndSortLexical(map['scripts'])); 1619 scripts.addAll(removeDuplicatesAndSortLexical(map['scripts']));
1620 classes.clear(); 1620 classes.clear();
1621 classes.addAll(map['classes']); 1621 classes.addAll(map['classes']);
1622 classes.sort(ServiceObject.LexicalSortName); 1622 classes.sort(ServiceObject.LexicalSortName);
1623 variables.clear(); 1623 variables.clear();
1624 variables.addAll(map['variables']); 1624 variables.addAll(map['variables']);
1625 variables.sort(ServiceObject.LexicalSortName); 1625 variables.sort(ServiceObject.LexicalSortName);
1626 functions.clear(); 1626 functions.clear();
1627 functions.addAll(map['functions']); 1627 functions.addAll(map['functions']);
1628 functions.sort(ServiceObject.LexicalSortName); 1628 functions.sort(ServiceObject.LexicalSortName);
1629 } 1629 }
1630 1630
1631 Future<ServiceObject> evaluate(String expression) { 1631 Future<ServiceObject> evaluate(String expression) {
1632 return isolate._eval(this, expression); 1632 return isolate._eval(this, expression);
1633 } 1633 }
1634 1634
1635 String toString() => "Library($url)"; 1635 String toString() => "Library($uri)";
1636 } 1636 }
1637 1637
1638 class AllocationCount extends Observable { 1638 class AllocationCount extends Observable {
1639 @observable int instances = 0; 1639 @observable int instances = 0;
1640 @observable int bytes = 0; 1640 @observable int bytes = 0;
1641 1641
1642 void reset() { 1642 void reset() {
1643 instances = 0; 1643 instances = 0;
1644 bytes = 0; 1644 bytes = 0;
1645 } 1645 }
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 final int line; 2210 final int line;
2211 final int column; 2211 final int column;
2212 final int endColumn; 2212 final int endColumn;
2213 LocalVarLocation(this.line, this.column, this.endColumn); 2213 LocalVarLocation(this.line, this.column, this.endColumn);
2214 } 2214 }
2215 2215
2216 class Script extends ServiceObject with Coverage { 2216 class Script extends ServiceObject with Coverage {
2217 Set<CallSite> callSites = new Set<CallSite>(); 2217 Set<CallSite> callSites = new Set<CallSite>();
2218 final lines = new ObservableList<ScriptLine>(); 2218 final lines = new ObservableList<ScriptLine>();
2219 final _hits = new Map<int, int>(); 2219 final _hits = new Map<int, int>();
2220 @observable String uri;
2220 @observable String kind; 2221 @observable String kind;
2221 @observable int firstTokenPos; 2222 @observable int firstTokenPos;
2222 @observable int lastTokenPos; 2223 @observable int lastTokenPos;
2223 @observable int lineOffset; 2224 @observable int lineOffset;
2224 @observable int columnOffset; 2225 @observable int columnOffset;
2225 @observable Library library; 2226 @observable Library library;
2226 bool get canCache => true; 2227 bool get canCache => true;
2227 bool get immutable => true; 2228 bool get immutable => true;
2228 2229
2229 String _shortUrl; 2230 String _shortUri;
2230 String _url;
2231 2231
2232 Script._empty(ServiceObjectOwner owner) : super._empty(owner); 2232 Script._empty(ServiceObjectOwner owner) : super._empty(owner);
2233 2233
2234 ScriptLine getLine(int line) { 2234 ScriptLine getLine(int line) {
2235 assert(_loaded); 2235 assert(_loaded);
2236 assert(line >= 1); 2236 assert(line >= 1);
2237 return lines[line - lineOffset - 1]; 2237 return lines[line - lineOffset - 1];
2238 } 2238 }
2239 2239
2240 /// This function maps a token position to a line number. 2240 /// This function maps a token position to a line number.
2241 int tokenToLine(int token) => _tokenToLine[token]; 2241 int tokenToLine(int token) => _tokenToLine[token];
2242 Map _tokenToLine = {}; 2242 Map _tokenToLine = {};
2243 2243
2244 /// This function maps a token position to a column number. 2244 /// This function maps a token position to a column number.
2245 int tokenToCol(int token) => _tokenToCol[token]; 2245 int tokenToCol(int token) => _tokenToCol[token];
2246 Map _tokenToCol = {}; 2246 Map _tokenToCol = {};
2247 2247
2248 void _update(ObservableMap map, bool mapIsRef) { 2248 void _update(ObservableMap map, bool mapIsRef) {
2249 _upgradeCollection(map, isolate); 2249 _upgradeCollection(map, isolate);
2250 uri = map['uri'];
2250 kind = map['kind']; 2251 kind = map['kind'];
2251 _url = map['name']; 2252 _shortUri = uri.substring(uri.lastIndexOf('/') + 1);
2252 _shortUrl = _url.substring(_url.lastIndexOf('/') + 1); 2253 name = _shortUri;
2253 name = _shortUrl; 2254 vmName = uri;
2254 vmName = _url;
2255 if (mapIsRef) { 2255 if (mapIsRef) {
2256 return; 2256 return;
2257 } 2257 }
2258 _loaded = true; 2258 _loaded = true;
2259 lineOffset = map['lineOffset']; 2259 lineOffset = map['lineOffset'];
2260 columnOffset = map['columnOffset']; 2260 columnOffset = map['columnOffset'];
2261 _parseTokenPosTable(map['tokenPosTable']); 2261 _parseTokenPosTable(map['tokenPosTable']);
2262 _processSource(map['source']); 2262 _processSource(map['source']);
2263 library = map['library']; 2263 library = map['library'];
2264 } 2264 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 2330
2331 void _processSource(String source) { 2331 void _processSource(String source) {
2332 if (source == null) { 2332 if (source == null) {
2333 return; 2333 return;
2334 } 2334 }
2335 var sourceLines = source.split('\n'); 2335 var sourceLines = source.split('\n');
2336 if (sourceLines.length == 0) { 2336 if (sourceLines.length == 0) {
2337 return; 2337 return;
2338 } 2338 }
2339 lines.clear(); 2339 lines.clear();
2340 Logger.root.info('Adding ${sourceLines.length} source lines for ${_url}'); 2340 Logger.root.info('Adding ${sourceLines.length} source lines for ${uri}');
2341 for (var i = 0; i < sourceLines.length; i++) { 2341 for (var i = 0; i < sourceLines.length; i++) {
2342 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i])); 2342 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i]));
2343 } 2343 }
2344 for (var bpt in isolate.breakpoints.values) { 2344 for (var bpt in isolate.breakpoints.values) {
2345 if (bpt.script == this) { 2345 if (bpt.script == this) {
2346 _addBreakpoint(bpt); 2346 _addBreakpoint(bpt);
2347 } 2347 }
2348 } 2348 }
2349 2349
2350 _applyHitsToLines(); 2350 _applyHitsToLines();
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 var v = list[i]; 3154 var v = list[i];
3155 if ((v is ObservableMap) && _isServiceMap(v)) { 3155 if ((v is ObservableMap) && _isServiceMap(v)) {
3156 list[i] = owner.getFromMap(v); 3156 list[i] = owner.getFromMap(v);
3157 } else if (v is ObservableList) { 3157 } else if (v is ObservableList) {
3158 _upgradeObservableList(v, owner); 3158 _upgradeObservableList(v, owner);
3159 } else if (v is ObservableMap) { 3159 } else if (v is ObservableMap) {
3160 _upgradeObservableMap(v, owner); 3160 _upgradeObservableMap(v, owner);
3161 } 3161 }
3162 } 3162 }
3163 } 3163 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/library_view.html ('k') | runtime/observatory/tests/service/allocations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698