search.ts 2.1 KB
Newer Older
J
Joao Moreno 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

8
import { PPromise, TPromise } from 'vs/base/common/winjs.base';
B
Benjamin Pasero 已提交
9
import { IExpression } from 'vs/base/common/glob';
10
import { IProgress, ILineMatch, IPatternInfo, ISearchStats, ISearchLog } from 'vs/platform/search/common/search';
J
Joao Moreno 已提交
11

R
Rob Lourens 已提交
12 13 14 15 16 17
export interface IFolderSearch {
	folder: string;
	excludePattern?: IExpression;
	fileEncoding?: string;
}

J
Joao Moreno 已提交
18
export interface IRawSearch {
R
Rob Lourens 已提交
19
	folderQueries: IFolderSearch[];
J
Joao Moreno 已提交
20 21
	extraFiles?: string[];
	filePattern?: string;
B
Benjamin Pasero 已提交
22 23
	excludePattern?: IExpression;
	includePattern?: IExpression;
J
Joao Moreno 已提交
24 25
	contentPattern?: IPatternInfo;
	maxResults?: number;
26 27
	sortByScore?: boolean;
	cacheKey?: string;
J
Joao Moreno 已提交
28
	maxFilesize?: number;
29
	useRipgrep?: boolean;
R
Rob Lourens 已提交
30
	disregardIgnoreFiles?: boolean;
J
Joao Moreno 已提交
31 32 33 34 35
}

export interface IRawSearchService {
	fileSearch(search: IRawSearch): PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem>;
	textSearch(search: IRawSearch): PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem>;
36
	clearCache(cacheKey: string): TPromise<void>;
J
Joao Moreno 已提交
37 38
}

39
export interface IRawFileMatch {
C
Christof Marti 已提交
40
	base?: string;
41
	relativePath: string;
42
	basename: string;
C
Christof Marti 已提交
43
	size?: number;
44 45 46
}

export interface ISearchEngine<T> {
47
	search: (onResult: (matches: T) => void, onProgress: (progress: IProgress) => void, done: (error: Error, complete: ISerializedSearchComplete) => void) => void;
J
Joao Moreno 已提交
48 49 50 51 52
	cancel: () => void;
}

export interface ISerializedSearchComplete {
	limitHit: boolean;
C
chrmarti 已提交
53
	stats: ISearchStats;
J
Joao Moreno 已提交
54 55 56
}

export interface ISerializedFileMatch {
57
	path: string;
J
Joao Moreno 已提交
58
	lineMatches?: ILineMatch[];
59
	numMatches?: number;
J
Joao Moreno 已提交
60 61
}

C
chrmarti 已提交
62
// Type of the possible values for progress calls from the engine
63 64
export type ISerializedSearchProgressItem = ISerializedFileMatch | ISerializedFileMatch[] | IProgress | ISearchLog;
export type IFileSearchProgressItem = IRawFileMatch | IRawFileMatch[] | IProgress;