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

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

Issue 2873013004: Omnibus Observatory UI fixes: (Closed)
Patch Set: Created 3 years, 7 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 script_inset_element; 5 library script_inset_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:svg'; 9 import 'dart:svg';
10 import 'package:observatory/app.dart'; 10 import 'package:observatory/app.dart';
11 import 'package:observatory/models.dart' as M; 11 import 'package:observatory/models.dart' as M;
12 import 'package:observatory/service.dart' as S; 12 import 'package:observatory/service.dart' as S;
13 import 'package:observatory/src/elements/helpers/any_ref.dart'; 13 import 'package:observatory/src/elements/helpers/any_ref.dart';
14 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 14 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
15 import 'package:observatory/src/elements/helpers/tag.dart'; 15 import 'package:observatory/src/elements/helpers/tag.dart';
16 import 'package:observatory/src/elements/helpers/uris.dart'; 16 import 'package:observatory/src/elements/helpers/uris.dart';
17 import 'package:observatory/utils.dart'; 17 import 'package:observatory/utils.dart';
18 18
19 class ScriptInsetElement extends HtmlElement implements Renderable { 19 class ScriptInsetElement extends HtmlElement implements Renderable {
20 static const tag = const Tag<ScriptInsetElement>('script-inset'); 20 static const tag = const Tag<ScriptInsetElement>('script-inset');
21 21
22 RenderingScheduler _r; 22 RenderingScheduler _r;
23 23
24 Stream<RenderedEvent<ScriptInsetElement>> get onRendered => _r.onRendered; 24 Stream<RenderedEvent<ScriptInsetElement>> get onRendered => _r.onRendered;
25 25
26 M.IsolateRef _isolate; 26 M.IsolateRef _isolate;
27 M.ScriptRef _script; 27 M.ScriptRef _script;
28 M.Script _loadedScript; 28 M.Script _loadedScript;
29 M.ScriptRepository _scripts; 29 M.ScriptRepository _scripts;
30 M.InstanceRepository _instances; 30 M.ObjectRepository _objects;
31 M.EventRepository _events; 31 M.EventRepository _events;
32 StreamSubscription _subscription; 32 StreamSubscription _subscription;
33 int _startPos; 33 int _startPos;
34 int _endPos; 34 int _endPos;
35 int _currentPos; 35 int _currentPos;
36 bool _inDebuggerContext; 36 bool _inDebuggerContext;
37 Iterable _variables; 37 Iterable _variables;
38 38
39 M.IsolateRef get isolate => _isolate; 39 M.IsolateRef get isolate => _isolate;
40 M.ScriptRef get script => _script; 40 M.ScriptRef get script => _script;
41 41
42 factory ScriptInsetElement( 42 factory ScriptInsetElement(
43 M.IsolateRef isolate, 43 M.IsolateRef isolate,
44 M.ScriptRef script, 44 M.ScriptRef script,
45 M.ScriptRepository scripts, 45 M.ScriptRepository scripts,
46 M.InstanceRepository instances, 46 M.ObjectRepository objects,
47 M.EventRepository events, 47 M.EventRepository events,
48 {int startPos, 48 {int startPos,
49 int endPos, 49 int endPos,
50 int currentPos, 50 int currentPos,
51 bool inDebuggerContext: false, 51 bool inDebuggerContext: false,
52 Iterable variables: const [], 52 Iterable variables: const [],
53 RenderingQueue queue}) { 53 RenderingQueue queue}) {
54 assert(isolate != null); 54 assert(isolate != null);
55 assert(script != null); 55 assert(script != null);
56 assert(scripts != null); 56 assert(scripts != null);
57 assert(instances != null); 57 assert(objects != null);
58 assert(events != null); 58 assert(events != null);
59 assert(inDebuggerContext != null); 59 assert(inDebuggerContext != null);
60 assert(variables != null); 60 assert(variables != null);
61 ScriptInsetElement e = document.createElement(tag.name); 61 ScriptInsetElement e = document.createElement(tag.name);
62 e._r = new RenderingScheduler(e, queue: queue); 62 e._r = new RenderingScheduler(e, queue: queue);
63 e._isolate = isolate; 63 e._isolate = isolate;
64 e._script = script; 64 e._script = script;
65 e._scripts = scripts; 65 e._scripts = scripts;
66 e._instances = instances; 66 e._objects = objects;
67 e._events = events; 67 e._events = events;
68 e._startPos = startPos; 68 e._startPos = startPos;
69 e._endPos = endPos; 69 e._endPos = endPos;
70 e._currentPos = currentPos; 70 e._currentPos = currentPos;
71 e._inDebuggerContext = inDebuggerContext; 71 e._inDebuggerContext = inDebuggerContext;
72 e._variables = new List.unmodifiable(variables); 72 e._variables = new List.unmodifiable(variables);
73 return e; 73 return e;
74 } 74 }
75 75
76 ScriptInsetElement.created() : super.created(); 76 ScriptInsetElement.created() : super.created();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 addCallSiteAnnotations(); 319 addCallSiteAnnotations();
320 } 320 }
321 321
322 addLocalVariableAnnotations(); 322 addLocalVariableAnnotations();
323 323
324 _annotations.sort(); 324 _annotations.sort();
325 } 325 }
326 326
327 void addCurrentExecutionAnnotation() { 327 void addCurrentExecutionAnnotation() {
328 if (_currentLine != null) { 328 if (_currentLine != null) {
329 var a = new CurrentExecutionAnnotation(_isolate, _instances, _r.queue); 329 var a = new CurrentExecutionAnnotation(_isolate, _objects, _r.queue);
330 a.line = _currentLine; 330 a.line = _currentLine;
331 a.columnStart = _currentCol; 331 a.columnStart = _currentCol;
332 S.Script script = _loadedScript as S.Script; 332 S.Script script = _loadedScript as S.Script;
333 var length = script.guessTokenLength(_currentLine, _currentCol); 333 var length = script.guessTokenLength(_currentLine, _currentCol);
334 if (length == null) { 334 if (length == null) {
335 length = 1; 335 length = 1;
336 } 336 }
337 a.columnStop = _currentCol + length; 337 a.columnStop = _currentCol + length;
338 _annotations.add(a); 338 _annotations.add(a);
339 } 339 }
340 } 340 }
341 341
342 void addBreakpointAnnotations() { 342 void addBreakpointAnnotations() {
343 S.Script script = _loadedScript as S.Script; 343 S.Script script = _loadedScript as S.Script;
344 for (var line = _startLine; line <= _endLine; line++) { 344 for (var line = _startLine; line <= _endLine; line++) {
345 var bpts = script.getLine(line).breakpoints; 345 var bpts = script.getLine(line).breakpoints;
346 if (bpts != null) { 346 if (bpts != null) {
347 for (var bpt in bpts) { 347 for (var bpt in bpts) {
348 if (bpt.location != null) { 348 if (bpt.location != null) {
349 _annotations.add( 349 _annotations.add(
350 new BreakpointAnnotation(_isolate, _instances, _r.queue, bpt)); 350 new BreakpointAnnotation(_isolate, _objects, _r.queue, bpt));
351 } 351 }
352 } 352 }
353 } 353 }
354 } 354 }
355 } 355 }
356 356
357 Future loadDeclarationsOfLibrary(S.Library lib) { 357 Future loadDeclarationsOfLibrary(S.Library lib) {
358 return lib.load().then((lib) { 358 return lib.load().then((lib) {
359 var loads = []; 359 var loads = [];
360 for (var func in lib.functions) { 360 for (var func in lib.functions) {
(...skipping 24 matching lines...) Expand all
385 385
386 void addLibraryAnnotations() { 386 void addLibraryAnnotations() {
387 S.Script script = _loadedScript as S.Script; 387 S.Script script = _loadedScript as S.Script;
388 for (S.ScriptLine line in script.lines) { 388 for (S.ScriptLine line in script.lines) {
389 // TODO(rmacnak): Use a real scanner. 389 // TODO(rmacnak): Use a real scanner.
390 var pattern = new RegExp("library ${script.library.name}"); 390 var pattern = new RegExp("library ${script.library.name}");
391 var match = pattern.firstMatch(line.text); 391 var match = pattern.firstMatch(line.text);
392 if (match != null) { 392 if (match != null) {
393 var anno = new LibraryAnnotation( 393 var anno = new LibraryAnnotation(
394 _isolate, 394 _isolate,
395 _instances, 395 _objects,
396 _r.queue, 396 _r.queue,
397 _loadedScript.library, 397 _loadedScript.library,
398 Uris.inspect(isolate, object: _loadedScript.library)); 398 Uris.inspect(isolate, object: _loadedScript.library));
399 anno.line = line.line; 399 anno.line = line.line;
400 anno.columnStart = match.start + 8; 400 anno.columnStart = match.start + 8;
401 anno.columnStop = match.end; 401 anno.columnStop = match.end;
402 _annotations.add(anno); 402 _annotations.add(anno);
403 } 403 }
404 // TODO(rmacnak): Use a real scanner. 404 // TODO(rmacnak): Use a real scanner.
405 pattern = new RegExp("part of ${script.library.name}"); 405 pattern = new RegExp("part of ${script.library.name}");
406 match = pattern.firstMatch(line.text); 406 match = pattern.firstMatch(line.text);
407 if (match != null) { 407 if (match != null) {
408 var anno = new LibraryAnnotation( 408 var anno = new LibraryAnnotation(
409 _isolate, 409 _isolate,
410 _instances, 410 _objects,
411 _r.queue, 411 _r.queue,
412 _loadedScript.library, 412 _loadedScript.library,
413 Uris.inspect(isolate, object: _loadedScript.library)); 413 Uris.inspect(isolate, object: _loadedScript.library));
414 anno.line = line.line; 414 anno.line = line.line;
415 anno.columnStart = match.start + 8; 415 anno.columnStart = match.start + 8;
416 anno.columnStop = match.end; 416 anno.columnStop = match.end;
417 _annotations.add(anno); 417 _annotations.add(anno);
418 } 418 }
419 } 419 }
420 } 420 }
(...skipping 30 matching lines...) Expand all
451 new RegExp('import "(.*)"'), 451 new RegExp('import "(.*)"'),
452 new RegExp("export '(.*)'"), 452 new RegExp("export '(.*)'"),
453 new RegExp('export "(.*)"'), 453 new RegExp('export "(.*)"'),
454 ]; 454 ];
455 for (S.ScriptLine line in script.lines) { 455 for (S.ScriptLine line in script.lines) {
456 for (var pattern in patterns) { 456 for (var pattern in patterns) {
457 var match = pattern.firstMatch(line.text); 457 var match = pattern.firstMatch(line.text);
458 if (match != null) { 458 if (match != null) {
459 M.Library target = resolveDependency(match[1]); 459 M.Library target = resolveDependency(match[1]);
460 if (target != null) { 460 if (target != null) {
461 var anno = new LibraryAnnotation(_isolate, _instances, _r.queue, 461 var anno = new LibraryAnnotation(_isolate, _objects, _r.queue,
462 target, Uris.inspect(isolate, object: target)); 462 target, Uris.inspect(isolate, object: target));
463 anno.line = line.line; 463 anno.line = line.line;
464 anno.columnStart = match.start + 8; 464 anno.columnStart = match.start + 8;
465 anno.columnStop = match.end - 1; 465 anno.columnStop = match.end - 1;
466 _annotations.add(anno); 466 _annotations.add(anno);
467 } 467 }
468 } 468 }
469 } 469 }
470 } 470 }
471 } 471 }
(...skipping 21 matching lines...) Expand all
493 var patterns = [ 493 var patterns = [
494 new RegExp("part '(.*)'"), 494 new RegExp("part '(.*)'"),
495 new RegExp('part "(.*)"'), 495 new RegExp('part "(.*)"'),
496 ]; 496 ];
497 for (S.ScriptLine line in script.lines) { 497 for (S.ScriptLine line in script.lines) {
498 for (var pattern in patterns) { 498 for (var pattern in patterns) {
499 var match = pattern.firstMatch(line.text); 499 var match = pattern.firstMatch(line.text);
500 if (match != null) { 500 if (match != null) {
501 S.Script part = resolvePart(match[1]); 501 S.Script part = resolvePart(match[1]);
502 if (part != null) { 502 if (part != null) {
503 var anno = new PartAnnotation(_isolate, _instances, _r.queue, part, 503 var anno = new PartAnnotation(_isolate, _objects, _r.queue, part,
504 Uris.inspect(isolate, object: part)); 504 Uris.inspect(isolate, object: part));
505 anno.line = line.line; 505 anno.line = line.line;
506 anno.columnStart = match.start + 6; 506 anno.columnStart = match.start + 6;
507 anno.columnStop = match.end - 1; 507 anno.columnStop = match.end - 1;
508 _annotations.add(anno); 508 _annotations.add(anno);
509 } 509 }
510 } 510 }
511 } 511 }
512 } 512 }
513 } 513 }
514 514
515 void addClassAnnotations() { 515 void addClassAnnotations() {
516 S.Script script = _loadedScript as S.Script; 516 S.Script script = _loadedScript as S.Script;
517 for (var cls in script.library.classes) { 517 for (var cls in script.library.classes) {
518 if ((cls.location != null) && (cls.location.script == script)) { 518 if ((cls.location != null) && (cls.location.script == script)) {
519 var a = new ClassDeclarationAnnotation(_isolate, _instances, _r.queue, 519 var a = new ClassDeclarationAnnotation(_isolate, _objects, _r.queue,
520 cls, Uris.inspect(isolate, object: cls)); 520 cls, Uris.inspect(isolate, object: cls));
521 _annotations.add(a); 521 _annotations.add(a);
522 } 522 }
523 } 523 }
524 } 524 }
525 525
526 void addFieldAnnotations() { 526 void addFieldAnnotations() {
527 S.Script script = _loadedScript as S.Script; 527 S.Script script = _loadedScript as S.Script;
528 for (var field in script.library.variables) { 528 for (var field in script.library.variables) {
529 if ((field.location != null) && (field.location.script == script)) { 529 if ((field.location != null) && (field.location.script == script)) {
530 var a = new FieldDeclarationAnnotation(_isolate, _instances, _r.queue, 530 var a = new FieldDeclarationAnnotation(_isolate, _objects, _r.queue,
531 field, Uris.inspect(isolate, object: field)); 531 field, Uris.inspect(isolate, object: field));
532 _annotations.add(a); 532 _annotations.add(a);
533 } 533 }
534 } 534 }
535 for (var cls in script.library.classes) { 535 for (var cls in script.library.classes) {
536 for (var field in cls.fields) { 536 for (var field in cls.fields) {
537 if ((field.location != null) && (field.location.script == script)) { 537 if ((field.location != null) && (field.location.script == script)) {
538 var a = new FieldDeclarationAnnotation(_isolate, _instances, _r.queue, 538 var a = new FieldDeclarationAnnotation(_isolate, _objects, _r.queue,
539 field, Uris.inspect(isolate, object: field)); 539 field, Uris.inspect(isolate, object: field));
540 _annotations.add(a); 540 _annotations.add(a);
541 } 541 }
542 } 542 }
543 } 543 }
544 } 544 }
545 545
546 void addFunctionAnnotations() { 546 void addFunctionAnnotations() {
547 S.Script script = _loadedScript as S.Script; 547 S.Script script = _loadedScript as S.Script;
548 for (var func in script.library.functions) { 548 for (var func in script.library.functions) {
549 if ((func.location != null) && 549 if ((func.location != null) &&
550 (func.location.script == script) && 550 (func.location.script == script) &&
551 (func.kind != M.FunctionKind.implicitGetter) && 551 (func.kind != M.FunctionKind.implicitGetter) &&
552 (func.kind != M.FunctionKind.implicitSetter)) { 552 (func.kind != M.FunctionKind.implicitSetter)) {
553 // We annotate a field declaration with the field instead of the 553 // We annotate a field declaration with the field instead of the
554 // implicit getter or setter. 554 // implicit getter or setter.
555 var a = new FunctionDeclarationAnnotation(_isolate, _instances, 555 var a = new FunctionDeclarationAnnotation(_isolate, _objects, _r.queue,
556 _r.queue, func, Uris.inspect(isolate, object: func)); 556 func, Uris.inspect(isolate, object: func));
557 _annotations.add(a); 557 _annotations.add(a);
558 } 558 }
559 } 559 }
560 for (var cls in script.library.classes) { 560 for (var cls in script.library.classes) {
561 S.Script script = _loadedScript as S.Script; 561 S.Script script = _loadedScript as S.Script;
562 for (var func in cls.functions) { 562 for (var func in cls.functions) {
563 if ((func.location != null) && 563 if ((func.location != null) &&
564 (func.location.script == script) && 564 (func.location.script == script) &&
565 (func.kind != M.FunctionKind.implicitGetter) && 565 (func.kind != M.FunctionKind.implicitGetter) &&
566 (func.kind != M.FunctionKind.implicitSetter)) { 566 (func.kind != M.FunctionKind.implicitSetter)) {
567 // We annotate a field declaration with the field instead of the 567 // We annotate a field declaration with the field instead of the
568 // implicit getter or setter. 568 // implicit getter or setter.
569 var a = new FunctionDeclarationAnnotation(_isolate, _instances, 569 var a = new FunctionDeclarationAnnotation(_isolate, _objects,
570 _r.queue, func, Uris.inspect(isolate, object: func)); 570 _r.queue, func, Uris.inspect(isolate, object: func));
571 _annotations.add(a); 571 _annotations.add(a);
572 } 572 }
573 } 573 }
574 } 574 }
575 } 575 }
576 576
577 void addCallSiteAnnotations() { 577 void addCallSiteAnnotations() {
578 for (var callSite in _callSites) { 578 for (var callSite in _callSites) {
579 _annotations.add( 579 _annotations
580 new CallSiteAnnotation(_isolate, _instances, _r.queue, callSite)); 580 .add(new CallSiteAnnotation(_isolate, _objects, _r.queue, callSite));
581 } 581 }
582 } 582 }
583 583
584 void addLocalVariableAnnotations() { 584 void addLocalVariableAnnotations() {
585 S.Script script = _loadedScript as S.Script; 585 S.Script script = _loadedScript as S.Script;
586 // We have local variable information. 586 // We have local variable information.
587 if (_variables != null) { 587 if (_variables != null) {
588 // For each variable. 588 // For each variable.
589 for (var variable in _variables) { 589 for (var variable in _variables) {
590 // Find variable usage locations. 590 // Find variable usage locations.
591 var locations = script.scanForLocalVariableLocations( 591 var locations = script.scanForLocalVariableLocations(
592 variable['name'], variable['_tokenPos'], variable['_endTokenPos']); 592 variable['name'], variable['_tokenPos'], variable['_endTokenPos']);
593 593
594 // Annotate locations. 594 // Annotate locations.
595 for (var location in locations) { 595 for (var location in locations) {
596 _annotations.add(new LocalVariableAnnotation( 596 _annotations.add(new LocalVariableAnnotation(
597 _isolate, _instances, _r.queue, location, variable['value'])); 597 _isolate, _objects, _r.queue, location, variable['value']));
598 } 598 }
599 } 599 }
600 } 600 }
601 } 601 }
602 602
603 ButtonElement _newRefreshButton() { 603 ButtonElement _newRefreshButton() {
604 var button = new ButtonElement(); 604 var button = new ButtonElement();
605 button.classes = ['refresh']; 605 button.classes = ['refresh'];
606 button.onClick.listen((_) async { 606 button.onClick.listen((_) async {
607 button.disabled = true; 607 button.disabled = true;
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 void addLink(Element content, String target) { 984 void addLink(Element content, String target) {
985 // Ick, destructive but still compatible with also adding an info box. 985 // Ick, destructive but still compatible with also adding an info box.
986 var a = new AnchorElement(href: target); 986 var a = new AnchorElement(href: target);
987 a.text = content.text; 987 a.text = content.text;
988 content.text = ''; 988 content.text = '';
989 content.append(a); 989 content.append(a);
990 } 990 }
991 991
992 abstract class Annotation implements Comparable<Annotation> { 992 abstract class Annotation implements Comparable<Annotation> {
993 M.IsolateRef _isolate; 993 M.IsolateRef _isolate;
994 M.InstanceRepository _instances; 994 M.ObjectRepository _objects;
995 RenderingQueue queue; 995 RenderingQueue queue;
996 int line; 996 int line;
997 int columnStart; 997 int columnStart;
998 int columnStop; 998 int columnStop;
999 int get priority; 999 int get priority;
1000 1000
1001 Annotation(this._isolate, this._instances, this.queue); 1001 Annotation(this._isolate, this._objects, this.queue);
1002 1002
1003 void applyStyleTo(element); 1003 void applyStyleTo(element);
1004 1004
1005 int compareTo(Annotation other) { 1005 int compareTo(Annotation other) {
1006 if (line == other.line) { 1006 if (line == other.line) {
1007 if (columnStart == other.columnStart) { 1007 if (columnStart == other.columnStart) {
1008 return priority.compareTo(other.priority); 1008 return priority.compareTo(other.priority);
1009 } 1009 }
1010 return columnStart.compareTo(other.columnStart); 1010 return columnStart.compareTo(other.columnStart);
1011 } 1011 }
(...skipping 19 matching lines...) Expand all
1031 Element cell(content) { 1031 Element cell(content) {
1032 var e = new DivElement(); 1032 var e = new DivElement();
1033 e.style.display = "table-cell"; 1033 e.style.display = "table-cell";
1034 e.style.padding = "3px"; 1034 e.style.padding = "3px";
1035 if (content is String) e.text = content; 1035 if (content is String) e.text = content;
1036 if (content is Element) e.children.add(content); 1036 if (content is Element) e.children.add(content);
1037 return e; 1037 return e;
1038 } 1038 }
1039 1039
1040 Element serviceRef(object) { 1040 Element serviceRef(object) {
1041 return anyRef(_isolate, object, _instances, queue: queue); 1041 return anyRef(_isolate, object, _objects, queue: queue);
1042 } 1042 }
1043 } 1043 }
1044 1044
1045 class CurrentExecutionAnnotation extends Annotation { 1045 class CurrentExecutionAnnotation extends Annotation {
1046 int priority = 0; // highest priority. 1046 int priority = 0; // highest priority.
1047 1047
1048 CurrentExecutionAnnotation(M.IsolateRef isolate, 1048 CurrentExecutionAnnotation(
1049 M.InstanceRepository instances, RenderingQueue queue) 1049 M.IsolateRef isolate, M.ObjectRepository objects, RenderingQueue queue)
1050 : super(isolate, instances, queue); 1050 : super(isolate, objects, queue);
1051 1051
1052 void applyStyleTo(element) { 1052 void applyStyleTo(element) {
1053 if (element == null) { 1053 if (element == null) {
1054 return; // TODO(rmacnak): Handling overlapping annotations. 1054 return; // TODO(rmacnak): Handling overlapping annotations.
1055 } 1055 }
1056 element.classes.add("currentCol"); 1056 element.classes.add("currentCol");
1057 element.title = "Current execution"; 1057 element.title = "Current execution";
1058 } 1058 }
1059 } 1059 }
1060 1060
1061 class BreakpointAnnotation extends Annotation { 1061 class BreakpointAnnotation extends Annotation {
1062 M.Breakpoint bpt; 1062 M.Breakpoint bpt;
1063 int priority = 1; 1063 int priority = 1;
1064 1064
1065 BreakpointAnnotation(M.IsolateRef isolate, M.InstanceRepository instances, 1065 BreakpointAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1066 RenderingQueue queue, this.bpt) 1066 RenderingQueue queue, this.bpt)
1067 : super(isolate, instances, queue) { 1067 : super(isolate, objects, queue) {
1068 var script = bpt.location.script; 1068 var script = bpt.location.script;
1069 var location = bpt.location; 1069 var location = bpt.location;
1070 if (location.tokenPos != null) { 1070 if (location.tokenPos != null) {
1071 var pos = location.tokenPos; 1071 var pos = location.tokenPos;
1072 line = script.tokenToLine(pos); 1072 line = script.tokenToLine(pos);
1073 columnStart = script.tokenToCol(pos) - 1; // tokenToCol is 1-origin. 1073 columnStart = script.tokenToCol(pos) - 1; // tokenToCol is 1-origin.
1074 } else if (location is M.UnresolvedSourceLocation) { 1074 } else if (location is M.UnresolvedSourceLocation) {
1075 line = location.line; 1075 line = location.line;
1076 columnStart = location.column; 1076 columnStart = location.column;
1077 if (columnStart == null) { 1077 if (columnStart == null) {
(...skipping 22 matching lines...) Expand all
1100 } 1100 }
1101 element.title = "Breakpoint ${bpt.number} at ${line}:${column}"; 1101 element.title = "Breakpoint ${bpt.number} at ${line}:${column}";
1102 } 1102 }
1103 } 1103 }
1104 1104
1105 class LibraryAnnotation extends Annotation { 1105 class LibraryAnnotation extends Annotation {
1106 S.Library target; 1106 S.Library target;
1107 String url; 1107 String url;
1108 int priority = 2; 1108 int priority = 2;
1109 1109
1110 LibraryAnnotation(M.IsolateRef isolate, M.InstanceRepository instances, 1110 LibraryAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1111 RenderingQueue queue, this.target, this.url) 1111 RenderingQueue queue, this.target, this.url)
1112 : super(isolate, instances, queue); 1112 : super(isolate, objects, queue);
1113 1113
1114 void applyStyleTo(element) { 1114 void applyStyleTo(element) {
1115 if (element == null) { 1115 if (element == null) {
1116 return; // TODO(rmacnak): Handling overlapping annotations. 1116 return; // TODO(rmacnak): Handling overlapping annotations.
1117 } 1117 }
1118 element.title = "library ${target.uri}"; 1118 element.title = "library ${target.uri}";
1119 addLink(element, url); 1119 addLink(element, url);
1120 } 1120 }
1121 } 1121 }
1122 1122
1123 class PartAnnotation extends Annotation { 1123 class PartAnnotation extends Annotation {
1124 S.Script part; 1124 S.Script part;
1125 String url; 1125 String url;
1126 int priority = 2; 1126 int priority = 2;
1127 1127
1128 PartAnnotation(M.IsolateRef isolate, M.InstanceRepository instances, 1128 PartAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1129 RenderingQueue queue, this.part, this.url) 1129 RenderingQueue queue, this.part, this.url)
1130 : super(isolate, instances, queue); 1130 : super(isolate, objects, queue);
1131 1131
1132 void applyStyleTo(element) { 1132 void applyStyleTo(element) {
1133 if (element == null) { 1133 if (element == null) {
1134 return; // TODO(rmacnak): Handling overlapping annotations. 1134 return; // TODO(rmacnak): Handling overlapping annotations.
1135 } 1135 }
1136 element.title = "script ${part.uri}"; 1136 element.title = "script ${part.uri}";
1137 addLink(element, url); 1137 addLink(element, url);
1138 } 1138 }
1139 } 1139 }
1140 1140
1141 class LocalVariableAnnotation extends Annotation { 1141 class LocalVariableAnnotation extends Annotation {
1142 final value; 1142 final value;
1143 int priority = 2; 1143 int priority = 2;
1144 1144
1145 LocalVariableAnnotation(M.IsolateRef isolate, M.InstanceRepository instances, 1145 LocalVariableAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1146 RenderingQueue queue, S.LocalVarLocation location, this.value) 1146 RenderingQueue queue, S.LocalVarLocation location, this.value)
1147 : super(isolate, instances, queue) { 1147 : super(isolate, objects, queue) {
1148 line = location.line; 1148 line = location.line;
1149 columnStart = location.column; 1149 columnStart = location.column;
1150 columnStop = location.endColumn; 1150 columnStop = location.endColumn;
1151 } 1151 }
1152 1152
1153 void applyStyleTo(element) { 1153 void applyStyleTo(element) {
1154 if (element == null) { 1154 if (element == null) {
1155 return; // TODO(rmacnak): Handling overlapping annotations. 1155 return; // TODO(rmacnak): Handling overlapping annotations.
1156 } 1156 }
1157 element.style.fontWeight = "bold"; 1157 element.style.fontWeight = "bold";
1158 element.title = "${value.shortName}"; 1158 element.title = "${value.shortName}";
1159 } 1159 }
1160 } 1160 }
1161 1161
1162 class CallSiteAnnotation extends Annotation { 1162 class CallSiteAnnotation extends Annotation {
1163 S.CallSite callSite; 1163 S.CallSite callSite;
1164 int priority = 2; 1164 int priority = 2;
1165 1165
1166 CallSiteAnnotation(M.IsolateRef isolate, M.InstanceRepository instances, 1166 CallSiteAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1167 RenderingQueue queue, this.callSite) 1167 RenderingQueue queue, this.callSite)
1168 : super(isolate, instances, queue) { 1168 : super(isolate, objects, queue) {
1169 line = callSite.line; 1169 line = callSite.line;
1170 columnStart = callSite.column - 1; // Call site is 1-origin. 1170 columnStart = callSite.column - 1; // Call site is 1-origin.
1171 var tokenLength = callSite.script.guessTokenLength(line, columnStart); 1171 var tokenLength = callSite.script.guessTokenLength(line, columnStart);
1172 if (tokenLength == null) { 1172 if (tokenLength == null) {
1173 tokenLength = callSite.name.length; // Approximate. 1173 tokenLength = callSite.name.length; // Approximate.
1174 if (callSite.name.startsWith("get:") || callSite.name.startsWith("set:")) 1174 if (callSite.name.startsWith("get:") || callSite.name.startsWith("set:"))
1175 tokenLength -= 4; 1175 tokenLength -= 4;
1176 } 1176 }
1177 columnStop = columnStart + tokenLength; 1177 columnStop = columnStart + tokenLength;
1178 } 1178 }
(...skipping 30 matching lines...) Expand all
1209 } 1209 }
1210 return details; 1210 return details;
1211 }); 1211 });
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 abstract class DeclarationAnnotation extends Annotation { 1215 abstract class DeclarationAnnotation extends Annotation {
1216 String url; 1216 String url;
1217 int priority = 2; 1217 int priority = 2;
1218 1218
1219 DeclarationAnnotation(M.IsolateRef isolate, M.InstanceRepository instances, 1219 DeclarationAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1220 RenderingQueue queue, decl, this.url) 1220 RenderingQueue queue, decl, this.url)
1221 : super(isolate, instances, queue) { 1221 : super(isolate, objects, queue) {
1222 assert(decl.loaded); 1222 assert(decl.loaded);
1223 S.SourceLocation location = decl.location; 1223 S.SourceLocation location = decl.location;
1224 if (location == null) { 1224 if (location == null) {
1225 line = 0; 1225 line = 0;
1226 columnStart = 0; 1226 columnStart = 0;
1227 columnStop = 0; 1227 columnStop = 0;
1228 return; 1228 return;
1229 } 1229 }
1230 1230
1231 S.Script script = location.script; 1231 S.Script script = location.script;
(...skipping 16 matching lines...) Expand all
1248 columnStart = betterStart; 1248 columnStart = betterStart;
1249 } 1249 }
1250 columnStop = columnStart + decl.name.length; 1250 columnStop = columnStart + decl.name.length;
1251 } 1251 }
1252 } 1252 }
1253 } 1253 }
1254 1254
1255 class ClassDeclarationAnnotation extends DeclarationAnnotation { 1255 class ClassDeclarationAnnotation extends DeclarationAnnotation {
1256 S.Class klass; 1256 S.Class klass;
1257 1257
1258 ClassDeclarationAnnotation( 1258 ClassDeclarationAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1259 M.IsolateRef isolate, 1259 RenderingQueue queue, S.Class cls, String url)
1260 M.InstanceRepository instances,
1261 RenderingQueue queue,
1262 S.Class cls,
1263 String url)
1264 : klass = cls, 1260 : klass = cls,
1265 super(isolate, instances, queue, cls, url); 1261 super(isolate, objects, queue, cls, url);
1266 1262
1267 void applyStyleTo(element) { 1263 void applyStyleTo(element) {
1268 if (element == null) { 1264 if (element == null) {
1269 return; // TODO(rmacnak): Handling overlapping annotations. 1265 return; // TODO(rmacnak): Handling overlapping annotations.
1270 } 1266 }
1271 element.title = "class ${klass.name}"; 1267 element.title = "class ${klass.name}";
1272 addLink(element, url); 1268 addLink(element, url);
1273 } 1269 }
1274 } 1270 }
1275 1271
1276 class FieldDeclarationAnnotation extends DeclarationAnnotation { 1272 class FieldDeclarationAnnotation extends DeclarationAnnotation {
1277 S.Field field; 1273 S.Field field;
1278 1274
1279 FieldDeclarationAnnotation( 1275 FieldDeclarationAnnotation(M.IsolateRef isolate, M.ObjectRepository objects,
1280 M.IsolateRef isolate, 1276 RenderingQueue queue, S.Field fld, String url)
1281 M.InstanceRepository instances,
1282 RenderingQueue queue,
1283 S.Field fld,
1284 String url)
1285 : field = fld, 1277 : field = fld,
1286 super(isolate, instances, queue, fld, url); 1278 super(isolate, objects, queue, fld, url);
1287 1279
1288 void applyStyleTo(element) { 1280 void applyStyleTo(element) {
1289 if (element == null) { 1281 if (element == null) {
1290 return; // TODO(rmacnak): Handling overlapping annotations. 1282 return; // TODO(rmacnak): Handling overlapping annotations.
1291 } 1283 }
1292 var tooltip = "field ${field.name}"; 1284 var tooltip = "field ${field.name}";
1293 element.title = tooltip; 1285 element.title = tooltip;
1294 addLink(element, url); 1286 addLink(element, url);
1295 } 1287 }
1296 } 1288 }
1297 1289
1298 class FunctionDeclarationAnnotation extends DeclarationAnnotation { 1290 class FunctionDeclarationAnnotation extends DeclarationAnnotation {
1299 S.ServiceFunction function; 1291 S.ServiceFunction function;
1300 1292
1301 FunctionDeclarationAnnotation( 1293 FunctionDeclarationAnnotation(
1302 M.IsolateRef isolate, 1294 M.IsolateRef isolate,
1303 M.InstanceRepository instances, 1295 M.ObjectRepository objects,
1304 RenderingQueue queue, 1296 RenderingQueue queue,
1305 S.ServiceFunction func, 1297 S.ServiceFunction func,
1306 String url) 1298 String url)
1307 : function = func, 1299 : function = func,
1308 super(isolate, instances, queue, func, url); 1300 super(isolate, objects, queue, func, url);
1309 1301
1310 void applyStyleTo(element) { 1302 void applyStyleTo(element) {
1311 if (element == null) { 1303 if (element == null) {
1312 return; // TODO(rmacnak): Handling overlapping annotations. 1304 return; // TODO(rmacnak): Handling overlapping annotations.
1313 } 1305 }
1314 var tooltip = "method ${function.name}"; 1306 var tooltip = "method ${function.name}";
1315 if (function.isOptimizable == false) { 1307 if (function.isOptimizable == false) {
1316 tooltip += "\nUnoptimizable!"; 1308 tooltip += "\nUnoptimizable!";
1317 } 1309 }
1318 if (function.isInlinable == false) { 1310 if (function.isInlinable == false) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 ..setAttribute( 1387 ..setAttribute(
1396 'd', 1388 'd',
1397 'M13.5.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 ' 1389 'M13.5.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 '
1398 '3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 ' 1390 '3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 '
1399 '4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 ' 1391 '4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 '
1400 '17.41 3.8 13.5.67zM11.71 19c-1.78 ' 1392 '17.41 3.8 13.5.67zM11.71 19c-1.78 '
1401 '0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 ' 1393 '0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 '
1402 '1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 ' 1394 '1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 '
1403 '4.04 0 2.65-2.15 4.8-4.8 4.8z') 1395 '4.04 0 2.65-2.15 4.8-4.8 4.8z')
1404 ]; 1396 ];
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/retaining_path.dart ('k') | runtime/observatory/lib/src/elements/script_view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698