| 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, !WebInspector.UISourceCode.LineMarker>>
} */ | 63 |
| 64 this._lineDecorations = new Map(); | 64 /** @type {!Multimap<string, !WebInspector.UISourceCode.LineMarker>} */ |
| 65 this._typeDecorations = new Multimap(); |
| 66 /** @type {!Multimap<number, !WebInspector.UISourceCode.LineMarker>} */ |
| 67 this._lineDecorations = new Multimap(); |
| 65 | 68 |
| 66 /** @type {!Array.<!WebInspector.Revision>} */ | 69 /** @type {!Array.<!WebInspector.Revision>} */ |
| 67 this.history = []; | 70 this.history = []; |
| 68 | 71 |
| 69 /** @type {!Array<!WebInspector.UISourceCode.Message>} */ | 72 /** @type {!Array<!WebInspector.UISourceCode.Message>} */ |
| 70 this._messages = []; | 73 this._messages = []; |
| 71 } | 74 } |
| 72 | 75 |
| 73 /** | 76 /** |
| 74 * @return {!Promise<?WebInspector.UISourceCodeMetadata>} | 77 * @return {!Promise<?WebInspector.UISourceCodeMetadata>} |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 for (var message of messages) | 602 for (var message of messages) |
| 600 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemo
ved, message); | 603 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemo
ved, message); |
| 601 } | 604 } |
| 602 | 605 |
| 603 /** | 606 /** |
| 604 * @param {number} lineNumber | 607 * @param {number} lineNumber |
| 605 * @param {string} type | 608 * @param {string} type |
| 606 * @param {?} data | 609 * @param {?} data |
| 607 */ | 610 */ |
| 608 addLineDecoration(lineNumber, type, data) { | 611 addLineDecoration(lineNumber, type, data) { |
| 609 var markers = this._lineDecorations.get(type); | 612 |
| 610 if (!markers) { | |
| 611 markers = new Map(); | |
| 612 this._lineDecorations.set(type, markers); | |
| 613 } | |
| 614 var marker = new WebInspector.UISourceCode.LineMarker(lineNumber, type, data
); | 613 var marker = new WebInspector.UISourceCode.LineMarker(lineNumber, type, data
); |
| 615 markers.set(lineNumber, marker); | 614 |
| 615 this._typeDecorations.set(type, marker); |
| 616 this._lineDecorations.set(lineNumber, marker); |
| 617 |
| 616 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineDecoratio
nAdded, marker); | 618 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineDecoratio
nAdded, marker); |
| 617 } | 619 } |
| 618 | 620 |
| 619 /** | 621 /** |
| 620 * @param {number} lineNumber | 622 * @param {number} lineNumber |
| 621 * @param {string} type | 623 * @param {string} type |
| 622 */ | 624 */ |
| 623 removeLineDecoration(lineNumber, type) { | 625 removeLineDecoration(lineNumber, type) { |
| 624 var markers = this._lineDecorations.get(type); | 626 var markers = this._lineDecorations.get(lineNumber); |
| 625 if (!markers) | 627 if (!markers) |
| 626 return; | 628 return; |
| 627 var marker = markers.get(lineNumber); | 629 |
| 628 if (!marker) | 630 for (var decoration of markers) { |
| 629 return; | 631 if (decoration.type() === type) { |
| 630 markers.delete(lineNumber); | 632 |
| 631 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineDecoratio
nRemoved, marker); | 633 this._typeDecorations.remove(type, decoration); |
| 632 if (!markers.size) | 634 |
| 633 this._lineDecorations.delete(type); | 635 this._lineDecorations.remove(lineNumber, decoration); |
| 636 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineDecor
ationRemoved, decoration); |
| 637 } |
| 638 } |
| 634 } | 639 } |
| 635 | 640 |
| 636 /** | 641 /** |
| 637 * @param {string} type | 642 * @param {string} type |
| 638 */ | 643 */ |
| 639 removeAllLineDecorations(type) { | 644 removeAllLineDecorations(type) { |
| 640 var markers = this._lineDecorations.get(type); | 645 var markers = this._typeDecorations.get(type); |
| 641 if (!markers) | 646 if (!markers) |
| 642 return; | 647 return; |
| 643 this._lineDecorations.delete(type); | 648 |
| 649 markers.forEach(marker => this._lineDecorations.remove(marker.line(), marker
)); |
| 650 this._typeDecorations.removeAll(type); |
| 651 |
| 644 markers.forEach(marker => { | 652 markers.forEach(marker => { |
| 645 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineDecorat
ionRemoved, marker); | 653 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineDecorat
ionRemoved, marker); |
| 646 }); | 654 }); |
| 647 } | 655 } |
| 648 | 656 |
| 649 /** | 657 /** |
| 650 * @param {string} type | 658 * @param {string} type |
| 651 * @return {?Map<number, !WebInspector.UISourceCode.LineMarker>} | 659 * @return {?Set<!WebInspector.UISourceCode.LineMarker>} |
| 652 */ | 660 */ |
| 653 lineDecorations(type) { | 661 lineDecorations(type) { |
| 654 return this._lineDecorations.get(type) || null; | 662 return this._typeDecorations.get(type) || null; |
| 655 } | 663 } |
| 656 }; | 664 }; |
| 657 | 665 |
| 658 /** @enum {symbol} */ | 666 /** @enum {symbol} */ |
| 659 WebInspector.UISourceCode.Events = { | 667 WebInspector.UISourceCode.Events = { |
| 660 WorkingCopyChanged: Symbol('WorkingCopyChanged'), | 668 WorkingCopyChanged: Symbol('WorkingCopyChanged'), |
| 661 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), | 669 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), |
| 662 TitleChanged: Symbol('TitleChanged'), | 670 TitleChanged: Symbol('TitleChanged'), |
| 663 SourceMappingChanged: Symbol('SourceMappingChanged'), | 671 SourceMappingChanged: Symbol('SourceMappingChanged'), |
| 664 MessageAdded: Symbol('MessageAdded'), | 672 MessageAdded: Symbol('MessageAdded'), |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 WebInspector.UISourceCodeMetadata = class { | 950 WebInspector.UISourceCodeMetadata = class { |
| 943 /** | 951 /** |
| 944 * @param {?Date} modificationTime | 952 * @param {?Date} modificationTime |
| 945 * @param {?number} contentSize | 953 * @param {?number} contentSize |
| 946 */ | 954 */ |
| 947 constructor(modificationTime, contentSize) { | 955 constructor(modificationTime, contentSize) { |
| 948 this.modificationTime = modificationTime; | 956 this.modificationTime = modificationTime; |
| 949 this.contentSize = contentSize; | 957 this.contentSize = contentSize; |
| 950 } | 958 } |
| 951 }; | 959 }; |
| OLD | NEW |