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

Side by Side Diff: runtime/observatory/lib/src/elements/function_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 function_view_element; 5 library function_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';
(...skipping 12 matching lines...) Expand all
23 import 'package:observatory/src/elements/nav/notify.dart'; 23 import 'package:observatory/src/elements/nav/notify.dart';
24 import 'package:observatory/src/elements/nav/refresh.dart'; 24 import 'package:observatory/src/elements/nav/refresh.dart';
25 import 'package:observatory/src/elements/nav/top_menu.dart'; 25 import 'package:observatory/src/elements/nav/top_menu.dart';
26 import 'package:observatory/src/elements/nav/vm_menu.dart'; 26 import 'package:observatory/src/elements/nav/vm_menu.dart';
27 import 'package:observatory/src/elements/object_common.dart'; 27 import 'package:observatory/src/elements/object_common.dart';
28 import 'package:observatory/src/elements/source_inset.dart'; 28 import 'package:observatory/src/elements/source_inset.dart';
29 import 'package:observatory/src/elements/source_link.dart'; 29 import 'package:observatory/src/elements/source_link.dart';
30 import 'package:observatory/src/elements/view_footer.dart'; 30 import 'package:observatory/src/elements/view_footer.dart';
31 31
32 class FunctionViewElement extends HtmlElement implements Renderable { 32 class FunctionViewElement extends HtmlElement implements Renderable {
33 static const tag = const Tag<FunctionViewElement>('function-view', 33 static const tag =
34 dependencies: const [ 34 const Tag<FunctionViewElement>('function-view', dependencies: const [
35 ClassRefElement.tag, 35 ClassRefElement.tag,
36 CodeRefElement.tag, 36 CodeRefElement.tag,
37 CurlyBlockElement.tag, 37 CurlyBlockElement.tag,
38 FieldRefElement.tag, 38 FieldRefElement.tag,
39 InstanceRefElement.tag, 39 InstanceRefElement.tag,
40 NavClassMenuElement.tag, 40 NavClassMenuElement.tag,
41 NavLibraryMenuElement.tag, 41 NavLibraryMenuElement.tag,
42 NavTopMenuElement.tag, 42 NavTopMenuElement.tag,
43 NavVMMenuElement.tag, 43 NavVMMenuElement.tag,
44 NavIsolateMenuElement.tag, 44 NavIsolateMenuElement.tag,
45 NavRefreshElement.tag, 45 NavRefreshElement.tag,
46 NavNotifyElement.tag, 46 NavNotifyElement.tag,
47 ObjectCommonElement.tag, 47 ObjectCommonElement.tag,
48 SourceLinkElement.tag, 48 SourceLinkElement.tag,
49 SourceInsetElement.tag, 49 SourceInsetElement.tag,
50 ViewFooterElement.tag 50 ViewFooterElement.tag
51 ]); 51 ]);
52 52
53 RenderingScheduler<FunctionViewElement> _r; 53 RenderingScheduler<FunctionViewElement> _r;
54 54
55 Stream<RenderedEvent<FunctionViewElement>> get onRendered => _r.onRendered; 55 Stream<RenderedEvent<FunctionViewElement>> get onRendered => _r.onRendered;
56 56
57 M.VM _vm; 57 M.VM _vm;
58 M.IsolateRef _isolate; 58 M.IsolateRef _isolate;
59 M.EventRepository _events; 59 M.EventRepository _events;
60 M.NotificationRepository _notifications; 60 M.NotificationRepository _notifications;
61 M.Function _function; 61 M.Function _function;
62 M.LibraryRef _library; 62 M.LibraryRef _library;
63 M.FunctionRepository _functions; 63 M.FunctionRepository _functions;
64 M.ClassRepository _classes; 64 M.ClassRepository _classes;
65 M.RetainedSizeRepository _retainedSizes; 65 M.RetainedSizeRepository _retainedSizes;
66 M.ReachableSizeRepository _reachableSizes; 66 M.ReachableSizeRepository _reachableSizes;
67 M.InboundReferencesRepository _references; 67 M.InboundReferencesRepository _references;
68 M.RetainingPathRepository _retainingPaths; 68 M.RetainingPathRepository _retainingPaths;
69 M.ScriptRepository _scripts; 69 M.ScriptRepository _scripts;
70 M.InstanceRepository _instances; 70 M.InstanceRepository _instances;
71 71
72
73 M.VMRef get vm => _vm; 72 M.VMRef get vm => _vm;
74 M.IsolateRef get isolate => _isolate; 73 M.IsolateRef get isolate => _isolate;
75 M.NotificationRepository get notifications => _notifications; 74 M.NotificationRepository get notifications => _notifications;
76 M.Function get function => _function; 75 M.Function get function => _function;
77 76
78 factory FunctionViewElement(M.VM vm, M.IsolateRef isolate, M.Function function , 77 factory FunctionViewElement(
79 M.EventRepository events, 78 M.VM vm,
80 M.NotificationRepository notifications, 79 M.IsolateRef isolate,
81 M.FunctionRepository functions, 80 M.Function function,
82 M.ClassRepository classes, 81 M.EventRepository events,
83 M.RetainedSizeRepository retainedSizes, 82 M.NotificationRepository notifications,
84 M.ReachableSizeRepository reachableSizes, 83 M.FunctionRepository functions,
85 M.InboundReferencesRepository references, 84 M.ClassRepository classes,
86 M.RetainingPathRepository retainingPaths, 85 M.RetainedSizeRepository retainedSizes,
87 M.ScriptRepository scripts, 86 M.ReachableSizeRepository reachableSizes,
88 M.InstanceRepository instances, 87 M.InboundReferencesRepository references,
89 {RenderingQueue queue}) { 88 M.RetainingPathRepository retainingPaths,
89 M.ScriptRepository scripts,
90 M.InstanceRepository instances,
91 {RenderingQueue queue}) {
90 assert(vm != null); 92 assert(vm != null);
91 assert(isolate != null); 93 assert(isolate != null);
92 assert(events != null); 94 assert(events != null);
93 assert(notifications != null); 95 assert(notifications != null);
94 assert(function != null); 96 assert(function != null);
95 assert(functions != null); 97 assert(functions != null);
96 assert(classes != null); 98 assert(classes != null);
97 assert(retainedSizes != null); 99 assert(retainedSizes != null);
98 assert(reachableSizes != null); 100 assert(reachableSizes != null);
99 assert(references != null); 101 assert(references != null);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 @override 135 @override
134 detached() { 136 detached() {
135 super.detached(); 137 super.detached();
136 _r.disable(notify: true); 138 _r.disable(notify: true);
137 children = []; 139 children = [];
138 } 140 }
139 141
140 void render() { 142 void render() {
141 children = [ 143 children = [
142 navBar(_createMenu()), 144 navBar(_createMenu()),
143 new DivElement()..classes = ['content-centered-big'] 145 new DivElement()
146 ..classes = ['content-centered-big']
144 ..children = [ 147 ..children = [
145 new HeadingElement.h2()..text = 'Function ${_function.name}', 148 new HeadingElement.h2()..text = 'Function ${_function.name}',
146 new HRElement(), 149 new HRElement(),
147 new ObjectCommonElement(_isolate, _function, _retainedSizes, 150 new ObjectCommonElement(_isolate, _function, _retainedSizes,
148 _reachableSizes, _references, _retainingPaths, 151 _reachableSizes, _references, _retainingPaths, _instances,
149 _instances, queue: _r.queue), 152 queue: _r.queue),
150 new BRElement(), 153 new BRElement(),
151 new DivElement()..classes = ['memberList'] 154 new DivElement()
155 ..classes = ['memberList']
152 ..children = _createMembers(), 156 ..children = _createMembers(),
153 new HRElement(), 157 new HRElement(),
154 new DivElement() 158 new DivElement()
155 ..children = _function.location == null ? const [] 159 ..children = _function.location == null
156 : [ 160 ? const []
157 new SourceInsetElement(_isolate, _function.location, _scripts, 161 : [
158 _instances, _events, queue: _r.queue) 162 new SourceInsetElement(_isolate, _function.location,
159 ], 163 _scripts, _instances, _events,
164 queue: _r.queue)
165 ],
160 new ViewFooterElement(queue: _r.queue) 166 new ViewFooterElement(queue: _r.queue)
161 ] 167 ]
162 ]; 168 ];
163 } 169 }
164 170
165 List<Element> _createMenu() { 171 List<Element> _createMenu() {
166 final menu = [ 172 final menu = [
167 new NavTopMenuElement(queue: _r.queue), 173 new NavTopMenuElement(queue: _r.queue),
168 new NavVMMenuElement(_vm, _events, queue: _r.queue), 174 new NavVMMenuElement(_vm, _events, queue: _r.queue),
169 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue) 175 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue)
170 ]; 176 ];
171 if (_library != null) { 177 if (_library != null) {
172 menu.add(new NavLibraryMenuElement(_isolate, _function.dartOwner, 178 menu.add(new NavLibraryMenuElement(_isolate, _function.dartOwner,
173 queue: _r.queue)); 179 queue: _r.queue));
174 } else if (_function.dartOwner is M.ClassRef) { 180 } else if (_function.dartOwner is M.ClassRef) {
175 menu.add( 181 menu.add(new NavClassMenuElement(_isolate, _function.dartOwner,
176 new NavClassMenuElement(_isolate, _function.dartOwner, queue: _r.queue) 182 queue: _r.queue));
177 );
178 } 183 }
179 menu.addAll([ 184 menu.addAll([
180 navMenu(_function.name), 185 navMenu(_function.name),
181 new NavRefreshElement(queue: _r.queue) 186 new NavRefreshElement(queue: _r.queue)
182 ..onRefresh.listen((e) { 187 ..onRefresh.listen((e) {
183 e.element.disabled = true; 188 e.element.disabled = true;
184 _refresh(); 189 _refresh();
185 }), 190 }),
186 new NavNotifyElement(_notifications, queue: _r.queue) 191 new NavNotifyElement(_notifications, queue: _r.queue)
187 ]); 192 ]);
188 return menu; 193 return menu;
189 } 194 }
190 195
191 List<Element> _createMembers() { 196 List<Element> _createMembers() {
192 final members = <Element>[ 197 final members = <Element>[
193 new DivElement()..classes = ['memberItem'] 198 new DivElement()
199 ..classes = ['memberItem']
194 ..children = [ 200 ..children = [
195 new DivElement()..classes = ['memberName'] 201 new DivElement()
202 ..classes = ['memberName']
196 ..text = 'kind', 203 ..text = 'kind',
197 new DivElement()..classes = ['memberName'] 204 new DivElement()
205 ..classes = ['memberName']
198 ..children = [ 206 ..children = [
199 new SpanElement() 207 new SpanElement()
200 ..text = '${_function.isStatic ? "static ": ""}' 208 ..text = '${_function.isStatic ? "static ": ""}'
201 '${_function.isConst ? "const ": ""}' 209 '${_function.isConst ? "const ": ""}'
202 '${_functionKindToString(_function.kind)}' 210 '${_functionKindToString(_function.kind)}'
203 ] 211 ]
204 ], 212 ],
205 new DivElement()..classes = ['memberItem'] 213 new DivElement()
214 ..classes = ['memberItem']
206 ..children = [ 215 ..children = [
207 new DivElement()..classes = ['memberName'] 216 new DivElement()
217 ..classes = ['memberName']
208 ..text = 'owner', 218 ..text = 'owner',
209 new DivElement()..classes = ['memberName'] 219 new DivElement()
220 ..classes = ['memberName']
210 ..children = [ 221 ..children = [
211 _function.dartOwner == null 222 _function.dartOwner == null
212 ? (new SpanElement()..text = '...') 223 ? (new SpanElement()..text = '...')
213 : anyRef(_isolate, _function.dartOwner, _instances, 224 : anyRef(_isolate, _function.dartOwner, _instances,
214 queue: _r.queue) 225 queue: _r.queue)
215 ] 226 ]
216 ] 227 ]
217 ]; 228 ];
218 if (_function.field != null) { 229 if (_function.field != null) {
219 members.add( 230 members.add(new DivElement()
220 new DivElement()..classes = ['memberItem'] 231 ..classes = ['memberItem']
232 ..children = [
233 new DivElement()
234 ..classes = ['memberName']
235 ..text = 'script',
236 new DivElement()
237 ..classes = ['memberName']
238 ..children = [
239 new FieldRefElement(_isolate, _function.field, _instances,
240 queue: _r.queue)
241 ]
242 ]);
243 }
244 members.add(new DivElement()
245 ..classes = ['memberItem']
246 ..children = [
247 new DivElement()
248 ..classes = ['memberName']
249 ..text = 'script',
250 new DivElement()
251 ..classes = ['memberName']
221 ..children = [ 252 ..children = [
222 new DivElement()..classes = ['memberName'] 253 new SourceLinkElement(_isolate, _function.location, _scripts,
223 ..text = 'script', 254 queue: _r.queue)
224 new DivElement()..classes = ['memberName']
225 ..children = [
226 new FieldRefElement(_isolate, _function.field, _instances,
227 queue: _r.queue)
228 ]
229 ] 255 ]
230 ); 256 ]);
231 } 257 if (_function.code != null) {
232 members.add( 258 members.add(new DivElement()
233 new DivElement()..classes = ['memberItem'] 259 ..classes = ['memberItem']
234 ..children = [ 260 ..children = [
235 new DivElement()..classes = ['memberName'] 261 new DivElement()
236 ..text = 'script', 262 ..classes = ['memberName']
237 new DivElement()..classes = ['memberName'] 263 ..text = 'current code',
264 new DivElement()
265 ..classes = ['memberName']
238 ..children = [ 266 ..children = [
239 new SourceLinkElement(_isolate, _function.location, _scripts, 267 new CodeRefElement(_isolate, _function.code, queue: _r.queue)
240 queue: _r.queue)
241 ] 268 ]
242 ] 269 ]);
243 );
244 if (_function.code != null) {
245 members.add(
246 new DivElement()..classes = ['memberItem']
247 ..children = [
248 new DivElement()..classes = ['memberName']
249 ..text = 'current code',
250 new DivElement()..classes = ['memberName']
251 ..children = [
252 new CodeRefElement(_isolate, _function.code, queue: _r.queue)
253 ]
254 ]
255 );
256 } 270 }
257 if (_function.unoptimizedCode != null) { 271 if (_function.unoptimizedCode != null) {
258 members.add( 272 members.add(new DivElement()
259 new DivElement()..classes = ['memberItem'] 273 ..classes = ['memberItem']
260 ..children = [ 274 ..children = [
261 new DivElement()..classes = ['memberName'] 275 new DivElement()
262 ..text = 'unoptimized code', 276 ..classes = ['memberName']
263 new DivElement()..classes = ['memberName'] 277 ..text = 'unoptimized code',
264 ..children = [ 278 new DivElement()
265 new CodeRefElement(_isolate, _function.unoptimizedCode, 279 ..classes = ['memberName']
266 queue: _r.queue), 280 ..children = [
267 new SpanElement() 281 new CodeRefElement(_isolate, _function.unoptimizedCode,
268 ..title = 'This count is used to determine when a function ' 282 queue: _r.queue),
269 'will be optimized. It is a combination of call ' 283 new SpanElement()
270 'counts and other factors.' 284 ..title = 'This count is used to determine when a function '
271 ..text = ' (usage count: ${function.usageCounter })' 285 'will be optimized. It is a combination of call '
272 ] 286 'counts and other factors.'
273 ] 287 ..text = ' (usage count: ${function.usageCounter })'
274 ); 288 ]
289 ]);
275 } 290 }
276 members.add( 291 members.add(new DivElement()
277 new DivElement() 292 ..classes = ['memberItem']
278 ..classes = ['memberItem'] 293 ..text = ' ');
279 ..text = ' ');
280 294
281 if (_function.icDataArray != null) { 295 if (_function.icDataArray != null) {
282 members.add( 296 members.add(new DivElement()
283 new DivElement() 297 ..classes = ['memberItem']
284 ..classes = ['memberItem'] 298 ..children = [
285 ..children = [ 299 new DivElement()
286 new DivElement() 300 ..classes = ['memberName']
287 ..classes = ['memberName'] 301 ..text = 'ic data array',
288 ..text = 'ic data array', 302 new DivElement()
289 new DivElement() 303 ..classes = ['memberName']
290 ..classes = ['memberName'] 304 ..children = [
291 ..children = [ 305 new InstanceRefElement(
292 new InstanceRefElement(_isolate, _function.icDataArray, 306 _isolate, _function.icDataArray, _instances,
293 _instances, queue: _r.queue) 307 queue: _r.queue)
294 ] 308 ]
295 ] 309 ]);
296 );
297 } 310 }
298 311
299 members.addAll([ 312 members.addAll([
300 new DivElement()..classes = ['memberItem'] 313 new DivElement()
314 ..classes = ['memberItem']
301 ..children = [ 315 ..children = [
302 new DivElement()..classes = ['memberName'] 316 new DivElement()
317 ..classes = ['memberName']
303 ..text = 'deoptimizations', 318 ..text = 'deoptimizations',
304 new DivElement()..classes = ['memberName'] 319 new DivElement()
320 ..classes = ['memberName']
305 ..text = '${_function.deoptimizations}' 321 ..text = '${_function.deoptimizations}'
306 ], 322 ],
307 new DivElement()..classes = ['memberItem'] 323 new DivElement()
324 ..classes = ['memberItem']
308 ..children = [ 325 ..children = [
309 new DivElement()..classes = ['memberName'] 326 new DivElement()
327 ..classes = ['memberName']
310 ..text = 'optimizable', 328 ..text = 'optimizable',
311 new DivElement()..classes = ['memberName'] 329 new DivElement()
330 ..classes = ['memberName']
312 ..text = _function.isOptimizable ? 'yes' : 'no' 331 ..text = _function.isOptimizable ? 'yes' : 'no'
313 ], 332 ],
314 new DivElement()..classes = ['memberItem'] 333 new DivElement()
334 ..classes = ['memberItem']
315 ..children = [ 335 ..children = [
316 new DivElement()..classes = ['memberName'] 336 new DivElement()
337 ..classes = ['memberName']
317 ..text = 'inlinable', 338 ..text = 'inlinable',
318 new DivElement()..classes = ['memberName'] 339 new DivElement()
340 ..classes = ['memberName']
319 ..text = _function.isInlinable ? 'yes' : 'no' 341 ..text = _function.isInlinable ? 'yes' : 'no'
320 ], 342 ],
321 new DivElement()..classes = ['memberItem'] 343 new DivElement()
344 ..classes = ['memberItem']
322 ..children = [ 345 ..children = [
323 new DivElement()..classes = ['memberName'] 346 new DivElement()
347 ..classes = ['memberName']
324 ..text = 'intrinsic', 348 ..text = 'intrinsic',
325 new DivElement()..classes = ['memberName'] 349 new DivElement()
350 ..classes = ['memberName']
326 ..text = _function.hasIntrinsic ? 'yes' : 'no' 351 ..text = _function.hasIntrinsic ? 'yes' : 'no'
327 ], 352 ],
328 new DivElement()..classes = ['memberItem'] 353 new DivElement()
354 ..classes = ['memberItem']
329 ..children = [ 355 ..children = [
330 new DivElement()..classes = ['memberName'] 356 new DivElement()
357 ..classes = ['memberName']
331 ..text = 'recognized', 358 ..text = 'recognized',
332 new DivElement()..classes = ['memberName'] 359 new DivElement()
360 ..classes = ['memberName']
333 ..text = _function.isRecognized ? 'yes' : 'no' 361 ..text = _function.isRecognized ? 'yes' : 'no'
334 ], 362 ],
335 new DivElement()..classes = ['memberItem'] 363 new DivElement()
364 ..classes = ['memberItem']
336 ..children = [ 365 ..children = [
337 new DivElement()..classes = ['memberName'] 366 new DivElement()
367 ..classes = ['memberName']
338 ..text = 'native', 368 ..text = 'native',
339 new DivElement()..classes = ['memberName'] 369 new DivElement()
370 ..classes = ['memberName']
340 ..text = _function.isNative ? 'yes' : 'no' 371 ..text = _function.isNative ? 'yes' : 'no'
341 ], 372 ],
342 new DivElement()..classes = ['memberItem'] 373 new DivElement()
374 ..classes = ['memberItem']
343 ..children = [ 375 ..children = [
344 new DivElement()..classes = ['memberName'] 376 new DivElement()
377 ..classes = ['memberName']
345 ..text = 'vm name', 378 ..text = 'vm name',
346 new DivElement()..classes = ['memberName'] 379 new DivElement()
380 ..classes = ['memberName']
347 ..text = _function.vmName 381 ..text = _function.vmName
348 ] 382 ]
349 ]); 383 ]);
350 return members; 384 return members;
351 } 385 }
352 386
353 Future _refresh() async { 387 Future _refresh() async {
354 _function = await _functions.get(_isolate, _function.id); 388 _function = await _functions.get(_isolate, _function.id);
355 if (_function.dartOwner is M.LibraryRef) { 389 if (_function.dartOwner is M.LibraryRef) {
356 _library = _function.dartOwner; 390 _library = _function.dartOwner;
357 } else if (_function.dartOwner is M.ClassRef) { 391 } else if (_function.dartOwner is M.ClassRef) {
358 _library = (await _classes.get(_isolate, _function.dartOwner.id)).library; 392 _library = (await _classes.get(_isolate, _function.dartOwner.id)).library;
359 } 393 }
360 _r.dirty(); 394 _r.dirty();
361 } 395 }
362 396
363 static String _functionKindToString(M.FunctionKind kind) { 397 static String _functionKindToString(M.FunctionKind kind) {
364 switch(kind) { 398 switch (kind) {
365 case M.FunctionKind.regular: 399 case M.FunctionKind.regular:
366 return 'regular'; 400 return 'regular';
367 case M.FunctionKind.closure: 401 case M.FunctionKind.closure:
368 return 'closure'; 402 return 'closure';
369 case M.FunctionKind.getter: 403 case M.FunctionKind.getter:
370 return 'getter'; 404 return 'getter';
371 case M.FunctionKind.setter: 405 case M.FunctionKind.setter:
372 return 'setter'; 406 return 'setter';
373 case M.FunctionKind.constructor: 407 case M.FunctionKind.constructor:
374 return 'constructor'; 408 return 'constructor';
(...skipping 20 matching lines...) Expand all
395 case M.FunctionKind.stub: 429 case M.FunctionKind.stub:
396 return 'stub'; 430 return 'stub';
397 case M.FunctionKind.tag: 431 case M.FunctionKind.tag:
398 return 'tag'; 432 return 'tag';
399 case M.FunctionKind.signatureFunction: 433 case M.FunctionKind.signatureFunction:
400 return 'signature function'; 434 return 'signature function';
401 } 435 }
402 throw new Exception('Unknown Functionkind ($kind)'); 436 throw new Exception('Unknown Functionkind ($kind)');
403 } 437 }
404 } 438 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/function_ref.dart ('k') | runtime/observatory/lib/src/elements/general_error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698