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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 this._origin = ''; | 53 this._origin = ''; |
| 54 this._parentURL = ''; | 54 this._parentURL = ''; |
| 55 this._name = url; | 55 this._name = url; |
| 56 } | 56 } |
| 57 | 57 |
| 58 this._contentType = contentType; | 58 this._contentType = contentType; |
| 59 /** @type {?function(?string)} */ | 59 /** @type {?function(?string)} */ |
| 60 this._requestContentCallback = null; | 60 this._requestContentCallback = null; |
| 61 /** @type {?Promise<?string>} */ | 61 /** @type {?Promise<?string>} */ |
| 62 this._requestContentPromise = null; | 62 this._requestContentPromise = null; |
| 63 /** @type {!Map<string, !Map<number, !Workspace.UISourceCode.LineMarker>>} * / | 63 /** @type {!Map<string, !Map<!Common.TextRange, !Workspace.UISourceCode.Line Marker>>} */ |
|
caseq
2016/11/15 22:07:05
I wonder if there's any reason to have map now.
| |
| 64 this._lineDecorations = new Map(); | 64 this._decorations = new Map(); |
| 65 | 65 |
| 66 /** @type {!Array.<!Workspace.Revision>} */ | 66 /** @type {!Array.<!Workspace.Revision>} */ |
| 67 this.history = []; | 67 this.history = []; |
| 68 | 68 |
| 69 /** @type {!Array<!Workspace.UISourceCode.Message>} */ | 69 /** @type {!Array<!Workspace.UISourceCode.Message>} */ |
| 70 this._messages = []; | 70 this._messages = []; |
| 71 } | 71 } |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @return {!Promise<?Workspace.UISourceCodeMetadata>} | 74 * @return {!Promise<?Workspace.UISourceCodeMetadata>} |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 for (var message of messages) | 599 for (var message of messages) |
| 600 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message); | 600 this.dispatchEventToListeners(Workspace.UISourceCode.Events.MessageRemoved , message); |
| 601 } | 601 } |
| 602 | 602 |
| 603 /** | 603 /** |
| 604 * @param {number} lineNumber | 604 * @param {number} lineNumber |
| 605 * @param {string} type | 605 * @param {string} type |
| 606 * @param {?} data | 606 * @param {?} data |
| 607 */ | 607 */ |
| 608 addLineDecoration(lineNumber, type, data) { | 608 addLineDecoration(lineNumber, type, data) { |
| 609 var markers = this._lineDecorations.get(type); | 609 this.addDecoration(Common.TextRange.createFromLocation(lineNumber, 0), type, data); |
| 610 } | |
| 611 | |
| 612 /** | |
| 613 * @param {!Common.TextRange} range | |
| 614 * @param {string} type | |
| 615 * @param {?} data | |
| 616 */ | |
| 617 addDecoration(range, type, data) { | |
| 618 var markers = this._decorations.get(type); | |
| 610 if (!markers) { | 619 if (!markers) { |
| 611 markers = new Map(); | 620 markers = new Map(); |
| 612 this._lineDecorations.set(type, markers); | 621 this._decorations.set(type, markers); |
| 613 } | 622 } |
| 614 var marker = new Workspace.UISourceCode.LineMarker(lineNumber, type, data); | 623 var marker = new Workspace.UISourceCode.LineMarker(range.startLine, type, da ta); |
| 615 markers.set(lineNumber, marker); | 624 markers.set(range, marker); |
| 616 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAd ded, marker); | 625 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAd ded, marker); |
| 617 } | 626 } |
| 618 | 627 |
| 619 /** | 628 /** |
| 620 * @param {number} lineNumber | 629 * @param {number} lineNumber |
| 621 * @param {string} type | 630 * @param {string} type |
| 622 */ | 631 */ |
| 623 removeLineDecoration(lineNumber, type) { | 632 removeLineDecoration(lineNumber, type) { |
| 624 var markers = this._lineDecorations.get(type); | 633 this.removeDecoration(Common.TextRange.createFromLocation(lineNumber, 0), ty pe); |
|
caseq
2016/11/15 22:07:05
Does this actually work?
| |
| 634 } | |
| 635 | |
| 636 /** | |
| 637 * @param {!Common.TextRange} range | |
| 638 * @param {string} type | |
| 639 */ | |
| 640 removeDecoration(range, type) { | |
| 641 var markers = this._decorations.get(type); | |
| 625 if (!markers) | 642 if (!markers) |
| 626 return; | 643 return; |
| 627 var marker = markers.get(lineNumber); | 644 var marker = markers.get(range); |
| 628 if (!marker) | 645 if (!marker) |
| 629 return; | 646 return; |
| 630 markers.delete(lineNumber); | 647 markers.delete(range); |
| 631 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRe moved, marker); | 648 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRe moved, marker); |
| 632 if (!markers.size) | 649 if (!markers.size) |
| 633 this._lineDecorations.delete(type); | 650 this._decorations.delete(type); |
| 634 } | 651 } |
| 635 | 652 |
| 636 /** | 653 /** |
| 637 * @param {string} type | 654 * @param {string} type |
| 638 */ | 655 */ |
| 639 removeAllLineDecorations(type) { | 656 removeAllLineDecorations(type) { |
| 640 var markers = this._lineDecorations.get(type); | 657 var markers = this._decorations.get(type); |
| 641 if (!markers) | 658 if (!markers) |
| 642 return; | 659 return; |
| 643 this._lineDecorations.delete(type); | 660 this._decorations.delete(type); |
| 644 markers.forEach(marker => { | 661 markers.forEach(marker => { |
| 645 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecoration Removed, marker); | 662 this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecoration Removed, marker); |
| 646 }); | 663 }); |
| 647 } | 664 } |
| 648 | 665 |
| 649 /** | 666 /** |
| 667 * @return {!Map<string, !Map<!Common.TextRange, !Workspace.UISourceCode.LineM arker>>} | |
| 668 */ | |
| 669 getAllDecorations() { | |
| 670 return this._decorations; | |
| 671 } | |
| 672 | |
| 673 removeAllDecorations() { | |
| 674 this._decorations.clear(); | |
| 675 } | |
| 676 | |
| 677 /** | |
| 650 * @param {string} type | 678 * @param {string} type |
| 651 * @return {?Map<number, !Workspace.UISourceCode.LineMarker>} | 679 * @return {?Map<!Common.TextRange, !Workspace.UISourceCode.LineMarker>} |
| 652 */ | 680 */ |
| 653 lineDecorations(type) { | 681 lineDecorations(type) { |
| 654 return this._lineDecorations.get(type) || null; | 682 return this._decorations.get(type) || null; |
| 655 } | 683 } |
| 656 }; | 684 }; |
| 657 | 685 |
| 658 /** @enum {symbol} */ | 686 /** @enum {symbol} */ |
| 659 Workspace.UISourceCode.Events = { | 687 Workspace.UISourceCode.Events = { |
| 660 WorkingCopyChanged: Symbol('WorkingCopyChanged'), | 688 WorkingCopyChanged: Symbol('WorkingCopyChanged'), |
| 661 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), | 689 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), |
| 662 TitleChanged: Symbol('TitleChanged'), | 690 TitleChanged: Symbol('TitleChanged'), |
| 663 SourceMappingChanged: Symbol('SourceMappingChanged'), | 691 SourceMappingChanged: Symbol('SourceMappingChanged'), |
| 664 MessageAdded: Symbol('MessageAdded'), | 692 MessageAdded: Symbol('MessageAdded'), |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 942 Workspace.UISourceCodeMetadata = class { | 970 Workspace.UISourceCodeMetadata = class { |
| 943 /** | 971 /** |
| 944 * @param {?Date} modificationTime | 972 * @param {?Date} modificationTime |
| 945 * @param {?number} contentSize | 973 * @param {?number} contentSize |
| 946 */ | 974 */ |
| 947 constructor(modificationTime, contentSize) { | 975 constructor(modificationTime, contentSize) { |
| 948 this.modificationTime = modificationTime; | 976 this.modificationTime = modificationTime; |
| 949 this.contentSize = contentSize; | 977 this.contentSize = contentSize; |
| 950 } | 978 } |
| 951 }; | 979 }; |
| OLD | NEW |