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
export interface IFolderSearch {
	folder: string;
	excludePattern?: IExpression;
15
	includePattern?: IExpression;
R
Rob Lourens 已提交
16 17 18
	fileEncoding?: string;
}

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

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

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

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

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

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

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