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

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

Issue 1590353002: Only show breakpoints at possible breakpoint positions in Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix tests Created 4 years, 11 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:math'; 9 import 'dart:math';
10 import 'observatory_element.dart'; 10 import 'observatory_element.dart';
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 @published Element scroller; 379 @published Element scroller;
380 RefreshButtonElement _refreshButton; 380 RefreshButtonElement _refreshButton;
381 381
382 int _currentLine; 382 int _currentLine;
383 int _currentCol; 383 int _currentCol;
384 int _startLine; 384 int _startLine;
385 int _endLine; 385 int _endLine;
386 386
387 Map<int, List<ServiceMap>> _rangeMap = {}; 387 Map<int, List<ServiceMap>> _rangeMap = {};
388 Set _callSites = new Set<CallSite>(); 388 Set _callSites = new Set<CallSite>();
389 Set _possibleBreakpointLines = new Set<int>();
389 390
390 var annotations = []; 391 var annotations = [];
391 var annotationsCursor; 392 var annotationsCursor;
392 393
393 StreamSubscription _scriptChangeSubscription; 394 StreamSubscription _scriptChangeSubscription;
394 Future<StreamSubscription> _debugSubscriptionFuture; 395 Future<StreamSubscription> _debugSubscriptionFuture;
395 StreamSubscription _scrollSubscription; 396 StreamSubscription _scrollSubscription;
396 397
397 bool hasLoadedLibraryDeclarations = false; 398 bool hasLoadedLibraryDeclarations = false;
398 399
(...skipping 28 matching lines...) Expand all
427 } 428 }
428 if (_scriptChangeSubscription != null) { 429 if (_scriptChangeSubscription != null) {
429 // Don't leak. If only Dart and Javascript exposed weak references... 430 // Don't leak. If only Dart and Javascript exposed weak references...
430 _scriptChangeSubscription.cancel(); 431 _scriptChangeSubscription.cancel();
431 _scriptChangeSubscription = null; 432 _scriptChangeSubscription = null;
432 } 433 }
433 super.detached(); 434 super.detached();
434 } 435 }
435 436
436 void _onScroll(event) { 437 void _onScroll(event) {
438 if (_refreshButton == null) {
439 return;
440 }
437 var currentTop = _refreshButton.style.top; 441 var currentTop = _refreshButton.style.top;
438 var newTop = _refreshButtonTop(); 442 var newTop = _refreshButtonTop();
439 if (currentTop != newTop) { 443 if (currentTop != newTop) {
440 _refreshButton.style.top = '${newTop}px'; 444 _refreshButton.style.top = '${newTop}px';
441 } 445 }
442 } 446 }
443 447
444 void _onDebugEvent(event) { 448 void _onDebugEvent(event) {
445 if (script == null) { 449 if (script == null) {
446 return; 450 return;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 529
526 Element container; 530 Element container;
527 531
528 Future _refresh() async { 532 Future _refresh() async {
529 await update(); 533 await update();
530 } 534 }
531 535
532 // Build _rangeMap and _callSites from a source report. 536 // Build _rangeMap and _callSites from a source report.
533 Future _refreshSourceReport() async { 537 Future _refreshSourceReport() async {
534 var sourceReport = await script.isolate.getSourceReport( 538 var sourceReport = await script.isolate.getSourceReport(
535 [Isolate.kCallSitesReport], script, startPos, endPos); 539 [Isolate.kCallSitesReport, Isolate.kPossibleBreakpointsReport],
540 script, startPos, endPos);
541 _possibleBreakpointLines = getPossibleBreakpointLines(sourceReport, script);
536 _rangeMap.clear(); 542 _rangeMap.clear();
537 _callSites.clear(); 543 _callSites.clear();
538 for (var range in sourceReport['ranges']) { 544 for (var range in sourceReport['ranges']) {
539 int startLine = script.tokenToLine(range['startPos']); 545 int startLine = script.tokenToLine(range['startPos']);
540 int endLine = script.tokenToLine(range['endPos']); 546 int endLine = script.tokenToLine(range['endPos']);
541 for (var line = startLine; line <= endLine; line++) { 547 for (var line = startLine; line <= endLine; line++) {
542 var rangeList = _rangeMap[line]; 548 var rangeList = _rangeMap[line];
543 if (rangeList == null) { 549 if (rangeList == null) {
544 _rangeMap[line] = [range]; 550 _rangeMap[line] = [range];
545 } else { 551 } else {
546 rangeList.add(range); 552 rangeList.add(range);
547 } 553 }
548 } 554 }
549 var rangeCallSites = range['callSites']; 555 if (range['compiled']) {
550 if (rangeCallSites != null) { 556 var rangeCallSites = range['callSites'];
551 for (var callSiteMap in rangeCallSites) { 557 if (rangeCallSites != null) {
552 _callSites.add(new CallSite.fromMap(callSiteMap, script)); 558 for (var callSiteMap in rangeCallSites) {
559 _callSites.add(new CallSite.fromMap(callSiteMap, script));
560 }
553 } 561 }
554 } 562 }
555 } 563 }
556 } 564 }
557 565
558 Task _updateTask; 566 Task _updateTask;
559 Future update() async { 567 Future update() async {
560 assert(_updateTask != null); 568 assert(_updateTask != null);
561 if (script == null) { 569 if (script == null) {
562 // We may have previously had a script. 570 // We may have previously had a script.
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 var e = new DivElement(); 995 var e = new DivElement();
988 e.classes.add("sourceRow"); 996 e.classes.add("sourceRow");
989 e.append(lineBreakpointElement(line)); 997 e.append(lineBreakpointElement(line));
990 e.append(lineNumberElement(line, lineNumPad)); 998 e.append(lineNumberElement(line, lineNumPad));
991 e.append(lineSourceElement(line)); 999 e.append(lineSourceElement(line));
992 return e; 1000 return e;
993 } 1001 }
994 1002
995 Element lineBreakpointElement(ScriptLine line) { 1003 Element lineBreakpointElement(ScriptLine line) {
996 var e = new DivElement(); 1004 var e = new DivElement();
997 var busy = false; 1005 if (line == null || !_possibleBreakpointLines.contains(line.line)) {
998 if (line == null || !line.possibleBpt) { 1006 e.classes.add('noCopy');
999 e.classes.add("emptyBreakpoint"); 1007 e.classes.add("emptyBreakpoint");
1000 e.classes.add('noCopy');
1001 e.text = nbsp; 1008 e.text = nbsp;
1002 return e; 1009 return e;
1003 } 1010 }
1011
1004 e.text = 'B'; 1012 e.text = 'B';
1005 update() { 1013 var busy = false;
1014 void update() {
1006 e.classes.clear(); 1015 e.classes.clear();
1007 e.classes.add('noCopy'); 1016 e.classes.add('noCopy');
1008 1017 if (busy) {
1009 if (!line.possibleBpt) {
1010 e.classes.add("emptyBreakpoint");
1011 e.text = nbsp;
1012 } else if (busy) {
1013 e.classes.add("busyBreakpoint"); 1018 e.classes.add("busyBreakpoint");
1019 } else if (line.breakpoints != null) {
1020 bool resolved = false;
1021 for (var bpt in line.breakpoints) {
1022 if (bpt.resolved) {
1023 resolved = true;
1024 break;
1025 }
1026 }
1027 if (resolved) {
1028 e.classes.add("resolvedBreakpoint");
1029 } else {
1030 e.classes.add("unresolvedBreakpoint");
1031 }
1014 } else { 1032 } else {
1015 if (line.breakpoints != null) { 1033 e.classes.add("possibleBreakpoint");
1016 if (line.breakpointResolved) {
1017 e.classes.add("resolvedBreakpoint");
1018 } else {
1019 e.classes.add("unresolvedBreakpoint");
1020 }
1021 } else {
1022 e.classes.add("possibleBreakpoint");
1023 }
1024 } 1034 }
1025 } 1035 }
1036
1026 line.changes.listen((_) => update()); 1037 line.changes.listen((_) => update());
1027 e.onClick.listen((event) { 1038 e.onClick.listen((event) {
1028 if (busy) { 1039 if (busy) {
1029 return; 1040 return;
1030 } 1041 }
1031 busy = true; 1042 busy = true;
1032 if (line.breakpoints == null) { 1043 if (line.breakpoints == null) {
1033 // No breakpoint. Add it. 1044 // No breakpoint. Add it.
1034 line.script.isolate.addBreakpoint(line.script, line.line) 1045 line.script.isolate.addBreakpoint(line.script, line.line)
1035 .catchError((e, st) { 1046 .catchError((e, st) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 class SourceInsetElement extends PolymerElement { 1192 class SourceInsetElement extends PolymerElement {
1182 SourceInsetElement.created() : super.created(); 1193 SourceInsetElement.created() : super.created();
1183 1194
1184 @published SourceLocation location; 1195 @published SourceLocation location;
1185 @published String height = null; 1196 @published String height = null;
1186 @published int currentPos; 1197 @published int currentPos;
1187 @published bool inDebuggerContext = false; 1198 @published bool inDebuggerContext = false;
1188 @published ObservableList variables; 1199 @published ObservableList variables;
1189 @published Element scroller; 1200 @published Element scroller;
1190 } 1201 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/debugger/debugger_location.dart ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698