MCPcopy Create free account
hub / github.com/Snapchat/Valdi / addSource

Method addSource

valdi/vscode_debugger/src/adapter/sources.ts:692–722  ·  view source on GitHub ↗

* Adds a new source to the collection.

(
    url: string,
    contentGetter: ContentGetter,
    sourceMapUrl?: string,
    inlineSourceRange?: InlineScriptOffset,
    contentHash?: string,
  )

Source from the content-addressed store, hash-verified

690 * Adds a new source to the collection.
691 */
692 public async addSource(
693 url: string,
694 contentGetter: ContentGetter,
695 sourceMapUrl?: string,
696 inlineSourceRange?: InlineScriptOffset,
697 contentHash?: string,
698 ): Promise<Source> {
699 const absolutePath = await this.sourcePathResolver.urlToAbsolutePath({ url });
700 this.logger.verbose(LogTag.RuntimeSourceCreate, 'Creating source from url', {
701 inputUrl: url,
702 absolutePath,
703 });
704
705 const source = new Source(
706 this,
707 url,
708 absolutePath,
709 contentGetter,
710 sourceMapUrl &&
711 this.sourcePathResolver.shouldResolveSourceMap({
712 sourceMapUrl,
713 compiledPath: absolutePath || url,
714 })
715 ? sourceMapUrl
716 : undefined,
717 inlineSourceRange,
718 contentHash,
719 );
720 this._addSource(source);
721 return source;
722 }
723
724 private async _addSource(source: Source) {
725 this._sourceByReference.set(source.sourceReference(), source);

Callers 1

createSourceMethod · 0.80

Calls 4

_addSourceMethod · 0.95
urlToAbsolutePathMethod · 0.65
verboseMethod · 0.65

Tested by

no test coverage detected