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

Side by Side Diff: runtime/observatory/lib/src/elements/field_view.dart

Issue 2345023003: Use dartfmt on Observatory code (Closed)
Patch Set: merge Created 4 years, 3 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) 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 field_view_element; 5 library field_view_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:observatory/models.dart' as M; 9 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/src/elements/class_ref.dart'; 10 import 'package:observatory/src/elements/class_ref.dart';
11 import 'package:observatory/src/elements/curly_block.dart'; 11 import 'package:observatory/src/elements/curly_block.dart';
12 import 'package:observatory/src/elements/helpers/any_ref.dart'; 12 import 'package:observatory/src/elements/helpers/any_ref.dart';
13 import 'package:observatory/src/elements/helpers/nav_bar.dart'; 13 import 'package:observatory/src/elements/helpers/nav_bar.dart';
14 import 'package:observatory/src/elements/helpers/nav_menu.dart'; 14 import 'package:observatory/src/elements/helpers/nav_menu.dart';
15 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 15 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
16 import 'package:observatory/src/elements/helpers/tag.dart'; 16 import 'package:observatory/src/elements/helpers/tag.dart';
17 import 'package:observatory/src/elements/nav/class_menu.dart'; 17 import 'package:observatory/src/elements/nav/class_menu.dart';
18 import 'package:observatory/src/elements/nav/isolate_menu.dart'; 18 import 'package:observatory/src/elements/nav/isolate_menu.dart';
19 import 'package:observatory/src/elements/nav/library_menu.dart'; 19 import 'package:observatory/src/elements/nav/library_menu.dart';
20 import 'package:observatory/src/elements/nav/notify.dart'; 20 import 'package:observatory/src/elements/nav/notify.dart';
21 import 'package:observatory/src/elements/nav/refresh.dart'; 21 import 'package:observatory/src/elements/nav/refresh.dart';
22 import 'package:observatory/src/elements/nav/top_menu.dart'; 22 import 'package:observatory/src/elements/nav/top_menu.dart';
23 import 'package:observatory/src/elements/nav/vm_menu.dart'; 23 import 'package:observatory/src/elements/nav/vm_menu.dart';
24 import 'package:observatory/src/elements/object_common.dart'; 24 import 'package:observatory/src/elements/object_common.dart';
25 import 'package:observatory/src/elements/script_inset.dart'; 25 import 'package:observatory/src/elements/script_inset.dart';
26 import 'package:observatory/src/elements/source_link.dart'; 26 import 'package:observatory/src/elements/source_link.dart';
27 import 'package:observatory/src/elements/view_footer.dart'; 27 import 'package:observatory/src/elements/view_footer.dart';
28 28
29 class FieldViewElement extends HtmlElement implements Renderable { 29 class FieldViewElement extends HtmlElement implements Renderable {
30 static const tag = const Tag<FieldViewElement>('field-view', 30 static const tag =
31 dependencies: const [ 31 const Tag<FieldViewElement>('field-view', dependencies: const [
32 ClassRefElement.tag, 32 ClassRefElement.tag,
33 CurlyBlockElement.tag, 33 CurlyBlockElement.tag,
34 NavClassMenuElement.tag, 34 NavClassMenuElement.tag,
35 NavLibraryMenuElement.tag, 35 NavLibraryMenuElement.tag,
36 NavTopMenuElement.tag, 36 NavTopMenuElement.tag,
37 NavVMMenuElement.tag, 37 NavVMMenuElement.tag,
38 NavIsolateMenuElement.tag, 38 NavIsolateMenuElement.tag,
39 NavRefreshElement.tag, 39 NavRefreshElement.tag,
40 NavNotifyElement.tag, 40 NavNotifyElement.tag,
41 ObjectCommonElement.tag, 41 ObjectCommonElement.tag,
42 ScriptInsetElement.tag, 42 ScriptInsetElement.tag,
43 SourceLinkElement.tag, 43 SourceLinkElement.tag,
44 ViewFooterElement.tag 44 ViewFooterElement.tag
45 ]); 45 ]);
46 46
47 RenderingScheduler<FieldViewElement> _r; 47 RenderingScheduler<FieldViewElement> _r;
48 48
49 Stream<RenderedEvent<FieldViewElement>> get onRendered => _r.onRendered; 49 Stream<RenderedEvent<FieldViewElement>> get onRendered => _r.onRendered;
50 50
51 M.VM _vm; 51 M.VM _vm;
52 M.IsolateRef _isolate; 52 M.IsolateRef _isolate;
53 M.EventRepository _events; 53 M.EventRepository _events;
54 M.NotificationRepository _notifications; 54 M.NotificationRepository _notifications;
55 M.Field _field; 55 M.Field _field;
56 M.LibraryRef _library; 56 M.LibraryRef _library;
57 M.FieldRepository _fields; 57 M.FieldRepository _fields;
58 M.ClassRepository _classes; 58 M.ClassRepository _classes;
59 M.RetainedSizeRepository _retainedSizes; 59 M.RetainedSizeRepository _retainedSizes;
60 M.ReachableSizeRepository _reachableSizes; 60 M.ReachableSizeRepository _reachableSizes;
61 M.InboundReferencesRepository _references; 61 M.InboundReferencesRepository _references;
62 M.RetainingPathRepository _retainingPaths; 62 M.RetainingPathRepository _retainingPaths;
63 M.ScriptRepository _scripts; 63 M.ScriptRepository _scripts;
64 M.InstanceRepository _instances; 64 M.InstanceRepository _instances;
65 65
66
67 M.VMRef get vm => _vm; 66 M.VMRef get vm => _vm;
68 M.IsolateRef get isolate => _isolate; 67 M.IsolateRef get isolate => _isolate;
69 M.NotificationRepository get notifications => _notifications; 68 M.NotificationRepository get notifications => _notifications;
70 M.Field get field => _field; 69 M.Field get field => _field;
71 70
72 factory FieldViewElement(M.VM vm, M.IsolateRef isolate, M.Field field, 71 factory FieldViewElement(
73 M.EventRepository events, 72 M.VM vm,
74 M.NotificationRepository notifications, 73 M.IsolateRef isolate,
75 M.FieldRepository fields, 74 M.Field field,
76 M.ClassRepository classes, 75 M.EventRepository events,
77 M.RetainedSizeRepository retainedSizes, 76 M.NotificationRepository notifications,
78 M.ReachableSizeRepository reachableSizes, 77 M.FieldRepository fields,
79 M.InboundReferencesRepository references, 78 M.ClassRepository classes,
80 M.RetainingPathRepository retainingPaths, 79 M.RetainedSizeRepository retainedSizes,
81 M.ScriptRepository scripts, 80 M.ReachableSizeRepository reachableSizes,
82 M.InstanceRepository instances, 81 M.InboundReferencesRepository references,
83 {RenderingQueue queue}) { 82 M.RetainingPathRepository retainingPaths,
83 M.ScriptRepository scripts,
84 M.InstanceRepository instances,
85 {RenderingQueue queue}) {
84 assert(vm != null); 86 assert(vm != null);
85 assert(isolate != null); 87 assert(isolate != null);
86 assert(events != null); 88 assert(events != null);
87 assert(notifications != null); 89 assert(notifications != null);
88 assert(field != null); 90 assert(field != null);
89 assert(fields != null); 91 assert(fields != null);
90 assert(classes != null); 92 assert(classes != null);
91 assert(retainedSizes != null); 93 assert(retainedSizes != null);
92 assert(reachableSizes != null); 94 assert(reachableSizes != null);
93 assert(references != null); 95 assert(references != null);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 header += 'static '; 140 header += 'static ';
139 } else { 141 } else {
140 header += 'top-level '; 142 header += 'top-level ';
141 } 143 }
142 } 144 }
143 if (_field.isFinal) { 145 if (_field.isFinal) {
144 header += 'final '; 146 header += 'final ';
145 } else if (_field.isConst) { 147 } else if (_field.isConst) {
146 header += 'const '; 148 header += 'const ';
147 } 149 }
148 if (_field.declaredType.name == 'dynamic'){ 150 if (_field.declaredType.name == 'dynamic') {
149 header += 'var'; 151 header += 'var';
150 } else { 152 } else {
151 header += _field.declaredType.name; 153 header += _field.declaredType.name;
152 } 154 }
153 children = [ 155 children = [
154 navBar(_createMenu()), 156 navBar(_createMenu()),
155 new DivElement()..classes = ['content-centered-big'] 157 new DivElement()
158 ..classes = ['content-centered-big']
156 ..children = [ 159 ..children = [
157 new HeadingElement.h2()..text = '$header ${field.name}', 160 new HeadingElement.h2()..text = '$header ${field.name}',
158 new HRElement(), 161 new HRElement(),
159 new ObjectCommonElement(_isolate, _field, _retainedSizes, 162 new ObjectCommonElement(_isolate, _field, _retainedSizes,
160 _reachableSizes, _references, _retainingPaths, 163 _reachableSizes, _references, _retainingPaths, _instances,
161 _instances, queue: _r.queue), 164 queue: _r.queue),
162 new BRElement(), 165 new BRElement(),
163 new DivElement()..classes = ['memberList'] 166 new DivElement()
167 ..classes = ['memberList']
164 ..children = _createMembers(), 168 ..children = _createMembers(),
165 new HRElement(), 169 new HRElement(),
166 new DivElement() 170 new DivElement()
167 ..children = _field.location == null ? const [] 171 ..children = _field.location == null
168 : [ 172 ? const []
169 new ScriptInsetElement(_isolate, _field.location.script, 173 : [
170 _scripts, _instances, _events, 174 new ScriptInsetElement(_isolate, _field.location.script,
171 startPos: field.location.tokenPos, 175 _scripts, _instances, _events,
172 endPos: field.location.tokenPos, 176 startPos: field.location.tokenPos,
173 queue: _r.queue) 177 endPos: field.location.tokenPos,
174 ], 178 queue: _r.queue)
179 ],
175 new ViewFooterElement(queue: _r.queue) 180 new ViewFooterElement(queue: _r.queue)
176 ] 181 ]
177 ]; 182 ];
178 } 183 }
179 184
180 List<Element> _createMenu() { 185 List<Element> _createMenu() {
181 final menu = [ 186 final menu = [
182 new NavTopMenuElement(queue: _r.queue), 187 new NavTopMenuElement(queue: _r.queue),
183 new NavVMMenuElement(_vm, _events, queue: _r.queue), 188 new NavVMMenuElement(_vm, _events, queue: _r.queue),
184 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue) 189 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue)
185 ]; 190 ];
186 if (_library != null) { 191 if (_library != null) {
187 menu.add(new NavLibraryMenuElement(_isolate, _field.dartOwner, 192 menu.add(new NavLibraryMenuElement(_isolate, _field.dartOwner,
188 queue: _r.queue)); 193 queue: _r.queue));
189 } else if (_field.dartOwner is M.ClassRef) { 194 } else if (_field.dartOwner is M.ClassRef) {
190 menu.add( 195 menu.add(
191 new NavClassMenuElement(_isolate, _field.dartOwner, queue: _r.queue) 196 new NavClassMenuElement(_isolate, _field.dartOwner, queue: _r.queue));
192 );
193 } 197 }
194 menu.addAll([ 198 menu.addAll([
195 navMenu(_field.name), 199 navMenu(_field.name),
196 new NavRefreshElement(queue: _r.queue) 200 new NavRefreshElement(queue: _r.queue)
197 ..onRefresh.listen((e) { 201 ..onRefresh.listen((e) {
198 e.element.disabled = true; 202 e.element.disabled = true;
199 _refresh(); 203 _refresh();
200 }), 204 }),
201 new NavNotifyElement(_notifications, queue: _r.queue) 205 new NavNotifyElement(_notifications, queue: _r.queue)
202 ]); 206 ]);
203 return menu; 207 return menu;
204 } 208 }
205 209
206 List<Element> _createMembers() { 210 List<Element> _createMembers() {
207 final members = <Element>[ 211 final members = <Element>[
208 new DivElement()..classes = ['memberItem'] 212 new DivElement()
213 ..classes = ['memberItem']
209 ..children = [ 214 ..children = [
210 new DivElement()..classes = ['memberName'] 215 new DivElement()
216 ..classes = ['memberName']
211 ..text = 'owner', 217 ..text = 'owner',
212 new DivElement()..classes = ['memberName'] 218 new DivElement()
219 ..classes = ['memberName']
213 ..children = [ 220 ..children = [
214 _field.dartOwner == null 221 _field.dartOwner == null
215 ? (new SpanElement()..text = '...') 222 ? (new SpanElement()..text = '...')
216 : anyRef(_isolate, _field.dartOwner, _instances, 223 : anyRef(_isolate, _field.dartOwner, _instances,
217 queue: _r.queue) 224 queue: _r.queue)
218 ] 225 ]
219 ], 226 ],
220 new DivElement()..classes = ['memberItem'] 227 new DivElement()
228 ..classes = ['memberItem']
221 ..children = [ 229 ..children = [
222 new DivElement()..classes = ['memberName'] 230 new DivElement()
231 ..classes = ['memberName']
223 ..text = 'script', 232 ..text = 'script',
224 new DivElement()..classes = ['memberName'] 233 new DivElement()
234 ..classes = ['memberName']
225 ..children = [ 235 ..children = [
226 new SourceLinkElement(_isolate, field.location, _scripts, 236 new SourceLinkElement(_isolate, field.location, _scripts,
227 queue: _r.queue) 237 queue: _r.queue)
228 ] 238 ]
229 ] 239 ]
230 ]; 240 ];
231 if (!_field.isStatic) { 241 if (!_field.isStatic) {
232 members.add( 242 members.add(new DivElement()
233 new DivElement()..classes = ['memberItem'] 243 ..classes = ['memberItem']
234 ..title = 'The types observed for this field at runtime. ' 244 ..title = 'The types observed for this field at runtime. '
235 'Fields that are observed to have a single type at runtime ' 245 'Fields that are observed to have a single type at runtime '
236 'or to never be null may allow for additional optimization.' 246 'or to never be null may allow for additional optimization.'
237 ..children = [ 247 ..children = [
238 new DivElement()..classes = ['memberName'] 248 new DivElement()
239 ..text = 'observed types', 249 ..classes = ['memberName']
240 new DivElement()..classes = ['memberName'] 250 ..text = 'observed types',
241 ..children = _createGuard() 251 new DivElement()
242 ] 252 ..classes = ['memberName']
243 ); 253 ..children = _createGuard()
254 ]);
244 } 255 }
245 if (_field.staticValue != null) { 256 if (_field.staticValue != null) {
246 members.add( 257 members.add(new DivElement()
247 new DivElement()..classes = ['memberItem'] 258 ..classes = ['memberItem']
248 ..children = [ 259 ..children = [
249 new DivElement()..classes = ['memberName'] 260 new DivElement()
250 ..text = 'static value', 261 ..classes = ['memberName']
251 new DivElement()..classes = ['memberName'] 262 ..text = 'static value',
252 ..children = [ 263 new DivElement()
253 anyRef(_isolate, _field.staticValue, _instances, 264 ..classes = ['memberName']
254 queue: _r.queue) 265 ..children = [
255 ] 266 anyRef(_isolate, _field.staticValue, _instances, queue: _r.queue)
256 ] 267 ]
257 ); 268 ]);
258 } 269 }
259 return members; 270 return members;
260 } 271 }
261 272
262 List<Element> _createGuard() { 273 List<Element> _createGuard() {
263 final guard = <Element>[]; 274 final guard = <Element>[];
264 switch (_field.guardClassKind) { 275 switch (_field.guardClassKind) {
265 case M.GuardClassKind.unknown: 276 case M.GuardClassKind.unknown:
266 guard.add(new SpanElement()..text = 'none'); 277 guard.add(new SpanElement()..text = 'none');
267 break; 278 break;
268 case M.GuardClassKind.dynamic: 279 case M.GuardClassKind.dynamic:
269 guard.add(new SpanElement()..text = 'various'); 280 guard.add(new SpanElement()..text = 'various');
270 break; 281 break;
271 case M.GuardClassKind.single: 282 case M.GuardClassKind.single:
272 guard.add(new ClassRefElement(_isolate, _field.guardClass, 283 guard.add(
273 queue: _r.queue)); 284 new ClassRefElement(_isolate, _field.guardClass, queue: _r.queue));
274 break; 285 break;
275 } 286 }
276 guard.add(new SpanElement() 287 guard.add(new SpanElement()
277 ..text = _field.guardNullable ? '— null observed' : '— null not observed' 288 ..text =
278 ); 289 _field.guardNullable ? '— null observed' : '— null not observed');
279 return guard; 290 return guard;
280 } 291 }
281 292
282 Future _refresh() async { 293 Future _refresh() async {
283 _field = await _fields.get(_isolate, _field.id); 294 _field = await _fields.get(_isolate, _field.id);
284 if (_field.dartOwner is M.LibraryRef) { 295 if (_field.dartOwner is M.LibraryRef) {
285 _library = _field.dartOwner; 296 _library = _field.dartOwner;
286 } else if (_field.dartOwner is M.ClassRef) { 297 } else if (_field.dartOwner is M.ClassRef) {
287 _library = (await _classes.get(_isolate, _field.dartOwner.id)).library; 298 _library = (await _classes.get(_isolate, _field.dartOwner.id)).library;
288 } 299 }
289 _r.dirty(); 300 _r.dirty();
290 } 301 }
291 } 302 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/field_ref.dart ('k') | runtime/observatory/lib/src/elements/flag_list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698