search.ts 1.8 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';
J
Joao Moreno 已提交
9
import glob = require('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 16 17 18 19

export interface IRawSearch {
	rootFolders: string[];
	extraFiles?: string[];
	filePattern?: string;
	excludePattern?: glob.IExpression;
	includePattern?: glob.IExpression;
	contentPattern?: IPatternInfo;
	maxResults?: number;
20 21
	sortByScore?: boolean;
	cacheKey?: string;
J
Joao Moreno 已提交
22 23 24 25 26 27 28
	maxFilesize?: number;
	fileEncoding?: string;
}

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

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

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

export interface ISerializedSearchComplete {
	limitHit: boolean;
C
chrmarti 已提交
45
	stats: ISearchStats;
J
Joao Moreno 已提交
46 47 48
}

export interface ISerializedFileMatch {
49
	path: string;
J
Joao Moreno 已提交
50 51 52
	lineMatches?: ILineMatch[];
}

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