search.ts 1.9 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';
C
chrmarti 已提交
10
import { IProgress, ILineMatch, IPatternInfo, ISearchStats } from 'vs/platform/search/common/search';
J
Joao Moreno 已提交
11 12 13 14 15

export interface IRawSearch {
	rootFolders: string[];
	extraFiles?: string[];
	filePattern?: string;
B
Benjamin Pasero 已提交
16 17
	excludePattern?: IExpression;
	includePattern?: IExpression;
J
Joao Moreno 已提交
18 19
	contentPattern?: IPatternInfo;
	maxResults?: number;
20 21
	sortByScore?: boolean;
	cacheKey?: string;
J
Joao Moreno 已提交
22 23
	maxFilesize?: number;
	fileEncoding?: string;
24
	useRipgrep?: boolean;
25
	useIgnoreFiles?: boolean;
J
Joao Moreno 已提交
26 27 28 29 30
}

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

34
export interface IRawFileMatch {
C
Christof Marti 已提交
35
	base?: string;
36
	relativePath: string;
37
	basename: string;
C
Christof Marti 已提交
38
	size?: number;
39 40 41
}

export interface ISearchEngine<T> {
42
	search: (onResult: (matches: T) => void, onProgress: (progress: IProgress) => void, done: (error: Error, complete: ISerializedSearchComplete) => void) => void;
J
Joao Moreno 已提交
43 44 45 46 47
	cancel: () => void;
}

export interface ISerializedSearchComplete {
	limitHit: boolean;
C
chrmarti 已提交
48
	stats: ISearchStats;
J
Joao Moreno 已提交
49 50 51
}

export interface ISerializedFileMatch {
52
	path: string;
J
Joao Moreno 已提交
53
	lineMatches?: ILineMatch[];
54
	numMatches?: number;
J
Joao Moreno 已提交
55 56
}

C
chrmarti 已提交
57 58
// Type of the possible values for progress calls from the engine
export type ISerializedSearchProgressItem = ISerializedFileMatch | ISerializedFileMatch[] | IProgress;