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

Class VueFileMapper

valdi/vscode_debugger/src/adapter/vueFileMapper.ts:72–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 */
71@injectable()
72export class VueFileMapper implements IVueFileMapper {
73 constructor(
74 @inject(VueComponentPaths) private readonly files: FileGlobList,
75 @inject(ISearchStrategy) private readonly search: ISearchStrategy,
76 ) {}
77
78 private readonly getMapping = once(async () => {
79 const basenameToPath = new Map<string, string>();
80 await this.search.streamAllChildren(this.files, file =>
81 basenameToPath.set(basename(file), file),
82 );
83
84 return basenameToPath;
85 });
86
87 /**
88 * @inheritdoc
89 */
90 public async lookup(sourceUrl: string) {
91 const match = vueSourceUrlRe.exec(sourceUrl);
92 if (!match) {
93 return undefined;
94 }
95
96 const basenameToPath = await this.getMapping();
97 return basenameToPath.get(match[1]);
98 }
99
100 /**
101 * @inheritdoc
102 */
103 public getVueHandling(sourceUrl: string) {
104 if (this.files.empty) {
105 return VueHandling.Unhandled;
106 }
107
108 return vueSourceUrlRe.test(sourceUrl)
109 ? VueHandling.Lookup
110 : vueGeneratedRe.test(sourceUrl)
111 ? VueHandling.Omit
112 : VueHandling.Unhandled;
113 }
114}

Callers

nothing calls this directly

Calls 3

onceFunction · 0.90
streamAllChildrenMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected