MCPcopy Index your code
hub / github.com/WebFreak001/code-debug / constructor

Method constructor

src/source_file_map.ts:13–35  ·  view source on GitHub ↗
(map: { [index: string]: string }, remoteCwd?: string)

Source from the content-addressed store, hash-verified

11 private remoteCwd: string|undefined;
12
13 constructor (map: { [index: string]: string }, remoteCwd?: string) {
14 const mappings: Mapping[] = [];
15 this.remoteCwd = remoteCwd;
16 this.nativePath = this.getNativePath();
17 for (let [remotePrefix, localPrefix] of Object.entries(map)) {
18 // Normalize local path, adding trailing separator if missing.
19 localPrefix = this.nativePath.normalizeDir(localPrefix);
20
21 // Try to detect remote path.
22 const debuggerPath: PathKind = this.toPathKind(remotePrefix);
23 // Normalize remote path, adding trailing separator if missing.
24 remotePrefix = debuggerPath.normalizeDir(remotePrefix);
25
26 mappings.push({remote: remotePrefix, local: localPrefix});
27 }
28
29 // Sort with longest paths first in case some paths are subsets, so that
30 // we match the most appropriate (e.g., with path prefixes of '/home'
31 // and '/home/foo', and a complete path of '/home/foo/bar.c', we should
32 // match the '/home/foo' path prefix instead of '/home'.
33 this.sortedMappings.local = [...mappings].sort((a: Mapping, b: Mapping) => b.local.length - a.local.length);
34 this.sortedMappings.remote = [...mappings].sort((a: Mapping, b: Mapping) => b.remote.length - a.remote.length);
35 }
36
37 // The native path selection is isolated here to allow for easy unit testing
38 // allowing non-native path types to be tested by overriding this method in

Callers

nothing calls this directly

Calls 2

getNativePathMethod · 0.95
toPathKindMethod · 0.95

Tested by

no test coverage detected