search.ts 2.0 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 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;
R
Rob Lourens 已提交
25
	disregardIgnoreFiles?: boolean;
26
	searchPaths?: string[];
J
Joao Moreno 已提交
27 28 29 30 31
}

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

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

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

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

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

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