import { CancellationToken } from "../../../../base/common/cancellation.js"; import * as glob from "../../../../base/common/glob.js"; import { URI, UriComponents } from "../../../../base/common/uri.js"; import { IFilesConfiguration } from "../../../../platform/files/common/files.js"; import { ITelemetryData } from "../../../../platform/telemetry/common/telemetry.js"; import { Event } from "../../../../base/common/event.js"; import { AISearchKeyword, GlobPattern, TextSearchCompleteMessageType } from "./searchExtTypes.js"; export { TextSearchCompleteMessageType }; export declare const VIEWLET_ID = "workbench.view.search"; export declare const PANEL_ID = "workbench.panel.search"; export declare const VIEW_ID = "workbench.view.search"; export declare const SEARCH_RESULT_LANGUAGE_ID = "search-result"; export declare const SEARCH_EXCLUDE_CONFIG = "search.exclude"; export declare const DEFAULT_MAX_SEARCH_RESULTS = 20000; /** * TODO@roblou - split text from file search entirely, or share code in a more natural way. */ export declare enum SearchProviderType { file = 0, text = 1, aiText = 2 } export interface ISearchResultProvider { getAIName(): Promise; textSearch(query: ITextQuery, onProgress?: (p: ISearchProgressItem) => void, token?: CancellationToken): Promise; fileSearch(query: IFileQuery, token?: CancellationToken): Promise; clearCache(cacheKey: string): Promise; } export interface ExcludeGlobPattern { folder?: U; pattern: glob.IExpression; } export interface IFolderQuery { folder: U; folderName?: string; excludePattern?: ExcludeGlobPattern[]; includePattern?: glob.IExpression; ignoreGlobCase?: boolean; fileEncoding?: string; disregardIgnoreFiles?: boolean; disregardGlobalIgnoreFiles?: boolean; disregardParentIgnoreFiles?: boolean; ignoreSymlinks?: boolean; } export interface ICommonQueryProps { /** For telemetry - indicates what is triggering the source */ _reason?: string; folderQueries: IFolderQuery[]; includePattern?: glob.IExpression; excludePattern?: glob.IExpression; ignoreGlobCase?: boolean; extraFileResources?: U[]; onlyOpenEditors?: boolean; maxResults?: number; usingSearchPaths?: boolean; onlyFileScheme?: boolean; } export interface IFileQueryProps extends ICommonQueryProps { type: QueryType.File; filePattern?: string; shouldGlobMatchFilePattern?: boolean; /** * If true no results will be returned. Instead `limitHit` will indicate if at least one result exists or not. * Currently does not work with queries including a 'siblings clause'. */ exists?: boolean; sortByScore?: boolean; cacheKey?: string; } export interface ITextQueryProps extends ICommonQueryProps { type: QueryType.Text; contentPattern: IPatternInfo; previewOptions?: ITextSearchPreviewOptions; maxFileSize?: number; usePCRE2?: boolean; surroundingContext?: number; userDisabledExcludesAndIgnoreFiles?: boolean; } export interface IAITextQueryProps extends ICommonQueryProps { type: QueryType.aiText; contentPattern: string; previewOptions?: ITextSearchPreviewOptions; maxFileSize?: number; surroundingContext?: number; userDisabledExcludesAndIgnoreFiles?: boolean; } export type IFileQuery = IFileQueryProps; export type IRawFileQuery = IFileQueryProps; export type ITextQuery = ITextQueryProps; export type IRawTextQuery = ITextQueryProps; export type IAITextQuery = IAITextQueryProps; export type IRawAITextQuery = IAITextQueryProps; export type IRawQuery = IRawTextQuery | IRawFileQuery | IRawAITextQuery; export type ISearchQuery = ITextQuery | IFileQuery | IAITextQuery; export type ITextSearchQuery = ITextQuery | IAITextQuery; export declare enum QueryType { File = 1, Text = 2, aiText = 3 } export interface IPatternInfo { pattern: string; isRegExp?: boolean; isWordMatch?: boolean; wordSeparators?: string; isMultiline?: boolean; isUnicode?: boolean; isCaseSensitive?: boolean; notebookInfo?: INotebookPatternInfo; } export interface INotebookPatternInfo { isInNotebookMarkdownInput?: boolean; isInNotebookMarkdownPreview?: boolean; isInNotebookCellInput?: boolean; isInNotebookCellOutput?: boolean; } export interface IExtendedExtensionSearchOptions { usePCRE2?: boolean; } export interface IFileMatch { resource: U; results?: ITextSearchResult[]; } export type IRawFileMatch2 = IFileMatch; export interface ITextSearchPreviewOptions { matchLines: number; charsPerLine: number; } export interface ISearchRange { readonly startLineNumber: number; readonly startColumn: number; readonly endLineNumber: number; readonly endColumn: number; } export interface ITextSearchMatch { uri?: U; rangeLocations: SearchRangeSetPairing[]; previewText: string; webviewIndex?: number; cellFragment?: string; } export interface ITextSearchContext { uri?: U; text: string; lineNumber: number; } export type ITextSearchResult = ITextSearchMatch | ITextSearchContext; export declare function resultIsMatch(result: ITextSearchResult): result is ITextSearchMatch; export interface IProgressMessage { message: string; } export type ISearchProgressItem = IFileMatch | IProgressMessage | AISearchKeyword; export declare function isFileMatch(p: ISearchProgressItem): p is IFileMatch; export declare function isAIKeyword(p: ISearchProgressItem): p is AISearchKeyword; export declare function isProgressMessage(p: ISearchProgressItem | ISerializedSearchProgressItem): p is IProgressMessage; export interface ITextSearchCompleteMessage { text: string; type: TextSearchCompleteMessageType; trusted?: boolean; } export interface ISearchCompleteStats { limitHit?: boolean; messages: ITextSearchCompleteMessage[]; stats?: IFileSearchStats | ITextSearchStats; } export interface ISearchComplete extends ISearchCompleteStats { results: IFileMatch[]; exit?: SearchCompletionExitCode; aiKeywords?: AISearchKeyword[]; } export declare enum SearchCompletionExitCode { Normal = 0, NewSearchStarted = 1 } export interface ITextSearchStats { type: "textSearchProvider" | "searchProcess" | "aiTextSearchProvider"; } export interface IFileSearchStats { fromCache: boolean; detailStats: ISearchEngineStats | ICachedSearchStats | IFileSearchProviderStats; resultCount: number; type: "fileSearchProvider" | "searchProcess"; sortingTime?: number; } export interface ICachedSearchStats { cacheWasResolved: boolean; cacheLookupTime: number; cacheFilterTime: number; cacheEntryCount: number; } export interface ISearchEngineStats { fileWalkTime: number; directoriesWalked: number; filesWalked: number; cmdTime: number; cmdResultCount?: number; } export interface IFileSearchProviderStats { providerTime: number; postProcessTime: number; } export declare class FileMatch implements IFileMatch { resource: URI; results: ITextSearchResult[]; constructor(resource: URI); } export interface SearchRangeSetPairing { source: ISearchRange; preview: ISearchRange; } export declare class TextSearchMatch implements ITextSearchMatch { rangeLocations: SearchRangeSetPairing[]; previewText: string; webviewIndex?: number; constructor(text: string, ranges: ISearchRange | ISearchRange[], previewOptions?: ITextSearchPreviewOptions, webviewIndex?: number); } export declare class SearchRange implements ISearchRange { startLineNumber: number; startColumn: number; endLineNumber: number; endColumn: number; constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number); } export declare class OneLineRange extends SearchRange { constructor(lineNumber: number, startColumn: number, endColumn: number); } export declare enum ViewMode { List = "list", Tree = "tree" } export declare enum SearchSortOrder { Default = "default", FileNames = "fileNames", Type = "type", Modified = "modified", CountDescending = "countDescending", CountAscending = "countAscending" } export declare enum SemanticSearchBehavior { Auto = "auto", Manual = "manual", RunOnEmpty = "runOnEmpty" } export interface ISearchConfigurationProperties { exclude: glob.IExpression; useRipgrep: boolean; /** * Use ignore file for file search. */ useIgnoreFiles: boolean; useGlobalIgnoreFiles: boolean; useParentIgnoreFiles: boolean; followSymlinks: boolean; smartCase: boolean; globalFindClipboard: boolean; location: "sidebar" | "panel"; useReplacePreview: boolean; showLineNumbers: boolean; usePCRE2: boolean; actionsPosition: "auto" | "right"; maintainFileSearchCache: boolean; maxResults: number | null; collapseResults: "auto" | "alwaysCollapse" | "alwaysExpand"; searchOnType: boolean; seedOnFocus: boolean; seedWithNearestWord: boolean; searchOnTypeDebouncePeriod: number; mode: "view" | "reuseEditor" | "newEditor"; searchEditor: { doubleClickBehaviour: "selectWord" | "goToLocation" | "openLocationToSide"; singleClickBehaviour: "default" | "peekDefinition"; reusePriorSearchConfiguration: boolean; defaultNumberOfContextLines: number | null; focusResultsOnSearch: boolean; experimental: {}; }; sortOrder: SearchSortOrder; decorations: { colors: boolean; badges: boolean; }; quickAccess: { preserveInput: boolean; }; defaultViewMode: ViewMode; experimental: { closedNotebookRichContentResults: boolean; }; searchView: { semanticSearchBehavior: string; keywordSuggestions: boolean; }; } export interface ISearchConfiguration extends IFilesConfiguration { search: ISearchConfigurationProperties; editor: { wordSeparators: string; }; } export declare function getExcludes(configuration: ISearchConfiguration, includeSearchExcludes?: boolean): glob.IExpression | undefined; export declare function pathIncludedInQuery(queryProps: ICommonQueryProps, fsPath: string): boolean; export declare enum SearchErrorCode { unknownEncoding = 1, regexParseError = 2, globParseError = 3, invalidLiteral = 4, rgProcessError = 5, other = 6, canceled = 7 } export declare class SearchError extends Error { readonly code?: SearchErrorCode | undefined; constructor(message: string, code?: SearchErrorCode | undefined); } export declare function deserializeSearchError(error: Error): SearchError; export declare function serializeSearchError(searchError: SearchError): Error; export interface ITelemetryEvent { eventName: string; data: ITelemetryData; } export interface IRawSearchService { fileSearch(search: IRawFileQuery): Event; textSearch(search: IRawTextQuery): Event; clearCache(cacheKey: string): Promise; } export interface IRawFileMatch { base?: string; /** * The path of the file relative to the containing `base` folder. * This path is exactly as it appears on the filesystem. */ relativePath: string; /** * This path is transformed for search purposes. For example, this could be * the `relativePath` with the workspace folder name prepended. This way the * search algorithm would also match against the name of the containing folder. * * If not given, the search algorithm should use `relativePath`. */ searchPath: string | undefined; } export interface ISearchEngine { search: (onResult: (matches: T) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error | null, complete: ISearchEngineSuccess) => void) => void; cancel: () => void; } export interface ISerializedSearchSuccess { type: "success"; limitHit: boolean; messages: ITextSearchCompleteMessage[]; stats?: IFileSearchStats | ITextSearchStats; } export interface ISearchEngineSuccess { limitHit: boolean; messages: ITextSearchCompleteMessage[]; stats: ISearchEngineStats; } export interface ISerializedSearchError { type: "error"; error: { message: string; stack: string; }; } export type ISerializedSearchComplete = ISerializedSearchSuccess | ISerializedSearchError; export declare function isSerializedSearchComplete(arg: ISerializedSearchProgressItem | ISerializedSearchComplete): arg is ISerializedSearchComplete; export declare function isSerializedSearchSuccess(arg: ISerializedSearchComplete): arg is ISerializedSearchSuccess; export declare function isSerializedFileMatch(arg: ISerializedSearchProgressItem): arg is ISerializedFileMatch; export declare function isFilePatternMatch(candidate: IRawFileMatch, filePatternToUse: string, fuzzy?: boolean): boolean; export interface ISerializedFileMatch { path: string; results?: ITextSearchResult[]; numMatches?: number; } export type ISerializedSearchProgressItem = ISerializedFileMatch | ISerializedFileMatch[] | IProgressMessage; export type IFileSearchProgressItem = IRawFileMatch | IRawFileMatch[] | IProgressMessage; export declare class SerializableFileMatch implements ISerializedFileMatch { path: string; results: ITextSearchMatch[]; constructor(path: string); addMatch(match: ITextSearchMatch): void; serialize(): ISerializedFileMatch; } /** * Computes the patterns that the provider handles. Discards sibling clauses and 'false' patterns */ export declare function resolvePatternsForProvider(globalPattern: glob.IExpression | undefined, folderPattern: glob.IExpression | undefined): string[]; export declare class QueryGlobTester { private _excludeExpression; private _parsedExcludeExpression; private _parsedIncludeExpression; constructor(config: ISearchQuery, folderQuery: IFolderQuery); private _evalParsedExcludeExpression; matchesExcludesSync(testPath: string, basename?: string, hasSibling?: (name: string) => boolean): boolean; /** * Guaranteed sync - siblingsFn should not return a promise. */ includedInQuerySync(testPath: string, basename?: string, hasSibling?: (name: string) => boolean): boolean; /** * Evaluating the exclude expression is only async if it includes sibling clauses. As an optimization, avoid doing anything with Promises * unless the expression is async. */ includedInQuery(testPath: string, basename?: string, hasSibling?: (name: string) => boolean | Promise): Promise | boolean; hasSiblingExcludeClauses(): boolean; } export declare function hasSiblingPromiseFn(siblingsFn?: () => Promise): ((name: string) => Promise) | undefined; export declare function hasSiblingFn(siblingsFn?: () => string[]): ((name: string) => boolean) | undefined; export declare function excludeToGlobPattern(excludesForFolder: { baseUri?: URI | undefined; patterns: string[]; }[]): GlobPattern[]; export declare const DEFAULT_TEXT_SEARCH_PREVIEW_OPTIONS: { matchLines: number; charsPerLine: number; };