| OLD | NEW |
| 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 library class_tree_element; | 5 library class_tree_element; |
| 6 | 6 |
| 7 import 'observatory_element.dart'; | 7 import 'observatory_element.dart'; |
| 8 import 'dart:async'; |
| 8 import 'dart:html'; | 9 import 'dart:html'; |
| 9 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
| 10 import 'package:observatory/app.dart'; | 11 import 'package:observatory/app.dart'; |
| 11 import 'package:observatory/service.dart'; | 12 import 'package:observatory/service.dart'; |
| 12 import 'package:polymer/polymer.dart'; | 13 import 'package:polymer/polymer.dart'; |
| 13 | 14 |
| 14 class ClassTreeRow extends TableTreeRow { | 15 class ClassTreeRow extends TableTreeRow { |
| 15 @reflectable final Isolate isolate; | 16 @reflectable final Isolate isolate; |
| 16 @reflectable final Class cls; | 17 @reflectable final Class cls; |
| 17 ClassTreeRow(this.isolate, this.cls, TableTree tree, ClassTreeRow parent) | 18 ClassTreeRow(this.isolate, this.cls, TableTree tree, ClassTreeRow parent) |
| 18 : super(tree, parent) { | 19 : super(tree, parent) { |
| 19 assert(isolate != null); | 20 assert(isolate != null); |
| 20 assert(cls != null); | 21 assert(cls != null); |
| 21 } | 22 } |
| 22 | 23 |
| 23 void _addChildren(List<Class> subclasses) { | 24 void _addChildren(List<Class> subclasses) { |
| 24 for (var subclass in subclasses) { | 25 for (var subclass in subclasses) { |
| 25 if (subclass.isPatch) { | 26 if (subclass.isPatch) { |
| 26 continue; | 27 continue; |
| 27 } | 28 } |
| 28 if (subclass.mixin != null) { | 29 if (subclass.mixin != null) { |
| 29 _addChildren(subclass.subclasses); | 30 _addChildren(subclass.subclasses); |
| 30 } else { | 31 } else { |
| 31 var row = new ClassTreeRow(isolate, subclass, tree, this); | 32 var row = new ClassTreeRow(isolate, subclass, tree, this); |
| 32 children.add(row); | 33 children.add(row); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 | 37 |
| 37 void _addMixins(Class cls) async { | 38 Future _addMixins(Class cls) async { |
| 38 var classCell = flexColumns[0]; | 39 var classCell = flexColumns[0]; |
| 39 if (cls.superclass == null) { | 40 if (cls.superclass == null) { |
| 40 return; | 41 return; |
| 41 } | 42 } |
| 42 bool first = true; | 43 bool first = true; |
| 43 while (cls.superclass != null && cls.superclass.mixin != null) { | 44 while (cls.superclass != null && cls.superclass.mixin != null) { |
| 44 cls = cls.superclass; | 45 cls = cls.superclass; |
| 45 await cls.mixin.load(); | 46 await cls.mixin.load(); |
| 46 var span = new SpanElement(); | 47 var span = new SpanElement(); |
| 47 span.style.alignSelf = 'center'; | 48 span.style.alignSelf = 'center'; |
| 48 span.style.whiteSpace = 'pre'; | 49 span.style.whiteSpace = 'pre'; |
| 49 if (first) { | 50 if (first) { |
| 50 span.text = ' with '; | 51 span.text = ' with '; |
| 51 } else { | 52 } else { |
| 52 span.text = ', '; | 53 span.text = ', '; |
| 53 } | 54 } |
| 54 classCell.children.add(span); | 55 classCell.children.add(span); |
| 55 var mixinRef = new Element.tag('class-ref'); | 56 var mixinRef = new Element.tag('class-ref'); |
| 56 mixinRef.ref = cls.mixin.typeClass; | 57 mixinRef.ref = cls.mixin.typeClass; |
| 57 mixinRef.style.alignSelf = 'center'; | 58 mixinRef.style.alignSelf = 'center'; |
| 58 classCell.children.add(mixinRef); | 59 classCell.children.add(mixinRef); |
| 59 first = false; | 60 first = false; |
| 60 } | 61 } |
| 61 } | 62 } |
| 62 | 63 |
| 63 void _addClass(Class cls) async { | 64 Future _addClass(Class cls) async { |
| 64 var classCell = flexColumns[0]; | 65 var classCell = flexColumns[0]; |
| 65 classCell.style.justifyContent = 'flex-start'; | 66 classCell.style.justifyContent = 'flex-start'; |
| 66 var classRef = new Element.tag('class-ref'); | 67 var classRef = new Element.tag('class-ref'); |
| 67 classRef.ref = cls; | 68 classRef.ref = cls; |
| 68 classRef.style.alignSelf = 'center'; | 69 classRef.style.alignSelf = 'center'; |
| 69 classCell.children.add(classRef); | 70 classCell.children.add(classRef); |
| 70 if (cls.superclass != null && cls.superclass.mixin != null) { | 71 if (cls.superclass != null && cls.superclass.mixin != null) { |
| 71 await _addMixins(cls); | 72 await _addMixins(cls); |
| 72 } | 73 } |
| 73 if (cls.subclasses.isNotEmpty) { | 74 if (cls.subclasses.isNotEmpty) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } catch (e, stackTrace) { | 144 } catch (e, stackTrace) { |
| 144 Logger.root.warning('_update', e, stackTrace); | 145 Logger.root.warning('_update', e, stackTrace); |
| 145 } | 146 } |
| 146 // Check if we only have one node at the root and expand it. | 147 // Check if we only have one node at the root and expand it. |
| 147 if (tree.rows.length == 1) { | 148 if (tree.rows.length == 1) { |
| 148 tree.toggle(tree.rows[0]); | 149 tree.toggle(tree.rows[0]); |
| 149 } | 150 } |
| 150 notifyPropertyChange(#tree, null, tree); | 151 notifyPropertyChange(#tree, null, tree); |
| 151 } | 152 } |
| 152 } | 153 } |
| OLD | NEW |