Chromium Code Reviews| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 this.uiSourceCode().addEventListener( | 61 this.uiSourceCode().addEventListener( |
| 62 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin gChanged, this); | 62 Workspace.UISourceCode.Events.SourceMappingChanged, this._onSourceMappin gChanged, this); |
| 63 this.uiSourceCode().addEventListener( | 63 this.uiSourceCode().addEventListener( |
| 64 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); | 64 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); |
| 65 this.uiSourceCode().addEventListener( | 65 this.uiSourceCode().addEventListener( |
| 66 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); | 66 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); |
| 67 this.uiSourceCode().addEventListener( | 67 this.uiSourceCode().addEventListener( |
| 68 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); | 68 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); |
| 69 | 69 |
| 70 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ | |
| 71 this._breakpointDecorations = new Set(); | |
| 72 | |
| 70 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ | 73 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ |
| 71 this._scriptFileForTarget = new Map(); | 74 this._scriptFileForTarget = new Map(); |
| 72 var targets = SDK.targetManager.targets(); | 75 var targets = SDK.targetManager.targets(); |
| 73 for (var i = 0; i < targets.length; ++i) { | 76 for (var i = 0; i < targets.length; ++i) { |
| 74 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode , targets[i]); | 77 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode , targets[i]); |
| 75 if (scriptFile) | 78 if (scriptFile) |
| 76 this._updateScriptFile(targets[i]); | 79 this._updateScriptFile(targets[i]); |
| 77 } | 80 } |
| 78 | 81 |
| 79 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' || | 82 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' || |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 * @override | 247 * @override |
| 245 * @return {!Promise} | 248 * @return {!Promise} |
| 246 */ | 249 */ |
| 247 populateLineGutterContextMenu(contextMenu, lineNumber) { | 250 populateLineGutterContextMenu(contextMenu, lineNumber) { |
| 248 /** | 251 /** |
| 249 * @this {Sources.JavaScriptSourceFrame} | 252 * @this {Sources.JavaScriptSourceFrame} |
| 250 */ | 253 */ |
| 251 function populate(resolve, reject) { | 254 function populate(resolve, reject) { |
| 252 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); | 255 var uiLocation = new Workspace.UILocation(this.uiSourceCode(), lineNumber, 0); |
| 253 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); | 256 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); |
| 254 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCod e(), lineNumber); | 257 var breakpoints = this._lineBreakpointDecorations(lineNumber).map(decorati on => decoration.breakpoint); |
| 255 if (!breakpoints.length) { | 258 if (!breakpoints.length) { |
| 256 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. | 259 // This row doesn't have a breakpoint: We want to show Add Breakpoint an d Add and Edit Breakpoint. |
| 257 contextMenu.appendItem( | 260 contextMenu.appendItem( |
| 258 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); | 261 Common.UIString('Add breakpoint'), this._createNewBreakpoint.bind(th is, lineNumber, '', true)); |
| 259 contextMenu.appendItem( | 262 contextMenu.appendItem( |
| 260 Common.UIString('Add conditional breakpoint…'), this._editBreakpoint Condition.bind(this, lineNumber)); | 263 Common.UIString('Add conditional breakpoint\u2026'), this._editBreak pointCondition.bind(this, lineNumber)); |
| 261 contextMenu.appendItem( | 264 contextMenu.appendItem( |
| 262 Common.UIString('Never pause here'), this._createNewBreakpoint.bind( this, lineNumber, 'false', true)); | 265 Common.UIString('Never pause here'), this._createNewBreakpoint.bind( this, lineNumber, 'false', true)); |
| 263 } else { | 266 } else { |
| 264 var breakpoint = breakpoints[0]; | 267 var hasOneBreakpoint = breakpoints.length === 1; |
| 265 | 268 var removeTitle = |
| 266 // This row has a breakpoint, we want to show edit and remove breakpoint , and either disable or enable. | 269 hasOneBreakpoint ? Common.UIString('Remove breakpoint') : Common.UIS tring('Remove all breakpoints in line'); |
| 267 contextMenu.appendItem(Common.UIString('Remove breakpoint'), breakpoint. remove.bind(breakpoint)); | 270 contextMenu.appendItem(removeTitle, () => breakpoints.map(breakpoint => breakpoint.remove())); |
| 268 contextMenu.appendItem( | 271 if (hasOneBreakpoint) { |
| 269 Common.UIString('Edit breakpoint…'), this._editBreakpointCondition.b ind(this, lineNumber, breakpoint)); | 272 contextMenu.appendItem( |
| 270 if (breakpoint.enabled()) | 273 Common.UIString('Edit breakpoint\u2026'), |
| 271 contextMenu.appendItem(Common.UIString('Disable breakpoint'), breakpoi nt.setEnabled.bind(breakpoint, false)); | 274 this._editBreakpointCondition.bind(this, lineNumber, breakpoints[0 ])); |
| 272 else | 275 } |
| 273 contextMenu.appendItem(Common.UIString('Enable breakpoint'), breakpoin t.setEnabled.bind(breakpoint, true)); | 276 var hasEnabled = breakpoints.some(breakpoint => breakpoint.enabled()); |
| 277 if (hasEnabled) { | |
| 278 var title = hasOneBreakpoint ? Common.UIString('Disable breakpoint') : | |
| 279 Common.UIString('Disable all breakpoint s in line'); | |
| 280 contextMenu.appendItem(title, () => breakpoints.map(breakpoint => brea kpoint.setEnabled(false))); | |
| 281 } | |
| 282 var hasDisabled = breakpoints.some(breakpoint => !breakpoint.enabled()); | |
| 283 if (hasDisabled) { | |
| 284 var title = hasOneBreakpoint ? Common.UIString('Enable breakpoint') : | |
| 285 Common.UIString('Enabled all breakpoint s in line'); | |
| 286 contextMenu.appendItem(title, () => breakpoints.map(breakpoint => brea kpoint.setEnabled(true))); | |
| 287 } | |
| 274 } | 288 } |
| 275 resolve(); | 289 resolve(); |
| 276 } | 290 } |
| 277 return new Promise(populate.bind(this)); | 291 return new Promise(populate.bind(this)); |
| 278 } | 292 } |
| 279 | 293 |
| 280 /** | 294 /** |
| 281 * @override | 295 * @override |
| 282 * @return {!Promise} | 296 * @return {!Promise} |
| 283 */ | 297 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 _didDivergeFromVM() { | 362 _didDivergeFromVM() { |
| 349 if (this._supportsEnabledBreakpointsWhileEditing()) | 363 if (this._supportsEnabledBreakpointsWhileEditing()) |
| 350 return; | 364 return; |
| 351 this._updateDivergedInfobar(); | 365 this._updateDivergedInfobar(); |
| 352 this._muteBreakpointsWhileEditing(); | 366 this._muteBreakpointsWhileEditing(); |
| 353 } | 367 } |
| 354 | 368 |
| 355 _muteBreakpointsWhileEditing() { | 369 _muteBreakpointsWhileEditing() { |
| 356 if (this._muted) | 370 if (this._muted) |
| 357 return; | 371 return; |
| 358 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNum ber) { | 372 for (var decoration of this._breakpointDecorations) |
| 359 var breakpointDecoration = this._textEditor.getAttribute(lineNumber, 'brea kpoint'); | 373 this._updateBreakpointDecoration(decoration); |
| 360 if (!breakpointDecoration) | |
| 361 continue; | |
| 362 this._removeBreakpointDecoration(lineNumber); | |
| 363 this._addBreakpointDecoration( | |
| 364 lineNumber, breakpointDecoration.columnNumber, breakpointDecoration.co ndition, breakpointDecoration.enabled, | |
| 365 true); | |
| 366 } | |
| 367 this._muted = true; | 374 this._muted = true; |
| 368 } | 375 } |
| 369 | 376 |
| 370 _updateDivergedInfobar() { | 377 _updateDivergedInfobar() { |
| 371 if (this.uiSourceCode().project().type() !== Workspace.projectTypes.FileSyst em) { | 378 if (this.uiSourceCode().project().type() !== Workspace.projectTypes.FileSyst em) { |
| 372 this._hideDivergedInfobar(); | 379 this._hideDivergedInfobar(); |
| 373 return; | 380 return; |
| 374 } | 381 } |
| 375 | 382 |
| 376 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 383 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 396 for (var i = 0; i < scriptFiles.length; ++i) { | 403 for (var i = 0; i < scriptFiles.length; ++i) { |
| 397 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM()) | 404 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM()) |
| 398 return; | 405 return; |
| 399 } | 406 } |
| 400 | 407 |
| 401 this._restoreBreakpointsAfterEditing(); | 408 this._restoreBreakpointsAfterEditing(); |
| 402 } | 409 } |
| 403 | 410 |
| 404 _restoreBreakpointsAfterEditing() { | 411 _restoreBreakpointsAfterEditing() { |
| 405 delete this._muted; | 412 delete this._muted; |
| 406 var breakpoints = {}; | 413 /** @type {!Array<!{lineNumber: number, columnNumber: number, condition: str ing, enabled: boolean}>} */ |
| 407 // Save and remove muted breakpoint decorations. | 414 var breakpoints = Array.from(this._breakpointDecorations) |
| 408 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNum ber) { | 415 .map(decoration => decoration.serialize()) |
|
lushnikov
2016/11/18 21:44:46
let's inline serialize here
or you may even use b
kozy
2016/11/19 00:46:09
Done.
| |
| 409 var breakpointDecoration = this._textEditor.getAttribute(lineNumber, 'brea kpoint'); | 416 .filter(breakpoint => !!breakpoint); |
| 410 if (breakpointDecoration) { | |
| 411 breakpoints[lineNumber] = breakpointDecoration; | |
| 412 this._removeBreakpointDecoration(lineNumber); | |
| 413 } | |
| 414 } | |
| 415 | |
| 416 // Remove all breakpoints. | |
| 417 this._removeAllBreakpoints(); | 417 this._removeAllBreakpoints(); |
| 418 | 418 this._breakpointDecorations.clear(); |
| 419 // Restore all breakpoints from saved decorations. | 419 for (var breakpoint of breakpoints) |
| 420 for (var lineNumberString in breakpoints) { | 420 this._setBreakpoint(breakpoint.lineNumber, breakpoint.columnNumber, breakp oint.condition, breakpoint.enabled); |
| 421 var lineNumber = parseInt(lineNumberString, 10); | |
| 422 if (isNaN(lineNumber)) | |
| 423 continue; | |
| 424 var breakpointDecoration = breakpoints[lineNumberString]; | |
| 425 this._setBreakpoint( | |
| 426 lineNumber, breakpointDecoration.columnNumber, breakpointDecoration.co ndition, breakpointDecoration.enabled); | |
| 427 } | |
| 428 } | 421 } |
| 429 | 422 |
| 430 _removeAllBreakpoints() { | 423 _removeAllBreakpoints() { |
| 431 var breakpoints = this._breakpointManager.breakpointsForUISourceCode(this.ui SourceCode()); | 424 for (var decoration of this._breakpointDecorations) |
| 432 for (var i = 0; i < breakpoints.length; ++i) | 425 decoration.breakpoint.remove(); |
| 433 breakpoints[i].remove(); | |
| 434 } | 426 } |
| 435 | 427 |
| 436 /** | 428 /** |
| 437 * @param {string} tokenType | 429 * @param {string} tokenType |
| 438 * @return {boolean} | 430 * @return {boolean} |
| 439 */ | 431 */ |
| 440 _isIdentifier(tokenType) { | 432 _isIdentifier(tokenType) { |
| 441 return tokenType.startsWith('js-variable') || tokenType.startsWith('js-prope rty') || tokenType === 'js-def'; | 433 return tokenType.startsWith('js-variable') || tokenType.startsWith('js-prope rty') || tokenType === 'js-def'; |
| 442 } | 434 } |
| 443 | 435 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 } | 542 } |
| 551 | 543 |
| 552 _onHidePopover() { | 544 _onHidePopover() { |
| 553 if (!this._popoverAnchorBox) | 545 if (!this._popoverAnchorBox) |
| 554 return; | 546 return; |
| 555 if (this._popoverAnchorBox._highlightDescriptor) | 547 if (this._popoverAnchorBox._highlightDescriptor) |
| 556 this.textEditor.removeHighlight(this._popoverAnchorBox._highlightDescripto r); | 548 this.textEditor.removeHighlight(this._popoverAnchorBox._highlightDescripto r); |
| 557 delete this._popoverAnchorBox; | 549 delete this._popoverAnchorBox; |
| 558 } | 550 } |
| 559 | 551 |
| 560 /** | |
| 561 * @param {number} lineNumber | |
| 562 * @param {number} columnNumber | |
| 563 * @param {string} condition | |
| 564 * @param {boolean} enabled | |
| 565 * @param {boolean} mutedWhileEditing | |
| 566 */ | |
| 567 _addBreakpointDecoration(lineNumber, columnNumber, condition, enabled, mutedWh ileEditing) { | |
| 568 var breakpoint = {condition: condition, enabled: enabled, columnNumber: colu mnNumber}; | |
| 569 | |
| 570 this.textEditor.setAttribute(lineNumber, 'breakpoint', breakpoint); | |
| 571 | |
| 572 var disabled = !enabled || mutedWhileEditing; | |
| 573 this.textEditor.addBreakpoint(lineNumber, disabled, !!condition); | |
| 574 } | |
| 575 | |
| 576 _removeBreakpointDecoration(lineNumber) { | |
| 577 this.textEditor.removeAttribute(lineNumber, 'breakpoint'); | |
| 578 this.textEditor.removeBreakpoint(lineNumber); | |
| 579 } | |
| 580 | |
| 581 _onKeyDown(event) { | 552 _onKeyDown(event) { |
| 582 if (event.key === 'Escape') { | 553 if (event.key === 'Escape') { |
| 583 if (this._popoverHelper.isPopoverVisible()) { | 554 if (this._popoverHelper.isPopoverVisible()) { |
| 584 this._popoverHelper.hidePopover(); | 555 this._popoverHelper.hidePopover(); |
| 585 event.consume(); | 556 event.consume(); |
| 586 } | 557 } |
| 587 } | 558 } |
| 588 } | 559 } |
| 589 | 560 |
| 590 /** | 561 /** |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 } | 791 } |
| 821 | 792 |
| 822 _clearValueWidgets() { | 793 _clearValueWidgets() { |
| 823 delete this._clearValueWidgetsTimer; | 794 delete this._clearValueWidgetsTimer; |
| 824 for (var line of this._valueWidgets.keys()) | 795 for (var line of this._valueWidgets.keys()) |
| 825 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); | 796 this.textEditor.removeDecoration(this._valueWidgets.get(line), line); |
| 826 this._valueWidgets.clear(); | 797 this._valueWidgets.clear(); |
| 827 } | 798 } |
| 828 | 799 |
| 829 /** | 800 /** |
| 801 * @param {number} lineNumber | |
| 802 * @return {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} | |
| 803 */ | |
| 804 _lineBreakpointDecorations(lineNumber) { | |
| 805 return Array.from(this._breakpointDecorations) | |
| 806 .filter(decoration => (decoration.handle.resolve() || {}).lineNumber === lineNumber); | |
| 807 } | |
| 808 | |
| 809 /** | |
| 810 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | |
| 811 */ | |
| 812 _updateBreakpointDecoration(decoration) { | |
| 813 var location = decoration.handle.resolve(); | |
| 814 if (!location) | |
| 815 return; | |
| 816 if (!this._scheduledBreakpointDecorationUpdates) { | |
| 817 this._scheduledBreakpointDecorationUpdates = new Set(); | |
|
lushnikov
2016/11/18 21:44:46
you should put decorations instead of lines inside
kozy
2016/11/19 00:46:09
Done.
| |
| 818 setImmediate(() => this.textEditor.operation(update.bind(this))); | |
| 819 } | |
| 820 this._scheduledBreakpointDecorationUpdates.add(location.lineNumber); | |
| 821 | |
| 822 /** | |
| 823 * @this {Sources.JavaScriptSourceFrame} | |
| 824 */ | |
| 825 function update() { | |
| 826 for (var lineNumber of this._scheduledBreakpointDecorationUpdates) { | |
| 827 if (lineNumber >= this._textEditor.linesCount) | |
| 828 continue; | |
| 829 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); | |
| 830 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); | |
| 831 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); | |
| 832 var decorations = this._lineBreakpointDecorations(lineNumber); | |
| 833 if (!decorations.length) | |
| 834 continue; | |
| 835 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); | |
| 836 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); | |
| 837 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted); | |
| 838 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', decorations[0].conditional); | |
| 839 } | |
| 840 delete this._scheduledBreakpointDecorationUpdates; | |
| 841 this._breakpointDecorationsUpdatedForTest(); | |
| 842 } | |
| 843 } | |
| 844 | |
| 845 _breakpointDecorationsUpdatedForTest() { | |
| 846 } | |
| 847 | |
| 848 /** | |
| 849 * @param {!Common.Event} event | |
| 830 * @return {boolean} | 850 * @return {boolean} |
| 831 */ | 851 */ |
| 832 _shouldIgnoreExternalBreakpointEvents() { | 852 _shouldIgnoreExternalBreakpointEvents(event) { |
| 853 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | |
| 854 if (uiLocation.uiSourceCode !== this.uiSourceCode() || !this.loaded) | |
| 855 return true; | |
| 833 if (this._supportsEnabledBreakpointsWhileEditing()) | 856 if (this._supportsEnabledBreakpointsWhileEditing()) |
| 834 return false; | 857 return false; |
| 835 if (this._muted) | 858 if (this._muted) |
| 836 return true; | 859 return true; |
| 837 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 860 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 838 for (var i = 0; i < scriptFiles.length; ++i) { | 861 for (var i = 0; i < scriptFiles.length; ++i) { |
| 839 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) | 862 if (scriptFiles[i].isDivergingFromVM() || scriptFiles[i].isMergingToVM()) |
| 840 return true; | 863 return true; |
| 841 } | 864 } |
| 842 return false; | 865 return false; |
| 843 } | 866 } |
| 844 | 867 |
| 868 /** | |
| 869 * @param {!Common.Event} event | |
| 870 */ | |
| 845 _breakpointAdded(event) { | 871 _breakpointAdded(event) { |
| 872 if (this._shouldIgnoreExternalBreakpointEvents(event)) | |
| 873 return; | |
| 846 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | 874 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); |
| 847 if (uiLocation.uiSourceCode !== this.uiSourceCode()) | 875 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumber , uiLocation.columnNumber); |
| 848 return; | |
| 849 if (this._shouldIgnoreExternalBreakpointEvents()) | |
| 850 return; | |
| 851 | |
| 852 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); | 876 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); |
| 853 if (this.loaded) { | 877 var decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration(hand le, breakpoint); |
| 854 this._addBreakpointDecoration( | 878 this._breakpointDecorations.add(decoration); |
| 855 uiLocation.lineNumber, uiLocation.columnNumber, breakpoint.condition() , breakpoint.enabled(), false); | 879 breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSym bol] = decoration; |
| 856 } | 880 this._updateBreakpointDecoration(decoration); |
| 857 } | |
| 858 | |
| 859 _breakpointRemoved(event) { | |
| 860 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation ); | |
| 861 if (uiLocation.uiSourceCode !== this.uiSourceCode()) | |
| 862 return; | |
| 863 if (this._shouldIgnoreExternalBreakpointEvents()) | |
| 864 return; | |
| 865 | |
| 866 var remainingBreakpoints = this._breakpointManager.findBreakpoints(this.uiSo urceCode(), uiLocation.lineNumber); | |
| 867 if (!remainingBreakpoints.length && this.loaded) | |
| 868 this._removeBreakpointDecoration(uiLocation.lineNumber); | |
| 869 } | 881 } |
| 870 | 882 |
| 871 /** | 883 /** |
| 884 * @param {!Common.Event} event | |
| 885 */ | |
| 886 _breakpointRemoved(event) { | |
| 887 if (this._shouldIgnoreExternalBreakpointEvents(event)) | |
| 888 return; | |
| 889 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even t.data.breakpoint); | |
| 890 var decoration = breakpoint[Sources.JavaScriptSourceFrame.BreakpointDecorati on._decorationSymbol]; | |
| 891 if (!decoration) | |
| 892 return; | |
| 893 this._breakpointDecorations.delete(decoration); | |
|
lushnikov
2016/11/18 21:44:46
cleanup symbol as well breakpoint[Sources.JavaScri
kozy
2016/11/19 00:46:09
Done.
| |
| 894 this._updateBreakpointDecoration(decoration); | |
| 895 } | |
| 896 | |
| 897 /** | |
| 872 * @param {!Common.Event} event | 898 * @param {!Common.Event} event |
| 873 */ | 899 */ |
| 874 _onSourceMappingChanged(event) { | 900 _onSourceMappingChanged(event) { |
| 875 var data = /** @type {{target: !SDK.Target}} */ (event.data); | 901 var data = /** @type {{target: !SDK.Target}} */ (event.data); |
| 876 this._updateScriptFile(data.target); | 902 this._updateScriptFile(data.target); |
| 877 this._updateLinesWithoutMappingHighlight(); | 903 this._updateLinesWithoutMappingHighlight(); |
| 878 } | 904 } |
| 879 | 905 |
| 880 _updateLinesWithoutMappingHighlight() { | 906 _updateLinesWithoutMappingHighlight() { |
| 881 var linesCount = this.textEditor.linesCount; | 907 var linesCount = this.textEditor.linesCount; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 /** | 957 /** |
| 932 * @override | 958 * @override |
| 933 */ | 959 */ |
| 934 onTextEditorContentSet() { | 960 onTextEditorContentSet() { |
| 935 super.onTextEditorContentSet(); | 961 super.onTextEditorContentSet(); |
| 936 if (this._executionLocation) | 962 if (this._executionLocation) |
| 937 this.setExecutionLocation(this._executionLocation); | 963 this.setExecutionLocation(this._executionLocation); |
| 938 | 964 |
| 939 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo urceCode(this.uiSourceCode()); | 965 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISo urceCode(this.uiSourceCode()); |
| 940 for (var i = 0; i < breakpointLocations.length; ++i) | 966 for (var i = 0; i < breakpointLocations.length; ++i) |
| 941 this._breakpointAdded({data: breakpointLocations[i]}); | 967 this._breakpointAdded(/** @type {!Common.Event} */ ({data: breakpointLocat ions[i]})); |
| 942 | 968 |
| 943 var scriptFiles = this._scriptFileForTarget.valuesArray(); | 969 var scriptFiles = this._scriptFileForTarget.valuesArray(); |
| 944 for (var i = 0; i < scriptFiles.length; ++i) | 970 for (var i = 0; i < scriptFiles.length; ++i) |
| 945 scriptFiles[i].checkMapping(); | 971 scriptFiles[i].checkMapping(); |
| 946 | 972 |
| 947 this._updateLinesWithoutMappingHighlight(); | 973 this._updateLinesWithoutMappingHighlight(); |
| 948 this._detectMinified(); | 974 this._detectMinified(); |
| 949 } | 975 } |
| 950 | 976 |
| 951 _detectMinified() { | 977 _detectMinified() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 | 1028 |
| 1003 this._toggleBreakpoint(lineNumber, eventObject.shiftKey); | 1029 this._toggleBreakpoint(lineNumber, eventObject.shiftKey); |
| 1004 eventObject.consume(true); | 1030 eventObject.consume(true); |
| 1005 } | 1031 } |
| 1006 | 1032 |
| 1007 /** | 1033 /** |
| 1008 * @param {number} lineNumber | 1034 * @param {number} lineNumber |
| 1009 * @param {boolean} onlyDisable | 1035 * @param {boolean} onlyDisable |
| 1010 */ | 1036 */ |
| 1011 _toggleBreakpoint(lineNumber, onlyDisable) { | 1037 _toggleBreakpoint(lineNumber, onlyDisable) { |
| 1012 var breakpoints = this._breakpointManager.findBreakpoints(this.uiSourceCode( ), lineNumber); | 1038 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 1013 if (breakpoints.length) { | 1039 if (!decorations.length) { |
| 1040 this._createNewBreakpoint(lineNumber, '', true); | |
| 1041 return; | |
| 1042 } | |
| 1043 var breakpoints = decorations.map(decoration => decoration.breakpoint); | |
| 1044 var hasDisabled = decorations.some(decoration => !decoration.enabled); | |
|
lushnikov
2016/11/18 21:44:46
can we check for cm-breakpoint-disabled class on g
kozy
2016/11/19 00:46:09
Done.
| |
| 1045 for (var breakpoint of breakpoints) { | |
| 1014 if (onlyDisable) | 1046 if (onlyDisable) |
| 1015 breakpoints[0].setEnabled(!breakpoints[0].enabled()); | 1047 breakpoint.setEnabled(hasDisabled); |
| 1016 else | 1048 else |
| 1017 breakpoints[0].remove(); | 1049 breakpoint.remove(); |
| 1018 } else { | |
| 1019 this._createNewBreakpoint(lineNumber, '', true); | |
| 1020 } | 1050 } |
| 1021 } | 1051 } |
| 1022 | 1052 |
| 1023 /** | 1053 /** |
| 1024 * @param {number} lineNumber | 1054 * @param {number} lineNumber |
| 1025 * @param {string} condition | 1055 * @param {string} condition |
| 1026 * @param {boolean} enabled | 1056 * @param {boolean} enabled |
| 1027 */ | 1057 */ |
| 1028 _createNewBreakpoint(lineNumber, condition, enabled) { | 1058 _createNewBreakpoint(lineNumber, condition, enabled) { |
| 1029 findPossibleBreakpoints.call(this, lineNumber) | 1059 findPossibleBreakpoints.call(this, lineNumber) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1120 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); | 1150 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang ed, this); |
| 1121 this.uiSourceCode().removeEventListener( | 1151 this.uiSourceCode().removeEventListener( |
| 1122 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); | 1152 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom mitted, this); |
| 1123 this.uiSourceCode().removeEventListener( | 1153 this.uiSourceCode().removeEventListener( |
| 1124 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); | 1154 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN eeded, this); |
| 1125 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this); | 1155 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._sh owBlackboxInfobarIfNeeded, this); |
| 1126 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); | 1156 Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBl ackboxInfobarIfNeeded, this); |
| 1127 super.dispose(); | 1157 super.dispose(); |
| 1128 } | 1158 } |
| 1129 }; | 1159 }; |
| 1160 | |
| 1161 /** | |
| 1162 * @unrestricted | |
| 1163 */ | |
| 1164 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { | |
| 1165 /** | |
| 1166 * @param {!TextEditor.TextEditorPositionHandle} handle | |
| 1167 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint | |
| 1168 */ | |
| 1169 constructor(handle, breakpoint) { | |
| 1170 this.handle = handle; | |
| 1171 this.conditional = !!breakpoint.condition(); | |
| 1172 this.enabled = breakpoint.enabled(); | |
| 1173 this.breakpoint = breakpoint; | |
| 1174 } | |
| 1175 | |
| 1176 /** | |
| 1177 * @return {?{lineNumber: number, columnNumber: number, condition: string, ena bled: boolean}} | |
| 1178 */ | |
| 1179 serialize() { | |
| 1180 var location = this.handle.resolve(); | |
| 1181 if (!location) | |
| 1182 return null; | |
| 1183 return { | |
| 1184 lineNumber: location.lineNumber, | |
| 1185 columnNumber: location.columnNumber, | |
| 1186 condition: this.breakpoint.condition(), | |
| 1187 enabled: this.breakpoint.enabled() | |
| 1188 }; | |
| 1189 } | |
| 1190 | |
| 1191 /** | |
| 1192 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration1 | |
| 1193 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration2 | |
| 1194 * @return {number} | |
| 1195 */ | |
| 1196 static mostSpecificFirst(decoration1, decoration2) { | |
| 1197 if (decoration1.conditional !== decoration2.conditional) | |
| 1198 return decoration1.conditional ? -1 : 1; | |
| 1199 if (decoration1.enabled !== decoration2.enabled) | |
| 1200 return decoration1.enabled ? -1 : 1; | |
| 1201 return 0; | |
| 1202 } | |
| 1203 }; | |
| 1204 | |
| 1205 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); | |
| OLD | NEW |