search.ts 2.3 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';
C
Christof Marti 已提交
11
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
J
Joao Moreno 已提交
12

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

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

C
Christof Marti 已提交
36 37 38 39 40
export interface ITelemetryEvent {
	eventName: string;
	data: ITelemetryData;
}

J
Joao Moreno 已提交
41 42 43
export interface IRawSearchService {
	fileSearch(search: IRawSearch): PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem>;
	textSearch(search: IRawSearch): PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem>;
44
	clearCache(cacheKey: string): TPromise<void>;
C
Christof Marti 已提交
45
	fetchTelemetry(): PPromise<void, ITelemetryEvent>;
J
Joao Moreno 已提交
46 47
}

48
export interface IRawFileMatch {
C
Christof Marti 已提交
49
	base?: string;
50
	relativePath: string;
51
	basename: string;
C
Christof Marti 已提交
52
	size?: number;
53 54 55
}

export interface ISearchEngine<T> {
56
	search: (onResult: (matches: T) => void, onProgress: (progress: IProgress) => void, done: (error: Error, complete: ISerializedSearchComplete) => void) => void;
J
Joao Moreno 已提交
57 58 59 60 61
	cancel: () => void;
}

export interface ISerializedSearchComplete {
	limitHit: boolean;
C
chrmarti 已提交
62
	stats: ISearchStats;
J
Joao Moreno 已提交
63 64 65
}

export interface ISerializedFileMatch {
66
	path: string;
J
Joao Moreno 已提交
67
	lineMatches?: ILineMatch[];
68
	numMatches?: number;
J
Joao Moreno 已提交
69 70
}

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