import * as glob from "../../../../base/common/glob.js"; import { URI, URI as uri, UriComponents } from "../../../../base/common/uri.js"; import { IConfigurationService } from "../../../../platform/configuration/common/configuration.service.js"; import { ILogService } from "../../../../platform/log/common/log.service.js"; import { IUriIdentityService } from "../../../../platform/uriIdentity/common/uriIdentity.service.js"; import { IWorkspaceFolderData } from "../../../../platform/workspace/common/workspace.js"; import { IWorkspaceContextService } from "../../../../platform/workspace/common/workspace.service.js"; import { IEditorGroupsService } from "../../editor/common/editorGroupsService.service.js"; import { IPathService } from "../../path/common/pathService.service.js"; import { IAITextQuery, IFileQuery, IPatternInfo, ITextQuery, ITextSearchPreviewOptions } from "./search.js"; import { GlobPattern } from "./searchExtTypes.js"; /** * One folder to search and a set of glob expressions that should be applied. */ export interface ISearchPathPattern { searchPath: uri; pattern?: glob.IExpression; } type ISearchPathPatternBuilder = string | string[]; export interface ISearchPatternBuilder { uri?: U; pattern: ISearchPathPatternBuilder; } export declare function isISearchPatternBuilder(object: ISearchPatternBuilder | ISearchPathPatternBuilder): object is ISearchPatternBuilder; export declare function globPatternToISearchPatternBuilder(globPattern: GlobPattern): ISearchPatternBuilder; /** * A set of search paths and a set of glob expressions that should be applied. */ export interface ISearchPathsInfo { searchPaths?: ISearchPathPattern[]; pattern?: glob.IExpression; } interface ICommonQueryBuilderOptions { _reason?: string; excludePattern?: ISearchPatternBuilder[]; includePattern?: ISearchPathPatternBuilder; extraFileResources?: U[]; /** Parse the special ./ syntax supported by the searchview, and expand foo to ** /foo */ expandPatterns?: boolean; maxResults?: number; maxFileSize?: number; disregardIgnoreFiles?: boolean; disregardGlobalIgnoreFiles?: boolean; disregardParentIgnoreFiles?: boolean; disregardExcludeSettings?: boolean; disregardSearchExcludeSettings?: boolean; ignoreSymlinks?: boolean; ignoreGlobCase?: boolean; onlyOpenEditors?: boolean; onlyFileScheme?: boolean; } export interface IFileQueryBuilderOptions extends ICommonQueryBuilderOptions { filePattern?: string; exists?: boolean; sortByScore?: boolean; cacheKey?: string; shouldGlobSearch?: boolean; } export interface ITextQueryBuilderOptions extends ICommonQueryBuilderOptions { previewOptions?: ITextSearchPreviewOptions; fileEncoding?: string; surroundingContext?: number; isSmartCase?: boolean; notebookSearchConfig?: { includeMarkupInput: boolean; includeMarkupPreview: boolean; includeCodeInput: boolean; includeOutput: boolean; }; } export declare class QueryBuilder { private readonly configurationService; private readonly workspaceContextService; private readonly editorGroupsService; private readonly logService; private readonly pathService; private readonly uriIdentityService; constructor(configurationService: IConfigurationService, workspaceContextService: IWorkspaceContextService, editorGroupsService: IEditorGroupsService, logService: ILogService, pathService: IPathService, uriIdentityService: IUriIdentityService); aiText(contentPattern: string, folderResources?: uri[], options?: ITextQueryBuilderOptions): IAITextQuery; text(contentPattern: IPatternInfo, folderResources?: uri[], options?: ITextQueryBuilderOptions): ITextQuery; /** * Adjusts input pattern for config */ private getContentPattern; file(folders: (IWorkspaceFolderData | URI)[], options?: IFileQueryBuilderOptions): IFileQuery; private handleIncludeExclude; private commonQuery; private commonQueryFromFileList; /** * Resolve isCaseSensitive flag based on the query and the isSmartCase flag, for search providers that don't support smart case natively. */ private isCaseSensitive; private isMultiline; /** * Take the includePattern as seen in the search viewlet, and split into components that look like searchPaths, and * glob patterns. Glob patterns are expanded from 'foo/bar' to '{foo/bar/**, **\/foo/bar}. * * Public for test. */ parseSearchPaths(pattern: string | string[]): ISearchPathsInfo; private getExcludesForFolder; /** * Split search paths (./ or ../ or absolute paths in the includePatterns) into absolute paths and globs applied to those paths */ private expandSearchPathPatterns; /** * Takes a searchPath like `./a/foo` or `../a/foo` and expands it to absolute paths for all the workspaces it matches. */ private expandOneSearchPath; private resolveOneSearchPathPattern; private getFolderQueryForSearchPath; private getFolderQueryForRoot; } /** * Escapes a path for use as a glob pattern that would match the input precisely. * Characters '?', '*', '[', and ']' are escaped into character range glob syntax * (for example, '?' becomes '[?]'). * NOTE: This implementation makes no special cases for UNC paths. For example, * given the input "//?/C:/A?.txt", this would produce output '//[?]/C:/A[?].txt', * which may not be desirable in some cases. Use with caution if UNC paths could be expected. */ export declare function escapeGlobPattern(path: string): string; /** * Construct an include pattern from a list of folders uris to search in. */ export declare function resolveResourcesForSearchIncludes(resources: URI[], contextService: IWorkspaceContextService): string[]; export {};