OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 source_link_element; | 5 library source_link_element; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'package:observatory/models.dart' | 9 import 'package:observatory/models.dart' |
10 show IsolateRef, SourceLocation, Script, ScriptRepository; | 10 show IsolateRef, SourceLocation, Script, ScriptRepository; |
(...skipping 26 matching lines...) Expand all Loading... |
37 e._location = location; | 37 e._location = location; |
38 e._repository = repository; | 38 e._repository = repository; |
39 return e; | 39 return e; |
40 } | 40 } |
41 | 41 |
42 SourceLinkElement.created() : super.created(); | 42 SourceLinkElement.created() : super.created(); |
43 | 43 |
44 @override | 44 @override |
45 void attached() { | 45 void attached() { |
46 super.attached(); | 46 super.attached(); |
47 assert(location != null); | |
48 _r.enable(); | |
49 _repository.get(_location.script.id).then((script) { | 47 _repository.get(_location.script.id).then((script) { |
50 _script = script; | 48 _script = script; |
51 _r.dirty(); | 49 _r.dirty(); |
52 }); | 50 }); |
| 51 _r.enable(); |
53 } | 52 } |
54 | 53 |
55 @override | 54 @override |
56 void detached() { super.detached(); children = []; _r.disable(notify: true); } | 55 void detached() { |
| 56 super.detached(); |
| 57 children = []; |
| 58 _r.disable(notify: true); |
| 59 } |
57 | 60 |
58 Future render() async { | 61 Future render() async { |
59 if (_script == null) { | 62 if (_script == null) { |
60 children = [new SpanElement()..text = '<LOADING>']; | 63 children = [new SpanElement()..text = '<LOADING>']; |
61 } else { | 64 } else { |
62 String label = _script.uri.split('/').last; | 65 String label = _script.uri.split('/').last; |
63 int token = _location.tokenPos; | 66 int token = _location.tokenPos; |
64 int line = _script.tokenToLine(token); | 67 int line = _script.tokenToLine(token); |
65 int column = _script.tokenToCol(token); | 68 int column = _script.tokenToCol(token); |
66 children = [ | 69 children = [ |
67 new AnchorElement( | 70 new AnchorElement( |
68 href: Uris.inspect(isolate, object: _script, pos: token)) | 71 href: Uris.inspect(isolate, object: _script, pos: token)) |
69 ..title = _script.uri | 72 ..title = _script.uri |
70 ..text = '${label}:${line}:${column}' | 73 ..text = '${label}:${line}:${column}' |
71 ]; | 74 ]; |
72 } | 75 } |
73 } | 76 } |
74 } | 77 } |
OLD | NEW |