MCPcopy
hub / github.com/microsoft/vscode-js-debug / _addSource

Method _addSource

src/adapter/sourceContainer.ts:664–702  ·  view source on GitHub ↗
(source: Source)

Source from the content-addressed store, hash-verified

662 }
663
664 private async _addSource(source: Source) {
665 // todo: we should allow the same source at multiple uri's if their scripts
666 // have different executionContextId. We only really need the overwrite
667 // behavior in Node for tools that transpile sources inline.
668 const existingByUrl = source.url && this._sourceByOriginalUrl.get(source.url);
669 if (existingByUrl && !isOriginalSourceOf(existingByUrl, source)) {
670 this.removeSource(existingByUrl, true);
671 }
672
673 this._sourceByOriginalUrl.set(source.url, source);
674 this._sourceByReference.set(source.sourceReference, source);
675 if (source instanceof SourceFromMap) {
676 this._sourceMapSourcesByUrl.set(source.url, source);
677 }
678
679 // Some builds, like the Vue starter, generate 'metadata' files for compiled
680 // files with query strings appended to deduplicate them, or nested inside
681 // of internal prefixes. If we see a duplicate entries for an absolute path,
682 // take the shorter of them.
683 const existingByPath = this._sourceByAbsolutePath.get(source.absolutePath);
684 if (
685 existingByPath === undefined
686 || existingByPath.url.length >= source.url.length
687 || isOriginalSourceOf(existingByPath, source)
688 ) {
689 this._sourceByAbsolutePath.set(source.absolutePath, source);
690 }
691
692 this.scriptSkipper.initializeSkippingValueForSource(source);
693 if (!source.sendLazy) {
694 this.emitLoadedSource(source);
695 }
696
697 if (isSourceWithSourceMap(source)) {
698 this._finishAddSourceWithSourceMap(source);
699 } else if (isSourceWithWasm(source)) {
700 this._finishAddSourceWithWasm(source as WasmSource);
701 }
702 }
703
704 private async _finishAddSourceWithWasm(compiled: WasmSource) {
705 const symbols = await this.wasmSymbols.loadWasmSymbols(compiled.event);

Callers 3

addSourceMethod · 0.95
_addSourceMapSourcesMethod · 0.95

Calls 10

removeSourceMethod · 0.95
emitLoadedSourceMethod · 0.95
isSourceWithSourceMapFunction · 0.90
isSourceWithWasmFunction · 0.90
isOriginalSourceOfFunction · 0.85
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected