提交 809ccf9a 编写于 作者: R Rob Lourens

Fix #70912 - fix noImplicitAny errors in search land

上级 7502b13a
...@@ -181,13 +181,19 @@ export function resultIsMatch(result: ITextSearchResult): result is ITextSearchM ...@@ -181,13 +181,19 @@ export function resultIsMatch(result: ITextSearchResult): result is ITextSearchM
return !!(<ITextSearchMatch>result).preview; return !!(<ITextSearchMatch>result).preview;
} }
export interface IProgress { export interface IProgressMessage {
total?: number;
worked?: number;
message?: string; message?: string;
} }
export type ISearchProgressItem = IFileMatch | IProgress; export type ISearchProgressItem = IFileMatch | IProgressMessage;
export function isFileMatch(p: ISearchProgressItem): p is IFileMatch {
return !!(<IFileMatch>p).resource;
}
export function isProgressMessage(p: ISearchProgressItem): p is IProgressMessage {
return !isFileMatch(p);
}
export interface ISearchCompleteStats { export interface ISearchCompleteStats {
limitHit?: boolean; limitHit?: boolean;
...@@ -410,7 +416,7 @@ export interface IRawFileMatch { ...@@ -410,7 +416,7 @@ export interface IRawFileMatch {
} }
export interface ISearchEngine<T> { export interface ISearchEngine<T> {
search: (onResult: (matches: T) => void, onProgress: (progress: IProgress) => void, done: (error: Error | null, complete: ISearchEngineSuccess) => void) => void; search: (onResult: (matches: T) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error | null, complete: ISearchEngineSuccess) => void) => void;
cancel: () => void; cancel: () => void;
} }
...@@ -460,8 +466,8 @@ export interface ISerializedFileMatch { ...@@ -460,8 +466,8 @@ export interface ISerializedFileMatch {
} }
// Type of the possible values for progress calls from the engine // Type of the possible values for progress calls from the engine
export type ISerializedSearchProgressItem = ISerializedFileMatch | ISerializedFileMatch[] | IProgress; export type ISerializedSearchProgressItem = ISerializedFileMatch | ISerializedFileMatch[] | IProgressMessage;
export type IFileSearchProgressItem = IRawFileMatch | IRawFileMatch[] | IProgress; export type IFileSearchProgressItem = IRawFileMatch | IRawFileMatch[] | IProgressMessage;
export class SerializableFileMatch implements ISerializedFileMatch { export class SerializableFileMatch implements ISerializedFileMatch {
......
...@@ -21,7 +21,7 @@ import * as types from 'vs/base/common/types'; ...@@ -21,7 +21,7 @@ import * as types from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import * as extfs from 'vs/base/node/extfs'; import * as extfs from 'vs/base/node/extfs';
import * as flow from 'vs/base/node/flow'; import * as flow from 'vs/base/node/flow';
import { IFileQuery, IFolderQuery, IProgress, ISearchEngineStats, IRawFileMatch, ISearchEngine, ISearchEngineSuccess } from 'vs/workbench/services/search/common/search'; import { IFileQuery, IFolderQuery, IProgressMessage, ISearchEngineStats, IRawFileMatch, ISearchEngine, ISearchEngineSuccess } from 'vs/workbench/services/search/common/search';
import { spawnRipgrepCmd } from './ripgrepFileSearch'; import { spawnRipgrepCmd } from './ripgrepFileSearch';
interface IDirectoryEntry { interface IDirectoryEntry {
...@@ -106,7 +106,7 @@ export class FileWalker { ...@@ -106,7 +106,7 @@ export class FileWalker {
this.isCanceled = true; this.isCanceled = true;
} }
walk(folderQueries: IFolderQuery[], extraFiles: URI[], onResult: (result: IRawFileMatch) => void, onMessage: (message: IProgress) => void, done: (error: Error | null, isLimitHit: boolean) => void): void { walk(folderQueries: IFolderQuery[], extraFiles: URI[], onResult: (result: IRawFileMatch) => void, onMessage: (message: IProgressMessage) => void, done: (error: Error | null, isLimitHit: boolean) => void): void {
this.fileWalkSW = StopWatch.create(false); this.fileWalkSW = StopWatch.create(false);
// Support that the file pattern is a full path to a file that exists // Support that the file pattern is a full path to a file that exists
...@@ -154,7 +154,7 @@ export class FileWalker { ...@@ -154,7 +154,7 @@ export class FileWalker {
} }
} }
private cmdTraversal(folderQuery: IFolderQuery, onResult: (result: IRawFileMatch) => void, onMessage: (message: IProgress) => void, cb: (err?: Error) => void): void { private cmdTraversal(folderQuery: IFolderQuery, onResult: (result: IRawFileMatch) => void, onMessage: (message: IProgressMessage) => void, cb: (err?: Error) => void): void {
const rootFolder = folderQuery.folder.fsPath; const rootFolder = folderQuery.folder.fsPath;
const isMac = platform.isMacintosh; const isMac = platform.isMacintosh;
let cmd: childProcess.ChildProcess; let cmd: childProcess.ChildProcess;
...@@ -285,7 +285,7 @@ export class FileWalker { ...@@ -285,7 +285,7 @@ export class FileWalker {
}); });
} }
private collectStdout(cmd: childProcess.ChildProcess, encoding: string, onMessage: (message: IProgress) => void, cb: (err: Error | null, stdout?: string, last?: boolean) => void): void { private collectStdout(cmd: childProcess.ChildProcess, encoding: string, onMessage: (message: IProgressMessage) => void, cb: (err: Error | null, stdout?: string, last?: boolean) => void): void {
let onData = (err: Error | null, stdout?: string, last?: boolean) => { let onData = (err: Error | null, stdout?: string, last?: boolean) => {
if (err || last) { if (err || last) {
onData = () => { }; onData = () => { };
...@@ -590,7 +590,7 @@ export class Engine implements ISearchEngine<IRawFileMatch> { ...@@ -590,7 +590,7 @@ export class Engine implements ISearchEngine<IRawFileMatch> {
this.walker = new FileWalker(config); this.walker = new FileWalker(config);
} }
search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgress) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void { search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void {
this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error, isLimitHit: boolean) => { this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error, isLimitHit: boolean) => {
done(err, { done(err, {
limitHit: isLimitHit, limitHit: isLimitHit,
......
...@@ -344,7 +344,7 @@ export class FileSearchManager { ...@@ -344,7 +344,7 @@ export class FileSearchManager {
engine.cancel(); engine.cancel();
}); });
const _onResult = match => { const _onResult = (match: IInternalFileMatch) => {
if (match) { if (match) {
batch.push(match); batch.push(match);
if (batchSize > 0 && batch.length >= batchSize) { if (batchSize > 0 && batch.length >= batchSize) {
......
...@@ -17,14 +17,14 @@ import * as strings from 'vs/base/common/strings'; ...@@ -17,14 +17,14 @@ import * as strings from 'vs/base/common/strings';
import { URI, UriComponents } from 'vs/base/common/uri'; import { URI, UriComponents } from 'vs/base/common/uri';
import { compareItemsByScore, IItemAccessor, prepareQuery, ScorerCache } from 'vs/base/parts/quickopen/common/quickOpenScorer'; import { compareItemsByScore, IItemAccessor, prepareQuery, ScorerCache } from 'vs/base/parts/quickopen/common/quickOpenScorer';
import { MAX_FILE_SIZE } from 'vs/platform/files/node/fileConstants'; import { MAX_FILE_SIZE } from 'vs/platform/files/node/fileConstants';
import { ICachedSearchStats, IFileQuery, IFileSearchStats, IFolderQuery, IProgress, IRawFileQuery, IRawQuery, IRawTextQuery, ITextQuery, IFileSearchProgressItem, IRawFileMatch, IRawSearchService, ISearchEngine, ISearchEngineSuccess, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedSearchSuccess } from 'vs/workbench/services/search/common/search'; import { ICachedSearchStats, IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, IRawFileQuery, IRawQuery, IRawTextQuery, ITextQuery, IFileSearchProgressItem, IRawFileMatch, IRawSearchService, ISearchEngine, ISearchEngineSuccess, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedSearchSuccess } from 'vs/workbench/services/search/common/search';
import { Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch'; import { Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch';
import { TextSearchEngineAdapter } from 'vs/workbench/services/search/node/textSearchAdapter'; import { TextSearchEngineAdapter } from 'vs/workbench/services/search/node/textSearchAdapter';
gracefulFs.gracefulify(fs); gracefulFs.gracefulify(fs);
type IProgressCallback = (p: ISerializedSearchProgressItem) => void; export type IProgressCallback = (p: ISerializedSearchProgressItem) => void;
type IFileProgressCallback = (p: IFileSearchProgressItem) => void; export type IFileProgressCallback = (p: IFileSearchProgressItem) => void;
export class SearchService implements IRawSearchService { export class SearchService implements IRawSearchService {
...@@ -97,7 +97,7 @@ export class SearchService implements IRawSearchService { ...@@ -97,7 +97,7 @@ export class SearchService implements IRawSearchService {
resultCount++; resultCount++;
progressCallback(this.rawMatchToSearchItem(<IRawFileMatch>progress)); progressCallback(this.rawMatchToSearchItem(<IRawFileMatch>progress));
} else { } else {
progressCallback(<IProgress>progress); progressCallback(<IProgressMessage>progress);
} }
}; };
...@@ -383,13 +383,13 @@ export class SearchService implements IRawSearchService { ...@@ -383,13 +383,13 @@ export class SearchService implements IRawSearchService {
cancel() { cancel() {
// Do nothing // Do nothing
} }
then(resolve, reject) { then(resolve: any, reject: any) {
return promise.then(resolve, reject); return promise.then(resolve, reject);
} }
catch(reject?) { catch(reject?: any) {
return this.then(undefined, reject); return this.then(undefined, reject);
} }
finally(onFinally) { finally(onFinally: any) {
return promise.finally(onFinally); return promise.finally(onFinally);
} }
}; };
......
...@@ -42,7 +42,7 @@ function searchRangeToRange(range: SearchRange): Range { ...@@ -42,7 +42,7 @@ function searchRangeToRange(range: SearchRange): Range {
} }
export class Position { export class Position {
constructor(readonly line, readonly character) { } constructor(readonly line: number, readonly character: number) { }
isBefore(other: Position): boolean { return false; } isBefore(other: Position): boolean { return false; }
isBeforeOrEqual(other: Position): boolean { return false; } isBeforeOrEqual(other: Position): boolean { return false; }
......
...@@ -165,10 +165,11 @@ export class RipgrepParser extends EventEmitter { ...@@ -165,10 +165,11 @@ export class RipgrepParser extends EventEmitter {
} }
on(event: 'result', listener: (result: vscode.TextSearchResult) => void); on(event: 'result', listener: (result: vscode.TextSearchResult) => void): this;
on(event: 'hitLimit', listener: () => void); on(event: 'hitLimit', listener: () => void): this;
on(event: string, listener: (...args: any[]) => void) { on(event: string, listener: (...args: any[]) => void): this {
super.on(event, listener); super.on(event, listener);
return this;
} }
handleData(data: Buffer | string): void { handleData(data: Buffer | string): void {
......
...@@ -26,7 +26,7 @@ import { ILogService } from 'vs/platform/log/common/log'; ...@@ -26,7 +26,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { deserializeSearchError, FileMatch, ICachedSearchStats, IFileMatch, IFileQuery, IFileSearchStats, IFolderQuery, IProgress, IRawSearchService, ISearchComplete, ISearchConfiguration, ISearchEngineStats, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, isSerializedSearchComplete, isSerializedSearchSuccess, ITextQuery, pathIncludedInQuery, QueryType, SearchError, SearchErrorCode, SearchProviderType } from 'vs/workbench/services/search/common/search'; import { deserializeSearchError, FileMatch, ICachedSearchStats, IFileMatch, IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, IRawSearchService, ISearchComplete, ISearchConfiguration, ISearchEngineStats, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, isSerializedSearchComplete, isSerializedSearchSuccess, ITextQuery, pathIncludedInQuery, QueryType, SearchError, SearchErrorCode, SearchProviderType, isFileMatch, isProgressMessage } from 'vs/workbench/services/search/common/search';
import { addContextToEditorMatches, editorMatchesToTextSearchResults } from 'vs/workbench/services/search/common/searchHelpers'; import { addContextToEditorMatches, editorMatchesToTextSearchResults } from 'vs/workbench/services/search/common/searchHelpers';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { SearchChannelClient } from './searchIpc'; import { SearchChannelClient } from './searchIpc';
...@@ -78,18 +78,18 @@ export class SearchService extends Disposable implements ISearchService { ...@@ -78,18 +78,18 @@ export class SearchService extends Disposable implements ISearchService {
arrays.coalesce(localResults.values()).forEach(onProgress); arrays.coalesce(localResults.values()).forEach(onProgress);
} }
const onProviderProgress = progress => { const onProviderProgress = (progress: ISearchProgressItem) => {
if (progress.resource) { if (isFileMatch(progress)) {
// Match // Match
if (!localResults.has(progress.resource) && onProgress) { // don't override local results if (!localResults.has(progress.resource) && onProgress) { // don't override local results
onProgress(progress); onProgress(progress);
} }
} else if (onProgress) { } else if (onProgress) {
// Progress // Progress
onProgress(<IProgress>progress); onProgress(<IProgressMessage>progress);
} }
if (progress.message) { if (isProgressMessage(progress)) {
this.logService.debug('SearchService#search', progress.message); this.logService.debug('SearchService#search', progress.message);
} }
}; };
...@@ -142,7 +142,7 @@ export class SearchService extends Disposable implements ISearchService { ...@@ -142,7 +142,7 @@ export class SearchService extends Disposable implements ISearchService {
return <ISearchComplete>{ return <ISearchComplete>{
limitHit: completes[0] && completes[0].limitHit, limitHit: completes[0] && completes[0].limitHit,
stats: completes[0].stats, stats: completes[0].stats,
results: arrays.flatten(completes.map(c => c.results)) results: arrays.flatten(completes.map((c: ISearchComplete) => c.results))
}; };
}); });
...@@ -497,7 +497,7 @@ export class DiskSearch implements ISearchResultProvider { ...@@ -497,7 +497,7 @@ export class DiskSearch implements ISearchResultProvider {
let event: Event<ISerializedSearchProgressItem | ISerializedSearchComplete>; let event: Event<ISerializedSearchProgressItem | ISerializedSearchComplete>;
event = this.raw.fileSearch(query); event = this.raw.fileSearch(query);
const onProgress = (p: IProgress) => { const onProgress = (p: IProgressMessage) => {
if (p.message) { if (p.message) {
// Should only be for logs // Should only be for logs
this.logService.debug('SearchService#search', p.message); this.logService.debug('SearchService#search', p.message);
...@@ -561,7 +561,7 @@ export class DiskSearch implements ISearchResultProvider { ...@@ -561,7 +561,7 @@ export class DiskSearch implements ISearchResultProvider {
// Progress // Progress
else if (onProgress) { else if (onProgress) {
onProgress(<IProgress>ev); onProgress(<IProgressMessage>ev);
} }
} }
}); });
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { CancellationToken } from 'vs/base/common/cancellation'; import { CancellationToken } from 'vs/base/common/cancellation';
import * as extfs from 'vs/base/node/extfs'; import * as extfs from 'vs/base/node/extfs';
import { IFileMatch, IProgress, ITextQuery, ITextSearchStats, ITextSearchMatch, ISerializedFileMatch, ISerializedSearchSuccess } from 'vs/workbench/services/search/common/search'; import { IFileMatch, IProgressMessage, ITextQuery, ITextSearchStats, ITextSearchMatch, ISerializedFileMatch, ISerializedSearchSuccess } from 'vs/workbench/services/search/common/search';
import { RipgrepTextSearchEngine } from 'vs/workbench/services/search/node/ripgrepTextSearchEngine'; import { RipgrepTextSearchEngine } from 'vs/workbench/services/search/node/ripgrepTextSearchEngine';
import { TextSearchManager } from 'vs/workbench/services/search/node/textSearchManager'; import { TextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';
...@@ -14,7 +14,7 @@ export class TextSearchEngineAdapter { ...@@ -14,7 +14,7 @@ export class TextSearchEngineAdapter {
constructor(private query: ITextQuery) { constructor(private query: ITextQuery) {
} }
search(token: CancellationToken, onResult: (matches: ISerializedFileMatch[]) => void, onMessage: (message: IProgress) => void): Promise<ISerializedSearchSuccess> { search(token: CancellationToken, onResult: (matches: ISerializedFileMatch[]) => void, onMessage: (message: IProgressMessage) => void): Promise<ISerializedSearchSuccess> {
if ((!this.query.folderQueries || !this.query.folderQueries.length) && (!this.query.extraFileResources || !this.query.extraFileResources.length)) { if ((!this.query.folderQueries || !this.query.folderQueries.length) && (!this.query.extraFileResources || !this.query.extraFileResources.length)) {
return Promise.resolve(<ISerializedSearchSuccess>{ return Promise.resolve(<ISerializedSearchSuccess>{
type: 'success', type: 'success',
...@@ -26,7 +26,7 @@ export class TextSearchEngineAdapter { ...@@ -26,7 +26,7 @@ export class TextSearchEngineAdapter {
} }
const pretendOutputChannel = { const pretendOutputChannel = {
appendLine(msg) { appendLine(msg: string) {
onMessage({ message: msg }); onMessage({ message: msg });
} }
}; };
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as assert from 'assert'; import * as assert from 'assert';
import * as path from 'vs/base/common/path';
import { getPathFromAmdModule } from 'vs/base/common/amd'; import { getPathFromAmdModule } from 'vs/base/common/amd';
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async'; import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
import { Emitter, Event } from 'vs/base/common/event'; import { Emitter, Event } from 'vs/base/common/event';
import * as path from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { IFileQuery, IFileSearchStats, IFolderQuery, IProgress, ISearchEngineStats, QueryType, IRawFileMatch, ISearchEngine, ISearchEngineSuccess, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedSearchSuccess } from 'vs/workbench/services/search/common/search'; import { IFileMatch, IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, IRawFileMatch, ISearchEngine, ISearchEngineStats, ISearchEngineSuccess, ISerializedFileMatch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedSearchSuccess, QueryType } from 'vs/workbench/services/search/common/search';
import { SearchService as RawSearchService } from 'vs/workbench/services/search/node/rawSearchService'; import { IProgressCallback, SearchService as RawSearchService } from 'vs/workbench/services/search/node/rawSearchService';
import { DiskSearch } from 'vs/workbench/services/search/node/searchService'; import { DiskSearch } from 'vs/workbench/services/search/node/searchService';
const TEST_FOLDER_QUERIES = [ const TEST_FOLDER_QUERIES = [
...@@ -40,7 +40,7 @@ class TestSearchEngine implements ISearchEngine<IRawFileMatch> { ...@@ -40,7 +40,7 @@ class TestSearchEngine implements ISearchEngine<IRawFileMatch> {
TestSearchEngine.last = this; TestSearchEngine.last = this;
} }
search(onResult: (match: IRawFileMatch) => void, onProgress: (progress: IProgress) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void { search(onResult: (match: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void {
const self = this; const self = this;
(function next() { (function next() {
process.nextTick(() => { process.nextTick(() => {
...@@ -157,7 +157,7 @@ suite('RawSearchService', () => { ...@@ -157,7 +157,7 @@ suite('RawSearchService', () => {
} }
const progressResults: any[] = []; const progressResults: any[] = [];
const onProgress = match => { const onProgress = (match: IFileMatch) => {
assert.strictEqual(match.resource.path, uriPath); assert.strictEqual(match.resource.path, uriPath);
progressResults.push(match); progressResults.push(match);
}; };
...@@ -217,7 +217,7 @@ suite('RawSearchService', () => { ...@@ -217,7 +217,7 @@ suite('RawSearchService', () => {
const service = new RawSearchService(); const service = new RawSearchService();
const results: any[] = []; const results: any[] = [];
const cb = value => { const cb: IProgressCallback = value => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
results.push(...value.map(v => v.path)); results.push(...value.map(v => v.path));
} else { } else {
...@@ -243,7 +243,7 @@ suite('RawSearchService', () => { ...@@ -243,7 +243,7 @@ suite('RawSearchService', () => {
const service = new RawSearchService(); const service = new RawSearchService();
const results: number[] = []; const results: number[] = [];
const cb = value => { const cb: IProgressCallback = value => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
value.forEach(m => { value.forEach(m => {
assert.deepStrictEqual(m, match); assert.deepStrictEqual(m, match);
...@@ -276,7 +276,7 @@ suite('RawSearchService', () => { ...@@ -276,7 +276,7 @@ suite('RawSearchService', () => {
const service = new RawSearchService(); const service = new RawSearchService();
const results: any[] = []; const results: any[] = [];
const cb = value => { const cb: IProgressCallback = value => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
results.push(...value.map(v => v.path)); results.push(...value.map(v => v.path));
} else { } else {
...@@ -294,7 +294,7 @@ suite('RawSearchService', () => { ...@@ -294,7 +294,7 @@ suite('RawSearchService', () => {
assert.deepStrictEqual(results, [path.normalize('/some/where/bcb'), path.normalize('/some/where/bbc'), path.normalize('/some/where/aab')]); assert.deepStrictEqual(results, [path.normalize('/some/where/bcb'), path.normalize('/some/where/bbc'), path.normalize('/some/where/aab')]);
}).then(async () => { }).then(async () => {
const results: any[] = []; const results: any[] = [];
const cb = value => { const cb: IProgressCallback = value => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
results.push(...value.map(v => v.path)); results.push(...value.map(v => v.path));
} else { } else {
...@@ -323,7 +323,7 @@ suite('RawSearchService', () => { ...@@ -323,7 +323,7 @@ suite('RawSearchService', () => {
size: 3 size: 3
}); });
const results: any[] = []; const results: any[] = [];
const cb = value => { const cb: IProgressCallback = value => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
results.push(...value.map(v => v.path)); results.push(...value.map(v => v.path));
} else { } else {
......
...@@ -42,7 +42,7 @@ suite('RipgrepTextSearchEngine', () => { ...@@ -42,7 +42,7 @@ suite('RipgrepTextSearchEngine', () => {
}); });
test('fixRegexCRMatchingWhitespaceClass', () => { test('fixRegexCRMatchingWhitespaceClass', () => {
function testFixRegexCRMatchingWhitespaceClass([inputReg, isMultiline, testStr, shouldMatch]): void { function testFixRegexCRMatchingWhitespaceClass([inputReg, isMultiline, testStr, shouldMatch]: [string, boolean, string, boolean]): void {
const fixed = fixRegexCRMatchingWhitespaceClass(inputReg, isMultiline); const fixed = fixRegexCRMatchingWhitespaceClass(inputReg, isMultiline);
const reg = new RegExp(fixed); const reg = new RegExp(fixed);
assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`); assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`);
...@@ -66,7 +66,7 @@ suite('RipgrepTextSearchEngine', () => { ...@@ -66,7 +66,7 @@ suite('RipgrepTextSearchEngine', () => {
}); });
test('fixRegexCRMatchingNonWordClass', () => { test('fixRegexCRMatchingNonWordClass', () => {
function testRegexCRMatchingNonWordClass([inputReg, isMultiline, testStr, shouldMatch]): void { function testRegexCRMatchingNonWordClass([inputReg, isMultiline, testStr, shouldMatch]: [string, boolean, string, boolean]): void {
const fixed = fixRegexCRMatchingNonWordClass(inputReg, isMultiline); const fixed = fixRegexCRMatchingNonWordClass(inputReg, isMultiline);
const reg = new RegExp(fixed); const reg = new RegExp(fixed);
assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`); assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`);
...@@ -90,7 +90,7 @@ suite('RipgrepTextSearchEngine', () => { ...@@ -90,7 +90,7 @@ suite('RipgrepTextSearchEngine', () => {
}); });
test('fixRegexNewline', () => { test('fixRegexNewline', () => {
function testFixRegexNewline([inputReg, testStr, shouldMatch]): void { function testFixRegexNewline([inputReg, testStr, shouldMatch]: [string, string, boolean]): void {
const fixed = fixRegexNewline(inputReg); const fixed = fixRegexNewline(inputReg);
const reg = new RegExp(fixed); const reg = new RegExp(fixed);
assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`); assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`);
...@@ -111,7 +111,7 @@ suite('RipgrepTextSearchEngine', () => { ...@@ -111,7 +111,7 @@ suite('RipgrepTextSearchEngine', () => {
}); });
test('fixNewline', () => { test('fixNewline', () => {
function testFixNewline([inputReg, testStr, shouldMatch = true]): void { function testFixNewline([inputReg, testStr, shouldMatch = true]: [string, string, boolean]): void {
const fixed = fixNewline(inputReg); const fixed = fixNewline(inputReg);
const reg = new RegExp(fixed); const reg = new RegExp(fixed);
assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`); assert.equal(reg.test(testStr), shouldMatch, `${inputReg} => ${reg}, ${testStr}, ${shouldMatch}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册