(source: Source, silent = false)
| 804 | } |
| 805 | |
| 806 | public removeSource(source: Source, silent = false) { |
| 807 | const existing = this._sourceByReference.get(source.sourceReference); |
| 808 | if (existing === undefined) { |
| 809 | return; // already removed |
| 810 | } |
| 811 | |
| 812 | this.logger.assert( |
| 813 | source === existing, |
| 814 | 'Expected source to be the same as the existing reference', |
| 815 | ); |
| 816 | this._sourceByReference.delete(source.sourceReference); |
| 817 | |
| 818 | // check for overwrites: |
| 819 | if (this._sourceByOriginalUrl.get(source.url) === source) { |
| 820 | this._sourceByOriginalUrl.delete(source.url); |
| 821 | } |
| 822 | |
| 823 | if (source instanceof SourceFromMap) { |
| 824 | this._sourceMapSourcesByUrl.delete(source.url); |
| 825 | for (const [compiled, key] of source.compiledToSourceUrl) { |
| 826 | compiled.sourceMap.sourceByUrl.delete(key); |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | this._sourceByAbsolutePath.delete(source.absolutePath); |
| 831 | if (isSourceWithMap(source)) { |
| 832 | this._permanentlyDisabledSourceMaps.delete(source); |
| 833 | this._temporarilyDisabledSourceMaps.delete(source); |
| 834 | } |
| 835 | |
| 836 | if (!silent && source.hasBeenAnnounced) { |
| 837 | source.toDap().then(dap => this._dap.loadedSource({ reason: 'removed', source: dap })); |
| 838 | } |
| 839 | |
| 840 | if (isSourceWithWasm(source)) { |
| 841 | source.sourceMap.value.promise.then(w => w?.dispose()); |
| 842 | } |
| 843 | |
| 844 | if (isSourceWithMap(source)) { |
| 845 | this._removeSourceMapSources(source, silent); |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | /** |
| 850 | * Sends a 'loadedSource' event for the given source. |
no test coverage detected