1
>
/*---------------------------------------------------------------------------------------------
folderQuerySearchTree.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
import { URI } from '../../../../base/common/uri.js';
6
>
import { IFolderQuery } from './search.js';
7
>
import { TernarySearchTree, UriIterator } from '../../../../base/common/ternarySearchTree.js';
8
>
import { ResourceMap } from '../../../../base/common/map.js';
9
>
10
>
/**
11
>
* A ternary search tree that supports URI keys and query/fragment-aware substring matching, specifically for file search.
12
>
* This is because the traditional TST does not support query and fragments https://github.com/microsoft/vscode/issues/227836
13
>
*/
14
>
export class FolderQuerySearchTree<FolderQueryInfo extends { folder: URI }> extends TernarySearchTree<URI, Map<string, FolderQueryInfo>> {
15
>
constructor(folderQueries: IFolderQuery<URI>[],
16
>
getFolderQueryInfo: (fq: IFolderQuery, i: number) => FolderQueryInfo,
17
>
ignorePathCasing: (key: URI) => boolean = () => false
18
>
) {
19
>
const uriIterator = new UriIterator(ignorePathCasing, () => false);
20
>
super(uriIterator);
21
>
22
>
const fqBySameBase = new ResourceMap<{ fq: IFolderQuery<URI>; i: number }[]>();
23
>
folderQueries.forEach((fq, i) => {
24
const uriWithoutQueryOrFragment = fq.folder.with({ query: '', fragment: '' });
25
if (fqBySameBase.has(uriWithoutQueryOrFragment)) {