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 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/curly_block.dart'; | 8 import 'package:observatory/src/elements/curly_block.dart'; |
9 import 'package:observatory/src/elements/instance_ref.dart'; | 9 import 'package:observatory/src/elements/instance_ref.dart'; |
10 import 'package:observatory/src/elements/helpers/any_ref.dart'; | 10 import 'package:observatory/src/elements/helpers/any_ref.dart'; |
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
12 import 'package:observatory/src/elements/helpers/tag.dart'; | 12 import 'package:observatory/src/elements/helpers/tag.dart'; |
13 | 13 |
14 class InboundReferencesElement extends HtmlElement implements Renderable { | 14 class InboundReferencesElement extends HtmlElement implements Renderable { |
15 static const tag = const Tag<InboundReferencesElement>('inbound-references', | 15 static const tag = const Tag<InboundReferencesElement>('inbound-references', |
16 dependencies: const [ | 16 dependencies: const [CurlyBlockElement.tag, InstanceRefElement.tag]); |
17 CurlyBlockElement.tag, | |
18 InstanceRefElement.tag | |
19 ]); | |
20 | 17 |
21 RenderingScheduler<InboundReferencesElement> _r; | 18 RenderingScheduler<InboundReferencesElement> _r; |
22 | 19 |
23 Stream<RenderedEvent<InboundReferencesElement>> get onRendered => | 20 Stream<RenderedEvent<InboundReferencesElement>> get onRendered => |
24 _r.onRendered; | 21 _r.onRendered; |
25 | 22 |
26 M.IsolateRef _isolate; | 23 M.IsolateRef _isolate; |
27 M.ObjectRef _object; | 24 M.ObjectRef _object; |
28 M.InboundReferencesRepository _references; | 25 M.InboundReferencesRepository _references; |
29 M.InstanceRepository _instances; | 26 M.InstanceRepository _instances; |
30 M.InboundReferences _inbounds; | 27 M.InboundReferences _inbounds; |
31 bool _expanded = false; | 28 bool _expanded = false; |
32 | 29 |
33 M.IsolateRef get isolate => _isolate; | 30 M.IsolateRef get isolate => _isolate; |
34 M.ObjectRef get object => _object; | 31 M.ObjectRef get object => _object; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 87 } |
91 return _inbounds.elements.map(_createItem).toList(); | 88 return _inbounds.elements.map(_createItem).toList(); |
92 } | 89 } |
93 | 90 |
94 Element _createItem(M.InboundReference reference) { | 91 Element _createItem(M.InboundReference reference) { |
95 final content = <Element>[]; | 92 final content = <Element>[]; |
96 | 93 |
97 if (reference.parentField != null) { | 94 if (reference.parentField != null) { |
98 content.addAll([ | 95 content.addAll([ |
99 new SpanElement()..text = 'from ', | 96 new SpanElement()..text = 'from ', |
100 anyRef(_isolate, reference.parentField, _instances, | 97 anyRef(_isolate, reference.parentField, _instances, queue: _r.queue), |
101 queue: _r.queue), | |
102 new SpanElement()..text = ' of ' | 98 new SpanElement()..text = ' of ' |
103 ]); | 99 ]); |
104 } else if (reference.parentListIndex != null) { | 100 } else if (reference.parentListIndex != null) { |
105 content.add( | 101 content.add(new SpanElement() |
106 new SpanElement() | 102 ..text = 'from [ ${reference.parentListIndex} ] of '); |
107 ..text = 'from [ ${reference.parentListIndex} ] of ' | |
108 ); | |
109 } else if (reference.parentWordOffset != null) { | 103 } else if (reference.parentWordOffset != null) { |
110 content.add( | 104 content.add(new SpanElement() |
111 new SpanElement() | 105 ..text = 'from word [ ${reference.parentWordOffset} ] of '); |
112 ..text = 'from word [ ${reference.parentWordOffset} ] of ' | |
113 ); | |
114 } | 106 } |
115 | 107 |
116 content.addAll([ | 108 content.addAll([ |
117 anyRef(_isolate, reference.source, _instances, queue: _r.queue), | 109 anyRef(_isolate, reference.source, _instances, queue: _r.queue), |
118 new SpanElement()..text = ' referenced by ', | 110 new SpanElement()..text = ' referenced by ', |
119 new InboundReferencesElement(_isolate, reference.source, _references, | 111 new InboundReferencesElement( |
120 _instances, queue: _r.queue ) | 112 _isolate, reference.source, _references, _instances, |
| 113 queue: _r.queue) |
121 ]); | 114 ]); |
122 | 115 |
123 return new DivElement()..classes = ['indent'] | 116 return new DivElement() |
124 ..children = content; | 117 ..classes = ['indent'] |
| 118 ..children = content; |
125 } | 119 } |
126 } | 120 } |
OLD | NEW |