| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 * @param {!Workspace.UILocation} uiLocation | 546 * @param {!Workspace.UILocation} uiLocation |
| 547 */ | 547 */ |
| 548 setExecutionLocation(uiLocation) { | 548 setExecutionLocation(uiLocation) { |
| 549 this._executionLocation = uiLocation; | 549 this._executionLocation = uiLocation; |
| 550 if (!this.loaded) | 550 if (!this.loaded) |
| 551 return; | 551 return; |
| 552 | 552 |
| 553 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum
nNumber); | 553 this.textEditor.setExecutionLocation(uiLocation.lineNumber, uiLocation.colum
nNumber); |
| 554 if (this.isShowing()) { | 554 if (this.isShowing()) { |
| 555 // We need SourcesTextEditor to be initialized prior to this call. @see cr
bug.com/506566 | 555 // We need SourcesTextEditor to be initialized prior to this call. @see cr
bug.com/506566 |
| 556 setImmediate(this._generateValuesInSource.bind(this)); | 556 setImmediate(() => { |
| 557 this._generateValuesInSource(); |
| 558 if (Runtime.experiments.isEnabled('continueToLocationMarkers')) |
| 559 this._showContinueToLocations(); |
| 560 }); |
| 557 } | 561 } |
| 558 } | 562 } |
| 559 | 563 |
| 560 _generateValuesInSource() { | 564 _generateValuesInSource() { |
| 561 if (!Common.moduleSetting('inlineVariableValues').get()) | 565 if (!Common.moduleSetting('inlineVariableValues').get()) |
| 562 return; | 566 return; |
| 563 var executionContext = UI.context.flavor(SDK.ExecutionContext); | 567 var executionContext = UI.context.flavor(SDK.ExecutionContext); |
| 564 if (!executionContext) | 568 if (!executionContext) |
| 565 return; | 569 return; |
| 566 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); | 570 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); |
| 567 if (!callFrame) | 571 if (!callFrame) |
| 568 return; | 572 return; |
| 569 | 573 |
| 570 var localScope = callFrame.localScope(); | 574 var localScope = callFrame.localScope(); |
| 571 var functionLocation = callFrame.functionLocation(); | 575 var functionLocation = callFrame.functionLocation(); |
| 572 if (localScope && functionLocation) { | 576 if (localScope && functionLocation) { |
| 573 Sources.SourceMapNamesResolver.resolveScopeInObject(localScope) | 577 Sources.SourceMapNamesResolver.resolveScopeInObject(localScope) |
| 574 .getAllProperties(false, false, this._prepareScopeVariables.bind(this,
callFrame)); | 578 .getAllProperties(false, false, this._prepareScopeVariables.bind(this,
callFrame)); |
| 575 } | 579 } |
| 576 | 580 |
| 577 if (this._clearValueWidgetsTimer) { | 581 if (this._clearValueWidgetsTimer) { |
| 578 clearTimeout(this._clearValueWidgetsTimer); | 582 clearTimeout(this._clearValueWidgetsTimer); |
| 579 delete this._clearValueWidgetsTimer; | 583 delete this._clearValueWidgetsTimer; |
| 580 } | 584 } |
| 581 } | 585 } |
| 582 | 586 |
| 587 _showContinueToLocations() { |
| 588 var executionContext = UI.context.flavor(SDK.ExecutionContext); |
| 589 if (!executionContext) |
| 590 return; |
| 591 var callFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame); |
| 592 if (!callFrame) |
| 593 return; |
| 594 var localScope = callFrame.localScope(); |
| 595 if (!localScope) |
| 596 return; |
| 597 var start = localScope.startLocation(); |
| 598 var end = localScope.endLocation(); |
| 599 var debuggerModel = callFrame.debuggerModel; |
| 600 debuggerModel.getPossibleBreakpoints(start, end, true) |
| 601 .then(locations => this.textEditor.operation(renderLocations.bind(this,
locations))); |
| 602 |
| 603 if (this._clearContinueToLocationsTimer) { |
| 604 clearTimeout(this._clearContinueToLocationsTimer); |
| 605 delete this._clearContinueToLocationsTimer; |
| 606 } |
| 607 |
| 608 /** |
| 609 * @param {!Array<!SDK.DebuggerModel.Location>} locations |
| 610 * @this {Sources.JavaScriptSourceFrame} |
| 611 */ |
| 612 function renderLocations(locations) { |
| 613 var bookmarks = this.textEditor.bookmarks( |
| 614 this.textEditor.fullRange(), Sources.JavaScriptSourceFrame.continueToL
ocationDecorationSymbol); |
| 615 bookmarks.map(bookmark => bookmark.clear()); |
| 616 |
| 617 for (var location of locations) { |
| 618 var icon = UI.Icon.create('smallicon-green-ball'); |
| 619 icon.classList.add('cm-continue-to-location'); |
| 620 icon.addEventListener('click', location.continueToLocation.bind(location
)); |
| 621 icon.addEventListener('mousemove', hidePopoverAndConsumeEvent.bind(this)
); |
| 622 this.textEditor.addBookmark( |
| 623 location.lineNumber, location.columnNumber, icon, |
| 624 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol); |
| 625 } |
| 626 } |
| 627 |
| 628 /** |
| 629 * @param {!Event} event |
| 630 * @this {Sources.JavaScriptSourceFrame} |
| 631 */ |
| 632 function hidePopoverAndConsumeEvent(event) { |
| 633 event.consume(true); |
| 634 this._popoverHelper.hidePopover(); |
| 635 } |
| 636 } |
| 637 |
| 583 /** | 638 /** |
| 584 * @param {!SDK.DebuggerModel.CallFrame} callFrame | 639 * @param {!SDK.DebuggerModel.CallFrame} callFrame |
| 585 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 640 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 586 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 641 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 587 */ | 642 */ |
| 588 _prepareScopeVariables(callFrame, properties, internalProperties) { | 643 _prepareScopeVariables(callFrame, properties, internalProperties) { |
| 589 if (!properties || !properties.length || properties.length > 500 || !this.is
Showing()) { | 644 if (!properties || !properties.length || properties.length > 500 || !this.is
Showing()) { |
| 590 this._clearValueWidgets(); | 645 this._clearValueWidgets(); |
| 591 return; | 646 return; |
| 592 } | 647 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 this.textEditor.addDecoration(widget, i); | 776 this.textEditor.addDecoration(widget, i); |
| 722 } | 777 } |
| 723 } | 778 } |
| 724 } | 779 } |
| 725 | 780 |
| 726 clearExecutionLine() { | 781 clearExecutionLine() { |
| 727 if (this.loaded && this._executionLocation) | 782 if (this.loaded && this._executionLocation) |
| 728 this.textEditor.clearExecutionLine(); | 783 this.textEditor.clearExecutionLine(); |
| 729 delete this._executionLocation; | 784 delete this._executionLocation; |
| 730 this._clearValueWidgetsTimer = setTimeout(this._clearValueWidgets.bind(this)
, 1000); | 785 this._clearValueWidgetsTimer = setTimeout(this._clearValueWidgets.bind(this)
, 1000); |
| 786 if (Runtime.experiments.isEnabled('continueToLocationMarkers')) |
| 787 this._clearContinueToLocationsTimer = setTimeout(this._clearContinueToLoca
tions.bind(this), 1000); |
| 731 } | 788 } |
| 732 | 789 |
| 733 _clearValueWidgets() { | 790 _clearValueWidgets() { |
| 734 delete this._clearValueWidgetsTimer; | 791 delete this._clearValueWidgetsTimer; |
| 735 for (var line of this._valueWidgets.keys()) | 792 for (var line of this._valueWidgets.keys()) |
| 736 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); | 793 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); |
| 737 this._valueWidgets.clear(); | 794 this._valueWidgets.clear(); |
| 738 } | 795 } |
| 739 | 796 |
| 797 _clearContinueToLocations() { |
| 798 delete this._clearContinueToLocationsTimer; |
| 799 var bookmarks = this.textEditor.bookmarks( |
| 800 this.textEditor.fullRange(), Sources.JavaScriptSourceFrame.continueToLoc
ationDecorationSymbol); |
| 801 this.textEditor.operation(() => bookmarks.map(bookmark => bookmark.clear()))
; |
| 802 } |
| 803 |
| 740 /** | 804 /** |
| 741 * @param {number} lineNumber | 805 * @param {number} lineNumber |
| 742 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} | 806 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} |
| 743 */ | 807 */ |
| 744 _lineBreakpointDecorations(lineNumber) { | 808 _lineBreakpointDecorations(lineNumber) { |
| 745 return Array.from(this._breakpointDecorations) | 809 return Array.from(this._breakpointDecorations) |
| 746 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber ===
lineNumber); | 810 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber ===
lineNumber); |
| 747 } | 811 } |
| 748 | 812 |
| 749 /** | 813 /** |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 hide() { | 1439 hide() { |
| 1376 if (!this.bookmark) | 1440 if (!this.bookmark) |
| 1377 return; | 1441 return; |
| 1378 this.bookmark.clear(); | 1442 this.bookmark.clear(); |
| 1379 this.bookmark = null; | 1443 this.bookmark = null; |
| 1380 } | 1444 } |
| 1381 }; | 1445 }; |
| 1382 | 1446 |
| 1383 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book
mark'); | 1447 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book
mark'); |
| 1384 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo
l('element'); | 1448 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo
l('element'); |
| 1449 |
| 1450 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm
ark'); |
| OLD | NEW |