OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 instance_ref_element; | 5 library instance_ref_element; |
6 | 6 |
7 import 'package:logging/logging.dart'; | 7 import 'package:logging/logging.dart'; |
8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
9 import 'service_ref.dart'; | 9 import 'service_ref.dart'; |
10 | 10 |
11 @CustomTag('instance-ref') | 11 @CustomTag('instance-ref') |
12 class InstanceRefElement extends ServiceRefElement { | 12 class InstanceRefElement extends ServiceRefElement { |
13 InstanceRefElement.created() : super.created(); | 13 InstanceRefElement.created() : super.created(); |
14 | 14 |
15 String get name { | 15 String get name { |
16 if (ref == null) { | 16 if (ref == null) { |
17 return super.name; | 17 return super.name; |
18 } | 18 } |
19 return ref['preview']; | 19 return ref['preview']; |
20 } | 20 } |
21 | 21 |
| 22 String get hoverText { |
| 23 if (ref != null) { |
| 24 if (ref['type'] == '@Null') { |
| 25 if (ref['id'] == 'objects/optimized-out') { |
| 26 return 'This object is no longer needed and has been removed by the op
timizing compiler.'; |
| 27 } else if (ref['id'] == 'objects/collected') { |
| 28 return 'This object has been reclaimed by the garbage collector.'; |
| 29 } else if (ref['id'] == 'objects/expired') { |
| 30 return 'The handle to this object has expired. Consider refreshing th
e page.'; |
| 31 } else if (ref['id'] == 'objects/not-initialized') { |
| 32 return 'This object will be initialized once it is accessed by the pro
gram.'; |
| 33 } else if (ref['id'] == 'objects/being-initialized') { |
| 34 return 'This object is currently being initialized.'; |
| 35 } |
| 36 } |
| 37 } |
| 38 return ''; |
| 39 } |
| 40 |
22 // TODO(turnidge): This is here to workaround vm/dart2js differences. | 41 // TODO(turnidge): This is here to workaround vm/dart2js differences. |
23 dynamic expander() { | 42 dynamic expander() { |
24 return expandEvent; | 43 return expandEvent; |
25 } | 44 } |
26 | 45 |
27 void expandEvent(bool expand, var done) { | 46 void expandEvent(bool expand, var done) { |
28 print("Calling expandEvent"); | 47 print("Calling expandEvent"); |
29 if (expand) { | 48 if (expand) { |
30 isolate.getMap(objectId).then((map) { | 49 isolate.getMap(objectId).then((map) { |
| 50 if (map['type'] == 'Null') { |
| 51 // The object is no longer available. For example, the |
| 52 // object id may have expired or the object may have been |
| 53 // collected by the gc. |
| 54 map['type'] = '@Null'; |
| 55 ref = map; |
| 56 } else { |
| 57 ref['fields'] = map['fields']; |
| 58 ref['elements'] = map['elements']; |
| 59 ref['length'] = map['length']; |
| 60 } |
31 ref['fields'] = map['fields']; | 61 ref['fields'] = map['fields']; |
32 ref['elements'] = map['elements']; | 62 ref['elements'] = map['elements']; |
33 ref['length'] = map['length']; | 63 ref['length'] = map['length']; |
34 }).catchError((e, trace) { | 64 }).catchError((e, trace) { |
35 Logger.root.severe('Error while expanding instance-ref: $e\n$trace'); | 65 Logger.root.severe('Error while expanding instance-ref: $e\n$trace'); |
36 }).whenComplete(done); | 66 }).whenComplete(done); |
37 } else { | 67 } else { |
38 ref['fields'] = null; | 68 ref['fields'] = null; |
39 ref['elements'] = null; | 69 ref['elements'] = null; |
40 done(); | 70 done(); |
41 } | 71 } |
42 } | 72 } |
43 } | 73 } |
OLD | NEW |