MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / scan

Method scan

Extension/src/Utility/Filesystem/ripgrep.ts:62–94  ·  view source on GitHub ↗
(...location: (string | number)[])

Source from the content-addressed store, hash-verified

60 scan(...location: string[]): FastFinder;
61 scan(depth: number, ...location: string[]): FastFinder;
62 scan(...location: (string | number)[]): FastFinder {
63 const depth = (typeof location[0] === 'number' ? location.shift() as number : 0) + 1;
64 const globs = this.executableExtensions.length ?
65 this.fileGlobs.map(glob => this.executableExtensions.map(ext => glob.includes('**') ? glob : `**/${glob}${ext}`)).flat() :
66 this.fileGlobs.map(glob => glob.includes('**') ? glob : `**/${glob}`);
67
68 // only search locations that exist
69 location = location.filter(each => existsSync(each.toString()));
70
71 // only search if there are globs and locations to search
72 if (globs.length && location.length) {
73 this.pending++;
74 void ripgrep!(...globs.map(each => ['--glob', each]).flat(), '--max-depth', depth, '--null-data', '--no-messages', '-L', '--files', ...location.map(each => each.toString())).then(async proc => {
75 const process = proc as unknown as Instance<Process>;
76 this.processes.push(process);
77 for await (const line of process.stdio) {
78 if (this.distinct.has(line)) {
79 continue;
80 }
81 this.distinct.add(line);
82 if (!this.keepOnlyExecutables || await filepath.isExecutable(line)) {
83 this.#files.add(line);
84 }
85 }
86 }).catch(logAndReturn.undefined).finally(() => {
87 this.pending--;
88 if (this.readyToComplete && this.pending === 0) {
89 this.#files.complete();
90 }
91 });
92 }
93 return this;
94 }
95}
96
97interface MatchData {

Callers

nothing calls this directly

Calls 9

toStringMethod · 0.80
pushMethod · 0.80
hasMethod · 0.80
filterMethod · 0.45
finallyMethod · 0.45
catchMethod · 0.45
thenMethod · 0.45
addMethod · 0.45
isExecutableMethod · 0.45

Tested by

no test coverage detected