textSearchManager.ts ×16

Frontier kind: Code frontier

unlabeled · c_14ba8b2f4b4e

17 tests · 10644 LOC · 48 files · introduces 0 tests · 87 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges87 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1501 ranges10644 lines · 48 files · Browse complete extent
All tests (intent)
17 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 87 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/search/common/textSearchManager.ts 82 introduced LOC · 16 ranges

Open complete file

40
41 constructor(private queryProviderPair: IAITextQueryProviderPair | ITextQueryProviderPair,
42 > private fileUtils: IFileUtils, textSearchManager.ts
43 > private processType: ITextSearchStats['type']) { }
44
45 private get query() {
46 > return this.queryProviderPair.query; textSearchManager.ts
47 > }
48
49 search(onProgress: (matches: IFileMatch[]) => void, token: CancellationToken, onKeywordResult?: (keyword: AISearchKeyword) => void): Promise<ISearchCompleteStats> {
50 > const folderQueries = this.query.folderQueries || []; textSearchManager.ts
51 > const tokenSource = new CancellationTokenSource(token);
52 >
53 > return new Promise<ISearchCompleteStats>((resolve, reject) => {
54 > this.collector = new TextSearchResultsCollector(onProgress);
55 >
56 > let isCanceled = false;
57 > const onResult = (result: TextSearchResult2, folderIdx: number) => {
58 if (result instanceof AISearchKeyword) {
59 // Already processed by the callback.
83 }
84 };
86 > // For each root folder
87 > this.doSearch(folderQueries, onResult, tokenSource.token, onKeywordResult).then(result => {
88 tokenSource.dispose();
89 this.collector!.flush();
96 }
97 });
98 > }, (err: Error) => { textSearchManager.ts
99 tokenSource.dispose();
100 const errMsg = toErrorMessage(err);
101 reject(new Error(errMsg));
103 > });
104 > }
105
106 private getMessagesFromResults(result: TextSearchComplete2 | null | undefined) {
127
128 private async doSearch(folderQueries: IFolderQuery<URI>[], onResult: (result: TextSearchResult2, folderIdx: number) => void, token: CancellationToken, onKeywordResult?: (keyword: AISearchKeyword) => void): Promise<TextSearchComplete2 | null | undefined> {
129 > const folderMappings: FolderQuerySearchTree<FolderQueryInfo> = new FolderQuerySearchTree<FolderQueryInfo>( textSearchManager.ts
130 > folderQueries,
131 > (fq, i) => {
132 > const queryTester = new QueryGlobTester(this.query, fq);
133 > return { queryTester, folder: fq.folder, folderIdx: i };
134 > },
135 > () => true
136 > );
137 >
138 > const testingPs: Promise<void>[] = [];
139 > const progress = {
140 > report: (result: TextSearchResult2 | AISearchResult) => {
141 if (result instanceof AISearchKeyword) {
142 onKeywordResult?.(result);
171 }
172 }
174 >
175 > const folderOptions = folderQueries.map(fq => this.getSearchOptionsForFolder(fq));
176 > const searchOptions: TextSearchProviderOptions = {
177 > folderOptions,
178 > maxFileSize: this.query.maxFileSize,
179 > maxResults: this.query.maxResults ?? DEFAULT_MAX_SEARCH_RESULTS,
180 > previewOptions: this.query.previewOptions ?? DEFAULT_TEXT_SEARCH_PREVIEW_OPTIONS,
181 > surroundingContext: this.query.surroundingContext ?? 0,
182 > };
183 >
184 > let result;
185 > if (this.queryProviderPair.query.type === QueryType.aiText) {
186 result = await (this.queryProviderPair as IAITextQueryProviderPair).provider.provideAITextSearchResults(this.queryProviderPair.query.contentPattern, searchOptions, progress, token);
187 > } else { textSearchManager.ts
188 > result = await (this.queryProviderPair as ITextQueryProviderPair).provider.provideTextSearchResults(patternInfoToQuery(this.queryProviderPair.query.contentPattern), searchOptions, progress, token);
189 }
190 if (testingPs.length) {
193
194 return result;
196
197 private getSearchOptionsForFolder(fq: IFolderQuery<URI>): TextSearchProviderFolderOptions {
198 > const includes = resolvePatternsForProvider(this.query.includePattern, fq.includePattern); textSearchManager.ts
199 >
200 > let excludePattern = fq.excludePattern?.map(e => ({
201 folder: e.folder,
202 patterns: resolvePatternsForProvider(this.query.excludePattern, e.pattern)
204 >
205 > if (!excludePattern || excludePattern.length === 0) {
206 excludePattern = [{
207 folder: undefined,
209 }];
210 }
211 > const excludes = excludeToGlobPattern(excludePattern); textSearchManager.ts
212 >
213 > const options = {
214 > folder: URI.from(fq.folder),
215 > excludes,
216 > includes,
217 > useIgnoreFiles: {
218 > local: !fq.disregardIgnoreFiles,
219 > parent: !fq.disregardParentIgnoreFiles,
220 > global: !fq.disregardGlobalIgnoreFiles
221 > },
222 > followSymlinks: !fq.ignoreSymlinks,
223 > encoding: (fq.fileEncoding && this.fileUtils.toCanonicalName(fq.fileEncoding)) ?? '',
224 > ignoreGlobCase: this.query.ignoreGlobCase || fq.ignoreGlobCase,
225 > };
226 > return options;
227 > }
228 }
229
230 > function patternInfoToQuery(patternInfo: IPatternInfo): TextSearchQuery2 { textSearchManager.ts
231 > return {
232 > isCaseSensitive: patternInfo.isCaseSensitive || false,
233 > isRegExp: patternInfo.isRegExp || false,
234 > isWordMatch: patternInfo.isWordMatch || false,
235 > isMultiline: patternInfo.isMultiline || false,
236 > pattern: patternInfo.pattern
237 > };
238 > }
239
240 export class TextSearchResultsCollector {
246
247 constructor(private _onResult: (result: IFileMatch[]) => void) {
248 > this._batchedCollector = new BatchedCollector<IFileMatch>(512, items => this.sendItems(items)); textSearchManager.ts
249 > }
250
251 add(data: TextSearchResult2, folderIdx: number): void {
334
335 constructor(private maxBatchSize: number, private cb: (items: T[]) => void) {
337
338 addItem(item: T, size: number): void {
src/vs/workbench/services/search/node/textSearchManager.ts 5 introduced LOC · 1 range

Open complete file

13
14 constructor(query: ITextQuery, provider: TextSearchProvider2, _pfs: typeof pfs = pfs, processType: ITextSearchStats['type'] = 'searchProcess') {
15 > super({ query, provider }, { textSearchManager.ts
16 > readdir: resource => _pfs.Promises.readdir(resource.fsPath),
17 > toCanonicalName: name => toCanonicalName(name)
18 > }, processType);
19 > }
20 }