From ff48b17c8bac582dfa4deb088dd0bb88c3049d54 Mon Sep 17 00:00:00 2001 From: Andrea Mah <31675041+andreamah@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:59:56 -0700 Subject: [PATCH] move search APIs from using `new` to `2` (#232443) * move search APIs from using `new` to `2` --- .../common/extensionsApiProposals.ts | 20 ++++----- .../workbench/api/common/extHost.api.impl.ts | 28 ++++++------- src/vs/workbench/api/common/extHostSearch.ts | 22 +++++----- .../workbench/api/common/extHostWorkspace.ts | 12 +++--- src/vs/workbench/api/node/extHostSearch.ts | 2 +- .../api/test/browser/extHostWorkspace.test.ts | 12 +++--- .../api/test/node/extHostSearch.test.ts | 2 +- .../search/common/fileSearchManager.ts | 6 +-- .../search/common/searchExtConversionTypes.ts | 22 +++++----- .../services/search/common/searchExtTypes.ts | 42 +++++++++---------- .../search/common/textSearchManager.ts | 34 +++++++-------- .../search/node/ripgrepSearchProvider.ts | 10 ++--- .../search/node/ripgrepTextSearchEngine.ts | 24 +++++------ .../services/search/node/textSearchManager.ts | 4 +- .../node/ripgrepTextSearchEngineUtils.test.ts | 30 ++++++------- .../test/node/textSearchManager.test.ts | 6 +-- ...scode.proposed.aiTextSearchProvider2.d.ts} | 6 +-- ... vscode.proposed.fileSearchProvider2.d.ts} | 4 +- ... => vscode.proposed.findTextInFiles2.d.ts} | 26 ++++++------ ... vscode.proposed.textSearchComplete2.d.ts} | 6 +-- ... vscode.proposed.textSearchProvider2.d.ts} | 28 ++++++------- 21 files changed, 173 insertions(+), 173 deletions(-) rename src/vscode-dts/{vscode.proposed.aiTextSearchProviderNew.d.ts => vscode.proposed.aiTextSearchProvider2.d.ts} (83%) rename src/vscode-dts/{vscode.proposed.fileSearchProviderNew.d.ts => vscode.proposed.fileSearchProvider2.d.ts} (95%) rename src/vscode-dts/{vscode.proposed.findTextInFilesNew.d.ts => vscode.proposed.findTextInFiles2.d.ts} (85%) rename src/vscode-dts/{vscode.proposed.textSearchCompleteNew.d.ts => vscode.proposed.textSearchComplete2.d.ts} (90%) rename src/vscode-dts/{vscode.proposed.textSearchProviderNew.d.ts => vscode.proposed.textSearchProvider2.d.ts} (89%) diff --git a/src/vs/platform/extensions/common/extensionsApiProposals.ts b/src/vs/platform/extensions/common/extensionsApiProposals.ts index 2296726d8e0..6ea83f743ad 100644 --- a/src/vs/platform/extensions/common/extensionsApiProposals.ts +++ b/src/vs/platform/extensions/common/extensionsApiProposals.ts @@ -15,8 +15,8 @@ const _allApiProposals = { aiTextSearchProvider: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.aiTextSearchProvider.d.ts', }, - aiTextSearchProviderNew: { - proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts', + aiTextSearchProvider2: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.aiTextSearchProvider2.d.ts', }, attributableCoverage: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts', @@ -200,8 +200,8 @@ const _allApiProposals = { fileSearchProvider: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileSearchProvider.d.ts', }, - fileSearchProviderNew: { - proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts', + fileSearchProvider2: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileSearchProvider2.d.ts', }, findFiles2: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findFiles2.d.ts', @@ -212,8 +212,8 @@ const _allApiProposals = { findTextInFiles: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFiles.d.ts', }, - findTextInFilesNew: { - proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts', + findTextInFiles2: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFiles2.d.ts', }, fsChunks: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fsChunks.d.ts', @@ -365,14 +365,14 @@ const _allApiProposals = { testRelatedCode: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testRelatedCode.d.ts', }, - textSearchCompleteNew: { - proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts', + textSearchComplete2: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchComplete2.d.ts', }, textSearchProvider: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts', }, - textSearchProviderNew: { - proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts', + textSearchProvider2: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider2.d.ts', }, timeline: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.timeline.d.ts', diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 68734bfe120..82b336d4c2b 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -106,7 +106,7 @@ import { ExtensionDescriptionRegistry } from '../../services/extensions/common/e import { UIKind } from '../../services/extensions/common/extensionHostProtocol.js'; import { checkProposedApiEnabled, isProposedApiEnabled } from '../../services/extensions/common/extensions.js'; import { ProxyIdentifier } from '../../services/extensions/common/proxyIdentifier.js'; -import { ExcludeSettingOptions, TextSearchCompleteMessageType, TextSearchContextNew, TextSearchMatchNew } from '../../services/search/common/searchExtTypes.js'; +import { ExcludeSettingOptions, TextSearchCompleteMessageType, TextSearchContext2, TextSearchMatch2 } from '../../services/search/common/searchExtTypes.js'; import type * as vscode from 'vscode'; import { ExtHostCodeMapper } from './extHostCodeMapper.js'; @@ -985,10 +985,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostWorkspace.findTextInFiles(query, options || {}, callback, extension.identifier, token); }, - findTextInFilesNew: (query: vscode.TextSearchQueryNew, options?: vscode.FindTextInFilesOptionsNew, token?: vscode.CancellationToken): vscode.FindTextInFilesResponse => { - checkProposedApiEnabled(extension, 'findTextInFilesNew'); - checkProposedApiEnabled(extension, 'textSearchProviderNew'); - return extHostWorkspace.findTextInFilesNew(query, options, extension.identifier, token); + findTextInFiles2: (query: vscode.TextSearchQuery2, options?: vscode.FindTextInFilesOptions2, token?: vscode.CancellationToken): vscode.FindTextInFilesResponse => { + checkProposedApiEnabled(extension, 'findTextInFiles2'); + checkProposedApiEnabled(extension, 'textSearchProvider2'); + return extHostWorkspace.findTextInFiles2(query, options, extension.identifier, token); }, save: (uri) => { return extHostWorkspace.save(uri); @@ -1139,18 +1139,18 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I checkProposedApiEnabled(extension, 'textSearchProvider'); return extHostSearch.registerAITextSearchProviderOld(scheme, provider); }, - registerFileSearchProviderNew: (scheme: string, provider: vscode.FileSearchProviderNew) => { - checkProposedApiEnabled(extension, 'fileSearchProviderNew'); + registerFileSearchProvider2: (scheme: string, provider: vscode.FileSearchProvider2) => { + checkProposedApiEnabled(extension, 'fileSearchProvider2'); return extHostSearch.registerFileSearchProvider(scheme, provider); }, - registerTextSearchProviderNew: (scheme: string, provider: vscode.TextSearchProviderNew) => { - checkProposedApiEnabled(extension, 'textSearchProviderNew'); + registerTextSearchProvider2: (scheme: string, provider: vscode.TextSearchProvider2) => { + checkProposedApiEnabled(extension, 'textSearchProvider2'); return extHostSearch.registerTextSearchProvider(scheme, provider); }, - registerAITextSearchProviderNew: (scheme: string, provider: vscode.AITextSearchProviderNew) => { + registerAITextSearchProvider2: (scheme: string, provider: vscode.AITextSearchProvider2) => { // there are some dependencies on textSearchProvider, so we need to check for both - checkProposedApiEnabled(extension, 'aiTextSearchProviderNew'); - checkProposedApiEnabled(extension, 'textSearchProviderNew'); + checkProposedApiEnabled(extension, 'aiTextSearchProvider2'); + checkProposedApiEnabled(extension, 'textSearchProvider2'); return extHostSearch.registerAITextSearchProvider(scheme, provider); }, registerRemoteAuthorityResolver: (authorityPrefix: string, resolver: vscode.RemoteAuthorityResolver) => { @@ -1792,8 +1792,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I InlineEdit: extHostTypes.InlineEdit, InlineEditTriggerKind: extHostTypes.InlineEditTriggerKind, ExcludeSettingOptions: ExcludeSettingOptions, - TextSearchContextNew: TextSearchContextNew, - TextSearchMatchNew: TextSearchMatchNew, + TextSearchContext2: TextSearchContext2, + TextSearchMatch2: TextSearchMatch2, TextSearchCompleteMessageTypeNew: TextSearchCompleteMessageType, }; }; diff --git a/src/vs/workbench/api/common/extHostSearch.ts b/src/vs/workbench/api/common/extHostSearch.ts index fbb111a79d1..cac2fb80914 100644 --- a/src/vs/workbench/api/common/extHostSearch.ts +++ b/src/vs/workbench/api/common/extHostSearch.ts @@ -22,9 +22,9 @@ export interface IExtHostSearch extends ExtHostSearchShape { registerTextSearchProviderOld(scheme: string, provider: vscode.TextSearchProvider): IDisposable; registerAITextSearchProviderOld(scheme: string, provider: vscode.AITextSearchProvider): IDisposable; registerFileSearchProviderOld(scheme: string, provider: vscode.FileSearchProvider): IDisposable; - registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProviderNew): IDisposable; - registerAITextSearchProvider(scheme: string, provider: vscode.AITextSearchProviderNew): IDisposable; - registerFileSearchProvider(scheme: string, provider: vscode.FileSearchProviderNew): IDisposable; + registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProvider2): IDisposable; + registerAITextSearchProvider(scheme: string, provider: vscode.AITextSearchProvider2): IDisposable; + registerFileSearchProvider(scheme: string, provider: vscode.FileSearchProvider2): IDisposable; doInternalFileSearchWithCustomCallback(query: IFileQuery, token: CancellationToken, handleFileMatch: (data: URI[]) => void): Promise; } @@ -35,13 +35,13 @@ export class ExtHostSearch implements IExtHostSearch { protected readonly _proxy: MainThreadSearchShape = this.extHostRpc.getProxy(MainContext.MainThreadSearch); protected _handlePool: number = 0; - private readonly _textSearchProvider = new Map(); + private readonly _textSearchProvider = new Map(); private readonly _textSearchUsedSchemes = new Set(); - private readonly _aiTextSearchProvider = new Map(); + private readonly _aiTextSearchProvider = new Map(); private readonly _aiTextSearchUsedSchemes = new Set(); - private readonly _fileSearchProvider = new Map(); + private readonly _fileSearchProvider = new Map(); private readonly _fileSearchUsedSchemes = new Set(); private readonly _fileSearchManager = new FileSearchManager(); @@ -72,7 +72,7 @@ export class ExtHostSearch implements IExtHostSearch { }); } - registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProviderNew): IDisposable { + registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProvider2): IDisposable { if (this._textSearchUsedSchemes.has(scheme)) { throw new Error(`a text search provider for the scheme '${scheme}' is already registered`); } @@ -104,7 +104,7 @@ export class ExtHostSearch implements IExtHostSearch { }); } - registerAITextSearchProvider(scheme: string, provider: vscode.AITextSearchProviderNew): IDisposable { + registerAITextSearchProvider(scheme: string, provider: vscode.AITextSearchProvider2): IDisposable { if (this._aiTextSearchUsedSchemes.has(scheme)) { throw new Error(`an AI text search provider for the scheme '${scheme}'is already registered`); } @@ -136,7 +136,7 @@ export class ExtHostSearch implements IExtHostSearch { }); } - registerFileSearchProvider(scheme: string, provider: vscode.FileSearchProviderNew): IDisposable { + registerFileSearchProvider(scheme: string, provider: vscode.FileSearchProvider2): IDisposable { if (this._fileSearchUsedSchemes.has(scheme)) { throw new Error(`a file search provider for the scheme '${scheme}' is already registered`); } @@ -208,14 +208,14 @@ export class ExtHostSearch implements IExtHostSearch { return provider.name ?? 'AI'; } - protected createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProviderNew): TextSearchManager { + protected createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProvider2): TextSearchManager { return new TextSearchManager({ query, provider }, { readdir: resource => Promise.resolve([]), toCanonicalName: encoding => encoding }, 'textSearchProvider'); } - protected createAITextSearchManager(query: IAITextQuery, provider: vscode.AITextSearchProviderNew): TextSearchManager { + protected createAITextSearchManager(query: IAITextQuery, provider: vscode.AITextSearchProvider2): TextSearchManager { return new TextSearchManager({ query, provider }, { readdir: resource => Promise.resolve([]), toCanonicalName: encoding => encoding diff --git a/src/vs/workbench/api/common/extHostWorkspace.ts b/src/vs/workbench/api/common/extHostWorkspace.ts index abb49a3cc27..2d2305b81f7 100644 --- a/src/vs/workbench/api/common/extHostWorkspace.ts +++ b/src/vs/workbench/api/common/extHostWorkspace.ts @@ -34,7 +34,7 @@ import type * as vscode from 'vscode'; import { ExtHostWorkspaceShape, IRelativePatternDto, IWorkspaceData, MainContext, MainThreadMessageOptions, MainThreadMessageServiceShape, MainThreadWorkspaceShape } from './extHost.protocol.js'; import { revive } from '../../../base/common/marshalling.js'; import { AuthInfo, Credentials } from '../../../platform/request/common/request.js'; -import { ExcludeSettingOptions, TextSearchContextNew, TextSearchMatchNew } from '../../services/search/common/searchExtTypes.js'; +import { ExcludeSettingOptions, TextSearchContext2, TextSearchMatch2 } from '../../services/search/common/searchExtTypes.js'; export interface IExtHostWorkspaceProvider { getWorkspaceFolder2(uri: vscode.Uri, resolveParent?: boolean): Promise; @@ -571,8 +571,8 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac return result.flat(); } - findTextInFilesNew(query: vscode.TextSearchQueryNew, options: vscode.FindTextInFilesOptionsNew | undefined, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): vscode.FindTextInFilesResponse { - this._logService.trace(`extHostWorkspace#findTextInFilesNew: textSearch, extension: ${extensionId.value}, entryPoint: findTextInFilesNew`); + findTextInFiles2(query: vscode.TextSearchQuery2, options: vscode.FindTextInFilesOptions2 | undefined, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): vscode.FindTextInFilesResponse { + this._logService.trace(`extHostWorkspace#findTextInFiles2: textSearch, extension: ${extensionId.value}, entryPoint: findTextInFiles2`); const getOptions = (include: vscode.GlobPattern | undefined): QueryOptions => { @@ -623,12 +623,12 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac (result, uri) => progressEmitter.fire({ result, uri }), token ); - const asyncIterable = new AsyncIterableObject(async emitter => { + const asyncIterable = new AsyncIterableObject(async emitter => { disposables.add(progressEmitter.event(e => { const result = e.result; const uri = e.uri; if (resultIsMatch(result)) { - emitter.emitOne(new TextSearchMatchNew( + emitter.emitOne(new TextSearchMatch2( uri, result.rangeLocations.map((range) => ({ previewRange: new Range(range.preview.startLineNumber, range.preview.startColumn, range.preview.endLineNumber, range.preview.endColumn), @@ -638,7 +638,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac )); } else { - emitter.emitOne(new TextSearchContextNew( + emitter.emitOne(new TextSearchContext2( uri, result.text, result.lineNumber diff --git a/src/vs/workbench/api/node/extHostSearch.ts b/src/vs/workbench/api/node/extHostSearch.ts index c91dd904607..879d589c7ab 100644 --- a/src/vs/workbench/api/node/extHostSearch.ts +++ b/src/vs/workbench/api/node/extHostSearch.ts @@ -161,7 +161,7 @@ export class NativeExtHostSearch extends ExtHostSearch implements IDisposable { return super.$clearCache(cacheKey); } - protected override createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProviderNew): TextSearchManager { + protected override createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProvider2): TextSearchManager { return new NativeTextSearchManager(query, provider, undefined, 'textSearchProvider'); } } diff --git a/src/vs/workbench/api/test/browser/extHostWorkspace.test.ts b/src/vs/workbench/api/test/browser/extHostWorkspace.test.ts index 0c019f59b2c..37d95aec3ec 100644 --- a/src/vs/workbench/api/test/browser/extHostWorkspace.test.ts +++ b/src/vs/workbench/api/test/browser/extHostWorkspace.test.ts @@ -1126,7 +1126,7 @@ suite('ExtHostWorkspace', function () { }); }); - suite('findTextInFilesNew -', function () { + suite('findTextInFiles2 -', function () { test('no include', async () => { const root = '/project/foo'; const rpcProtocol = new TestRPCProtocol(); @@ -1144,7 +1144,7 @@ suite('ExtHostWorkspace', function () { }); const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService()); - await (ws.findTextInFilesNew({ pattern: 'foo' }, {}, new ExtensionIdentifier('test'))).complete; + await (ws.findTextInFiles2({ pattern: 'foo' }, {}, new ExtensionIdentifier('test'))).complete; assert(mainThreadCalled, 'mainThreadCalled'); }); @@ -1165,7 +1165,7 @@ suite('ExtHostWorkspace', function () { }); const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService()); - await (ws.findTextInFilesNew({ pattern: 'foo' }, { include: ['**/files'] }, new ExtensionIdentifier('test'))).complete; + await (ws.findTextInFiles2({ pattern: 'foo' }, { include: ['**/files'] }, new ExtensionIdentifier('test'))).complete; assert(mainThreadCalled, 'mainThreadCalled'); }); @@ -1186,7 +1186,7 @@ suite('ExtHostWorkspace', function () { }); const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService()); - await (ws.findTextInFilesNew({ pattern: 'foo' }, { include: [new RelativePattern('/other/folder', 'glob/**')] }, new ExtensionIdentifier('test'))).complete; + await (ws.findTextInFiles2({ pattern: 'foo' }, { include: [new RelativePattern('/other/folder', 'glob/**')] }, new ExtensionIdentifier('test'))).complete; assert(mainThreadCalled, 'mainThreadCalled'); }); @@ -1204,7 +1204,7 @@ suite('ExtHostWorkspace', function () { const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService()); const token = CancellationToken.Cancelled; - await (ws.findTextInFilesNew({ pattern: 'foo' }, undefined, new ExtensionIdentifier('test'), token)).complete; + await (ws.findTextInFiles2({ pattern: 'foo' }, undefined, new ExtensionIdentifier('test'), token)).complete; assert(!mainThreadCalled, '!mainThreadCalled'); }); @@ -1226,7 +1226,7 @@ suite('ExtHostWorkspace', function () { }); const ws = createExtHostWorkspace(rpcProtocol, { id: 'foo', folders: [aWorkspaceFolderData(URI.file(root), 0)], name: 'Test' }, new NullLogService()); - await (ws.findTextInFilesNew({ pattern: 'foo' }, { exclude: [new RelativePattern('/other/folder', 'glob/**')] }, new ExtensionIdentifier('test'))).complete; + await (ws.findTextInFiles2({ pattern: 'foo' }, { exclude: [new RelativePattern('/other/folder', 'glob/**')] }, new ExtensionIdentifier('test'))).complete; assert(mainThreadCalled, 'mainThreadCalled'); }); diff --git a/src/vs/workbench/api/test/node/extHostSearch.test.ts b/src/vs/workbench/api/test/node/extHostSearch.test.ts index 75e6b2f34c6..94380c10ec4 100644 --- a/src/vs/workbench/api/test/node/extHostSearch.test.ts +++ b/src/vs/workbench/api/test/node/extHostSearch.test.ts @@ -170,7 +170,7 @@ suite('ExtHostSearch', () => { this._pfs = mockPFS as any; } - protected override createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProviderNew): TextSearchManager { + protected override createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProvider2): TextSearchManager { return new NativeTextSearchManager(query, provider, this._pfs); } }); diff --git a/src/vs/workbench/services/search/common/fileSearchManager.ts b/src/vs/workbench/services/search/common/fileSearchManager.ts index 1b56d2cbbe6..bd539edb41d 100644 --- a/src/vs/workbench/services/search/common/fileSearchManager.ts +++ b/src/vs/workbench/services/search/common/fileSearchManager.ts @@ -11,7 +11,7 @@ import * as resources from '../../../../base/common/resources.js'; import { StopWatch } from '../../../../base/common/stopwatch.js'; import { URI } from '../../../../base/common/uri.js'; import { IFileMatch, IFileSearchProviderStats, IFolderQuery, ISearchCompleteStats, IFileQuery, QueryGlobTester, resolvePatternsForProvider, hasSiblingFn, excludeToGlobPattern, DEFAULT_MAX_SEARCH_RESULTS } from './search.js'; -import { FileSearchProviderFolderOptions, FileSearchProviderNew, FileSearchProviderOptions } from './searchExtTypes.js'; +import { FileSearchProviderFolderOptions, FileSearchProvider2, FileSearchProviderOptions } from './searchExtTypes.js'; import { OldFileSearchProviderConverter } from './searchExtConversionTypes.js'; import { FolderQuerySearchTree } from './folderQuerySearchTree.js'; @@ -54,7 +54,7 @@ class FileSearchEngine { private globalExcludePattern?: glob.ParsedExpression; - constructor(private config: IFileQuery, private provider: FileSearchProviderNew, private sessionLifecycle?: SessionLifecycle) { + constructor(private config: IFileQuery, private provider: FileSearchProvider2, private sessionLifecycle?: SessionLifecycle) { this.filePattern = config.filePattern; this.includePattern = config.includePattern && glob.parse(config.includePattern); this.maxResults = config.maxResults || undefined; @@ -334,7 +334,7 @@ export class FileSearchManager { private readonly sessions = new Map(); - fileSearch(config: IFileQuery, provider: FileSearchProviderNew, onBatch: (matches: IFileMatch[]) => void, token: CancellationToken): Promise { + fileSearch(config: IFileQuery, provider: FileSearchProvider2, onBatch: (matches: IFileMatch[]) => void, token: CancellationToken): Promise { const sessionTokenSource = this.getSessionTokenSource(config.cacheKey); const engine = new FileSearchEngine(config, provider, sessionTokenSource); diff --git a/src/vs/workbench/services/search/common/searchExtConversionTypes.ts b/src/vs/workbench/services/search/common/searchExtConversionTypes.ts index 098b56480cb..96bff831656 100644 --- a/src/vs/workbench/services/search/common/searchExtConversionTypes.ts +++ b/src/vs/workbench/services/search/common/searchExtConversionTypes.ts @@ -13,7 +13,7 @@ import { CancellationToken } from '../../../../base/common/cancellation.js'; import { URI } from '../../../../base/common/uri.js'; import { IProgress } from '../../../../platform/progress/common/progress.js'; import { DEFAULT_TEXT_SEARCH_PREVIEW_OPTIONS } from './search.js'; -import { Range, FileSearchProviderNew, FileSearchProviderOptions, ProviderResult, TextSearchCompleteNew, TextSearchContextNew, TextSearchMatchNew, TextSearchProviderNew, TextSearchProviderOptions, TextSearchQueryNew, TextSearchResultNew, AITextSearchProviderNew, TextSearchCompleteMessage } from './searchExtTypes.js'; +import { Range, FileSearchProvider2, FileSearchProviderOptions, ProviderResult, TextSearchComplete2, TextSearchContext2, TextSearchMatch2, TextSearchProvider2, TextSearchProviderOptions, TextSearchQuery2, TextSearchResult2, AITextSearchProvider2, TextSearchCompleteMessage } from './searchExtTypes.js'; // old types that are retained for backward compatibility // TODO: delete this when search apis are adopted by all first-party extensions @@ -472,7 +472,7 @@ function newToOldFileProviderOptions(options: FileSearchProviderOptions): FileSe } satisfies FileSearchOptions)); } -export class OldFileSearchProviderConverter implements FileSearchProviderNew { +export class OldFileSearchProviderConverter implements FileSearchProvider2 { constructor(private provider: FileSearchProvider) { } provideFileSearchResults(pattern: string, options: FileSearchProviderOptions, token: CancellationToken): ProviderResult { @@ -517,23 +517,23 @@ export function newToOldPreviewOptions(options: { }; } -export function oldToNewTextSearchResult(result: TextSearchResult): TextSearchResultNew { +export function oldToNewTextSearchResult(result: TextSearchResult): TextSearchResult2 { if (isTextSearchMatch(result)) { const ranges = asArray(result.ranges).map((r, i) => { const previewArr = asArray(result.preview.matches); const matchingPreviewRange = previewArr[i]; return { sourceRange: r, previewRange: matchingPreviewRange }; }); - return new TextSearchMatchNew(result.uri, ranges, result.preview.text); + return new TextSearchMatch2(result.uri, ranges, result.preview.text); } else { - return new TextSearchContextNew(result.uri, result.text, result.lineNumber); + return new TextSearchContext2(result.uri, result.text, result.lineNumber); } } -export class OldTextSearchProviderConverter implements TextSearchProviderNew { +export class OldTextSearchProviderConverter implements TextSearchProvider2 { constructor(private provider: TextSearchProvider) { } - provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult { + provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult { const progressShim = (oldResult: TextSearchResult) => { if (!validateProviderResult(oldResult)) { @@ -556,19 +556,19 @@ export class OldTextSearchProviderConverter implements TextSearchProviderNew { return { limitHit: e.limitHit, message: coalesce(asArray(e.message)) - } satisfies TextSearchCompleteNew; + } satisfies TextSearchComplete2; }); } } -export class OldAITextSearchProviderConverter implements AITextSearchProviderNew { +export class OldAITextSearchProviderConverter implements AITextSearchProvider2 { public readonly name?: string; constructor(private provider: AITextSearchProvider) { this.name = this.provider.name; } - provideAITextSearchResults(query: string, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult { + provideAITextSearchResults(query: string, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult { const progressShim = (oldResult: TextSearchResult) => { if (!validateProviderResult(oldResult)) { return; @@ -590,7 +590,7 @@ export class OldAITextSearchProviderConverter implements AITextSearchProviderNew return { limitHit: e.limitHit, message: coalesce(asArray(e.message)) - } satisfies TextSearchCompleteNew; + } satisfies TextSearchComplete2; }); } } diff --git a/src/vs/workbench/services/search/common/searchExtTypes.ts b/src/vs/workbench/services/search/common/searchExtTypes.ts index 285f5a395a4..7dd13ebc258 100644 --- a/src/vs/workbench/services/search/common/searchExtTypes.ts +++ b/src/vs/workbench/services/search/common/searchExtTypes.ts @@ -93,7 +93,7 @@ export type GlobPattern = string | RelativePattern; /** * The parameters of a query for text search. */ -export interface TextSearchQueryNew { +export interface TextSearchQuery2 { /** * The text pattern to search for. */ @@ -214,7 +214,7 @@ export interface TextSearchProviderOptions { /** * Information collected when text search is complete. */ -export interface TextSearchCompleteNew { +export interface TextSearchComplete2 { /** * Whether the search hit the limit on the maximum number of search results. * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results. @@ -285,9 +285,9 @@ export interface FileSearchProviderOptions { } /** - * The main match information for a {@link TextSearchResultNew}. + * The main match information for a {@link TextSearchResult2}. */ -export class TextSearchMatchNew { +export class TextSearchMatch2 { /** * @param uri The uri for the matching document. * @param ranges The ranges associated with this match. @@ -301,9 +301,9 @@ export class TextSearchMatchNew { } /** - * The potential context information for a {@link TextSearchResultNew}. + * The potential context information for a {@link TextSearchResult2}. */ -export class TextSearchContextNew { +export class TextSearchContext2 { /** * @param uri The uri for the matching document. * @param text The line of context text. @@ -318,7 +318,7 @@ export class TextSearchContextNew { /** * A result payload for a text search, pertaining to matches within a single file. */ -export type TextSearchResultNew = TextSearchMatchNew | TextSearchContextNew; +export type TextSearchResult2 = TextSearchMatch2 | TextSearchContext2; /** @@ -330,7 +330,7 @@ export type TextSearchResultNew = TextSearchMatchNew | TextSearchContextNew; * The FileSearchProvider will be invoked on every keypress in quickaccess. When `workspace.findFiles` is called, it will be invoked with an empty query string, * and in that case, every file in the folder should be returned. */ -export interface FileSearchProviderNew { +export interface FileSearchProvider2 { /** * Provide the set of files that match a certain file path pattern. * @param query The parameters for this query. @@ -344,7 +344,7 @@ export interface FileSearchProviderNew { /** * A TextSearchProvider provides search results for text results inside files in the workspace. */ -export interface TextSearchProviderNew { +export interface TextSearchProvider2 { /** * Provide results that match the given text pattern. * @param query The parameters for this query. @@ -352,13 +352,13 @@ export interface TextSearchProviderNew { * @param progress A progress callback that must be invoked for all results. * @param token A cancellation token. */ - provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult; + provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult; } /** * Information collected when text search is complete. */ -export interface TextSearchCompleteNew { +export interface TextSearchComplete2 { /** * Whether the search hit the limit on the maximum number of search results. * `maxResults` on {@linkcode TextSearchOptions} specifies the max number of results. @@ -377,13 +377,13 @@ export interface TextSearchCompleteNew { * * Commands may optionally return { triggerSearch: true } to signal to the editor that the original search should run be again. */ - message?: TextSearchCompleteMessageNew[]; + message?: TextSearchCompleteMessage2[]; } /** * A message regarding a completed search. */ -export interface TextSearchCompleteMessageNew { +export interface TextSearchCompleteMessage2 { /** * Markdown text of the message. */ @@ -409,7 +409,7 @@ export interface TextSearchCompleteMessageNew { * The FileSearchProvider will be invoked on every keypress in quickaccess. When `workspace.findFiles` is called, it will be invoked with an empty query string, * and in that case, every file in the folder should be returned. */ -export interface FileSearchProviderNew { +export interface FileSearchProvider2 { /** * Provide the set of files that match a certain file path pattern. * @param query The parameters for this query. @@ -423,7 +423,7 @@ export interface FileSearchProviderNew { /** * A TextSearchProvider provides search results for text results inside files in the workspace. */ -export interface TextSearchProviderNew { +export interface TextSearchProvider2 { /** * Provide results that match the given text pattern. * @param query The parameters for this query. @@ -431,13 +431,13 @@ export interface TextSearchProviderNew { * @param progress A progress callback that must be invoked for all results. * @param token A cancellation token. */ - provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult; + provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult; } /** * Information collected when text search is complete. */ -export interface TextSearchCompleteNew { +export interface TextSearchComplete2 { /** * Whether the search hit the limit on the maximum number of search results. * `maxResults` on {@linkcode TextSearchOptions} specifies the max number of results. @@ -456,13 +456,13 @@ export interface TextSearchCompleteNew { * * Commands may optionally return { triggerSearch: true } to signal to the editor that the original search should run be again. */ - message?: TextSearchCompleteMessageNew[]; + message?: TextSearchCompleteMessage2[]; } /** * A message regarding a completed search. */ -export interface TextSearchCompleteMessageNew { +export interface TextSearchCompleteMessage2 { /** * Markdown text of the message. */ @@ -527,7 +527,7 @@ export interface TextSearchCompleteMessage { /** * An AITextSearchProvider provides additional AI text search results in the workspace. */ -export interface AITextSearchProviderNew { +export interface AITextSearchProvider2 { /** * The name of the AI searcher. Will be displayed as `{name} Results` in the Search View. @@ -543,5 +543,5 @@ export interface AITextSearchProviderNew { * @param progress A progress callback that must be invoked for all results. * @param token A cancellation token. */ - provideAITextSearchResults(query: string, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult; + provideAITextSearchResults(query: string, options: TextSearchProviderOptions, progress: IProgress, token: CancellationToken): ProviderResult; } diff --git a/src/vs/workbench/services/search/common/textSearchManager.ts b/src/vs/workbench/services/search/common/textSearchManager.ts index 8904ef2a1b6..5d8e858833b 100644 --- a/src/vs/workbench/services/search/common/textSearchManager.ts +++ b/src/vs/workbench/services/search/common/textSearchManager.ts @@ -12,18 +12,18 @@ import * as resources from '../../../../base/common/resources.js'; import { URI } from '../../../../base/common/uri.js'; import { FolderQuerySearchTree } from './folderQuerySearchTree.js'; import { DEFAULT_MAX_SEARCH_RESULTS, hasSiblingPromiseFn, IAITextQuery, IExtendedExtensionSearchOptions, IFileMatch, IFolderQuery, excludeToGlobPattern, IPatternInfo, ISearchCompleteStats, ITextQuery, ITextSearchContext, ITextSearchMatch, ITextSearchResult, ITextSearchStats, QueryGlobTester, QueryType, resolvePatternsForProvider, ISearchRange, DEFAULT_TEXT_SEARCH_PREVIEW_OPTIONS } from './search.js'; -import { AITextSearchProviderNew, TextSearchCompleteNew, TextSearchMatchNew, TextSearchProviderFolderOptions, TextSearchProviderNew, TextSearchProviderOptions, TextSearchQueryNew, TextSearchResultNew } from './searchExtTypes.js'; +import { AITextSearchProvider2, TextSearchComplete2, TextSearchMatch2, TextSearchProviderFolderOptions, TextSearchProvider2, TextSearchProviderOptions, TextSearchQuery2, TextSearchResult2 } from './searchExtTypes.js'; export interface IFileUtils { readdir: (resource: URI) => Promise; toCanonicalName: (encoding: string) => string; } interface IAITextQueryProviderPair { - query: IAITextQuery; provider: AITextSearchProviderNew; + query: IAITextQuery; provider: AITextSearchProvider2; } interface ITextQueryProviderPair { - query: ITextQuery; provider: TextSearchProviderNew; + query: ITextQuery; provider: TextSearchProvider2; } interface FolderQueryInfo { queryTester: QueryGlobTester; @@ -54,14 +54,14 @@ export class TextSearchManager { this.collector = new TextSearchResultsCollector(onProgress); let isCanceled = false; - const onResult = (result: TextSearchResultNew, folderIdx: number) => { + const onResult = (result: TextSearchResult2, folderIdx: number) => { if (isCanceled) { return; } if (!this.isLimitHit) { const resultSize = this.resultSize(result); - if (result instanceof TextSearchMatchNew && typeof this.query.maxResults === 'number' && this.resultCount + resultSize > this.query.maxResults) { + if (result instanceof TextSearchMatch2 && typeof this.query.maxResults === 'number' && this.resultCount + resultSize > this.query.maxResults) { this.isLimitHit = true; isCanceled = true; tokenSource.cancel(); @@ -71,7 +71,7 @@ export class TextSearchManager { const newResultSize = this.resultSize(result); this.resultCount += newResultSize; - const a = result instanceof TextSearchMatchNew; + const a = result instanceof TextSearchMatch2; if (newResultSize > 0 || !a) { this.collector!.add(result, folderIdx); @@ -99,14 +99,14 @@ export class TextSearchManager { }); } - private getMessagesFromResults(result: TextSearchCompleteNew | null | undefined) { + private getMessagesFromResults(result: TextSearchComplete2 | null | undefined) { if (!result?.message) { return []; } if (Array.isArray(result.message)) { return result.message; } return [result.message]; } - private resultSize(result: TextSearchResultNew): number { - if (result instanceof TextSearchMatchNew) { + private resultSize(result: TextSearchResult2): number { + if (result instanceof TextSearchMatch2) { return Array.isArray(result.ranges) ? result.ranges.length : 1; @@ -117,11 +117,11 @@ export class TextSearchManager { } } - private trimResultToSize(result: TextSearchMatchNew, size: number): TextSearchMatchNew { - return new TextSearchMatchNew(result.uri, result.ranges.slice(0, size), result.previewText); + private trimResultToSize(result: TextSearchMatch2, size: number): TextSearchMatch2 { + return new TextSearchMatch2(result.uri, result.ranges.slice(0, size), result.previewText); } - private async doSearch(folderQueries: IFolderQuery[], onResult: (result: TextSearchResultNew, folderIdx: number) => void, token: CancellationToken): Promise { + private async doSearch(folderQueries: IFolderQuery[], onResult: (result: TextSearchResult2, folderIdx: number) => void, token: CancellationToken): Promise { const folderMappings: FolderQuerySearchTree = new FolderQuerySearchTree( folderQueries, (fq, i) => { @@ -133,7 +133,7 @@ export class TextSearchManager { const testingPs: Promise[] = []; const progress = { - report: (result: TextSearchResultNew) => { + report: (result: TextSearchResult2) => { if (result.uri === undefined) { throw Error('Text search result URI is undefined. Please check provider implementation.'); @@ -220,7 +220,7 @@ export class TextSearchManager { } } -function patternInfoToQuery(patternInfo: IPatternInfo): TextSearchQueryNew { +function patternInfoToQuery(patternInfo: IPatternInfo): TextSearchQuery2 { return { isCaseSensitive: patternInfo.isCaseSensitive || false, isRegExp: patternInfo.isRegExp || false, @@ -241,7 +241,7 @@ export class TextSearchResultsCollector { this._batchedCollector = new BatchedCollector(512, items => this.sendItems(items)); } - add(data: TextSearchResultNew, folderIdx: number): void { + add(data: TextSearchResult2, folderIdx: number): void { // Collects TextSearchResults into IInternalFileMatches and collates using BatchedCollector. // This is efficient for ripgrep which sends results back one file at a time. It wouldn't be efficient for other search // providers that send results in random order. We could do this step afterwards instead. @@ -278,9 +278,9 @@ export class TextSearchResultsCollector { } } -function extensionResultToFrontendResult(data: TextSearchResultNew): ITextSearchResult { +function extensionResultToFrontendResult(data: TextSearchResult2): ITextSearchResult { // Warning: result from RipgrepTextSearchEH has fake Range. Don't depend on any other props beyond these... - if (data instanceof TextSearchMatchNew) { + if (data instanceof TextSearchMatch2) { return { previewText: data.previewText, rangeLocations: data.ranges.map(r => ({ diff --git a/src/vs/workbench/services/search/node/ripgrepSearchProvider.ts b/src/vs/workbench/services/search/node/ripgrepSearchProvider.ts index 9811308b833..d9577cd7d31 100644 --- a/src/vs/workbench/services/search/node/ripgrepSearchProvider.ts +++ b/src/vs/workbench/services/search/node/ripgrepSearchProvider.ts @@ -6,19 +6,19 @@ import { CancellationTokenSource, CancellationToken } from '../../../../base/common/cancellation.js'; import { OutputChannel } from './ripgrepSearchUtils.js'; import { RipgrepTextSearchEngine } from './ripgrepTextSearchEngine.js'; -import { TextSearchProviderNew, TextSearchCompleteNew, TextSearchResultNew, TextSearchQueryNew, TextSearchProviderOptions, } from '../common/searchExtTypes.js'; +import { TextSearchProvider2, TextSearchComplete2, TextSearchResult2, TextSearchQuery2, TextSearchProviderOptions, } from '../common/searchExtTypes.js'; import { Progress } from '../../../../platform/progress/common/progress.js'; import { Schemas } from '../../../../base/common/network.js'; import type { RipgrepTextSearchOptions } from '../common/searchExtTypesInternal.js'; -export class RipgrepSearchProvider implements TextSearchProviderNew { +export class RipgrepSearchProvider implements TextSearchProvider2 { private inProgress: Set = new Set(); constructor(private outputChannel: OutputChannel, private getNumThreads: () => Promise) { process.once('exit', () => this.dispose()); } - async provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): Promise { + async provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): Promise { const numThreads = await this.getNumThreads(); const engine = new RipgrepTextSearchEngine(this.outputChannel, numThreads); @@ -36,13 +36,13 @@ export class RipgrepSearchProvider implements TextSearchProviderNew { // Ripgrep search engine can only provide file-scheme results, but we want to use it to search some schemes that are backed by the filesystem, but with some other provider as the frontend, // case in point vscode-userdata. In these cases we translate the query to a file, and translate the results back to the frontend scheme. const translatedOptions = { ...extendedOptions, folder: folderOption.folder.with({ scheme: Schemas.file }) }; - const progressTranslator = new Progress(data => progress.report({ ...data, uri: data.uri.with({ scheme: folderOption.folder.scheme }) })); + const progressTranslator = new Progress(data => progress.report({ ...data, uri: data.uri.with({ scheme: folderOption.folder.scheme }) })); return this.withToken(token, token => engine.provideTextSearchResultsWithRgOptions(query, translatedOptions, progressTranslator, token)); } else { return this.withToken(token, token => engine.provideTextSearchResultsWithRgOptions(query, extendedOptions, progress, token)); } })).then((e => { - const complete: TextSearchCompleteNew = { + const complete: TextSearchComplete2 = { // todo: get this to actually check limitHit: e.some(complete => !!complete && complete.limitHit) }; diff --git a/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts b/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts index 3ab8205f2b1..188dc598f75 100644 --- a/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts +++ b/src/vs/workbench/services/search/node/ripgrepTextSearchEngine.ts @@ -14,7 +14,7 @@ import { createRegExp, escapeRegExpCharacters } from '../../../../base/common/st import { URI } from '../../../../base/common/uri.js'; import { Progress } from '../../../../platform/progress/common/progress.js'; import { DEFAULT_MAX_SEARCH_RESULTS, IExtendedExtensionSearchOptions, ITextSearchPreviewOptions, SearchError, SearchErrorCode, serializeSearchError, TextSearchMatch } from '../common/search.js'; -import { Range, TextSearchCompleteNew, TextSearchContextNew, TextSearchMatchNew, TextSearchProviderOptions, TextSearchQueryNew, TextSearchResultNew } from '../common/searchExtTypes.js'; +import { Range, TextSearchComplete2, TextSearchContext2, TextSearchMatch2, TextSearchProviderOptions, TextSearchQuery2, TextSearchResult2 } from '../common/searchExtTypes.js'; import { AST as ReAST, RegExpParser, RegExpVisitor } from 'vscode-regexpp'; import { rgPath } from '@vscode/ripgrep'; import { anchorGlob, IOutputChannel, Maybe, rangeToSearchRange, searchRangeToRange } from './ripgrepSearchUtils.js'; @@ -28,7 +28,7 @@ export class RipgrepTextSearchEngine { constructor(private outputChannel: IOutputChannel, private readonly _numThreads?: number | undefined) { } - provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): Promise { + provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): Promise { return Promise.all(options.folderOptions.map(folderOption => { const extendedOptions: RipgrepTextSearchOptions = { folderOptions: folderOption, @@ -40,7 +40,7 @@ export class RipgrepTextSearchEngine { }; return this.provideTextSearchResultsWithRgOptions(query, extendedOptions, progress, token); })).then((e => { - const complete: TextSearchCompleteNew = { + const complete: TextSearchComplete2 = { // todo: get this to actually check limitHit: e.some(complete => !!complete && complete.limitHit) }; @@ -48,7 +48,7 @@ export class RipgrepTextSearchEngine { })); } - provideTextSearchResultsWithRgOptions(query: TextSearchQueryNew, options: RipgrepTextSearchOptions, progress: Progress, token: CancellationToken): Promise { + provideTextSearchResultsWithRgOptions(query: TextSearchQuery2, options: RipgrepTextSearchOptions, progress: Progress, token: CancellationToken): Promise { this.outputChannel.appendLine(`provideTextSearchResults ${query.pattern}, ${JSON.stringify({ ...options, ...{ @@ -81,7 +81,7 @@ export class RipgrepTextSearchEngine { let gotResult = false; const ripgrepParser = new RipgrepParser(options.maxResults ?? DEFAULT_MAX_SEARCH_RESULTS, options.folderOptions.folder, newToOldPreviewOptions(options.previewOptions)); - ripgrepParser.on('result', (match: TextSearchResultNew) => { + ripgrepParser.on('result', (match: TextSearchResult2) => { gotResult = true; dataWithoutResult = ''; progress.report(match); @@ -223,7 +223,7 @@ export class RipgrepParser extends EventEmitter { } - override on(event: 'result', listener: (result: TextSearchResultNew) => void): this; + override on(event: 'result', listener: (result: TextSearchResult2) => void): this; override on(event: 'hitLimit', listener: () => void): this; override on(event: string, listener: (...args: any[]) => void): this { super.on(event, listener); @@ -295,7 +295,7 @@ export class RipgrepParser extends EventEmitter { } } - private createTextSearchMatch(data: IRgMatch, uri: URI): TextSearchMatchNew { + private createTextSearchMatch(data: IRgMatch, uri: URI): TextSearchMatch2 { const lineNumber = data.line_number - 1; const fullText = bytesOrTextToString(data.lines); const fullTextBytes = Buffer.from(fullText); @@ -351,7 +351,7 @@ export class RipgrepParser extends EventEmitter { const searchRange = mapArrayOrNot(ranges, rangeToSearchRange); const internalResult = new TextSearchMatch(fullText, searchRange, this.previewOptions); - return new TextSearchMatchNew( + return new TextSearchMatch2( uri, internalResult.rangeLocations.map(e => ( { @@ -362,16 +362,16 @@ export class RipgrepParser extends EventEmitter { internalResult.previewText); } - private createTextSearchContexts(data: IRgMatch, uri: URI): TextSearchContextNew[] { + private createTextSearchContexts(data: IRgMatch, uri: URI): TextSearchContext2[] { const text = bytesOrTextToString(data.lines); const startLine = data.line_number; return text .replace(/\r?\n$/, '') .split('\n') - .map((line, i) => new TextSearchContextNew(uri, line, startLine + i)); + .map((line, i) => new TextSearchContext2(uri, line, startLine + i)); } - private onResult(match: TextSearchResultNew): void { + private onResult(match: TextSearchResult2): void { this.emit('result', match); } } @@ -400,7 +400,7 @@ function getNumLinesAndLastNewlineLength(text: string): { numLines: number; last } // exported for testing -export function getRgArgs(query: TextSearchQueryNew, options: RipgrepTextSearchOptions): string[] { +export function getRgArgs(query: TextSearchQuery2, options: RipgrepTextSearchOptions): string[] { const args = ['--hidden', '--no-require-git']; args.push(query.isCaseSensitive ? '--case-sensitive' : '--ignore-case'); diff --git a/src/vs/workbench/services/search/node/textSearchManager.ts b/src/vs/workbench/services/search/node/textSearchManager.ts index 56744c247b7..22b096f14f0 100644 --- a/src/vs/workbench/services/search/node/textSearchManager.ts +++ b/src/vs/workbench/services/search/node/textSearchManager.ts @@ -6,12 +6,12 @@ import { toCanonicalName } from '../../textfile/common/encoding.js'; import * as pfs from '../../../../base/node/pfs.js'; import { ITextQuery, ITextSearchStats } from '../common/search.js'; -import { TextSearchProviderNew } from '../common/searchExtTypes.js'; +import { TextSearchProvider2 } from '../common/searchExtTypes.js'; import { TextSearchManager } from '../common/textSearchManager.js'; export class NativeTextSearchManager extends TextSearchManager { - constructor(query: ITextQuery, provider: TextSearchProviderNew, _pfs: typeof pfs = pfs, processType: ITextSearchStats['type'] = 'searchProcess') { + constructor(query: ITextQuery, provider: TextSearchProvider2, _pfs: typeof pfs = pfs, processType: ITextSearchStats['type'] = 'searchProcess') { super({ query, provider }, { readdir: resource => _pfs.Promises.readdir(resource.fsPath), toCanonicalName: name => toCanonicalName(name) diff --git a/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngineUtils.test.ts b/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngineUtils.test.ts index 59bdb0ca8f6..1223c793f64 100644 --- a/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngineUtils.test.ts +++ b/src/vs/workbench/services/search/test/node/ripgrepTextSearchEngineUtils.test.ts @@ -7,7 +7,7 @@ import assert from 'assert'; import { joinPath } from '../../../../../base/common/resources.js'; import { URI } from '../../../../../base/common/uri.js'; import { fixRegexNewline, IRgMatch, IRgMessage, RipgrepParser, unicodeEscapesToPCRE2, fixNewline, getRgArgs, performBraceExpansionForRipgrep } from '../../node/ripgrepTextSearchEngine.js'; -import { Range, TextSearchMatchNew, TextSearchQueryNew, TextSearchResultNew } from '../../common/searchExtTypes.js'; +import { Range, TextSearchMatch2, TextSearchQuery2, TextSearchResult2 } from '../../common/searchExtTypes.js'; import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js'; import { RipgrepTextSearchOptions } from '../../common/searchExtTypesInternal.js'; import { DEFAULT_TEXT_SEARCH_PREVIEW_OPTIONS } from '../../common/search.js'; @@ -106,10 +106,10 @@ suite('RipgrepTextSearchEngine', () => { suite('RipgrepParser', () => { const TEST_FOLDER = URI.file('/foo/bar'); - function testParser(inputData: string[], expectedResults: TextSearchResultNew[]): void { + function testParser(inputData: string[], expectedResults: TextSearchResult2[]): void { const testParser = new RipgrepParser(1000, TEST_FOLDER, DEFAULT_TEXT_SEARCH_PREVIEW_OPTIONS); - const actualResults: TextSearchResultNew[] = []; + const actualResults: TextSearchResult2[] = []; testParser.on('result', r => { actualResults.push(r); }); @@ -148,7 +148,7 @@ suite('RipgrepTextSearchEngine', () => { makeRgMatch('file1.js', 'foobar', 4, [{ start: 3, end: 6 }]) ], [ - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [{ previewRange: new Range(0, 3, 0, 6), @@ -167,7 +167,7 @@ suite('RipgrepTextSearchEngine', () => { makeRgMatch('app2/file3.js', 'foobar', 4, [{ start: 3, end: 6 }]), ], [ - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [{ previewRange: new Range(0, 3, 0, 6), @@ -175,7 +175,7 @@ suite('RipgrepTextSearchEngine', () => { }], 'foobar' ), - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'app/file2.js'), [{ previewRange: new Range(0, 3, 0, 6), @@ -183,7 +183,7 @@ suite('RipgrepTextSearchEngine', () => { }], 'foobar' ), - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'app2/file3.js'), [{ previewRange: new Range(0, 3, 0, 6), @@ -212,7 +212,7 @@ suite('RipgrepTextSearchEngine', () => { dataStrs[2].substring(25) ], [ - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [{ previewRange: new Range(0, 3, 0, 7), @@ -220,7 +220,7 @@ suite('RipgrepTextSearchEngine', () => { }], 'foo bar' ), - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'app/file2.js'), [{ previewRange: new Range(0, 3, 0, 6), @@ -228,7 +228,7 @@ suite('RipgrepTextSearchEngine', () => { }], 'foobar' ), - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'app2/file3.js'), [{ previewRange: new Range(0, 3, 0, 6), @@ -247,7 +247,7 @@ suite('RipgrepTextSearchEngine', () => { makeRgMatch('file1.js', '', 5, []), ], [ - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [ { @@ -257,7 +257,7 @@ suite('RipgrepTextSearchEngine', () => { ], 'foobar' ), - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [ { @@ -276,7 +276,7 @@ suite('RipgrepTextSearchEngine', () => { makeRgMatch('file1.js', 'foobarbazquux', 4, [{ start: 0, end: 4 }, { start: 6, end: 10 }]), ], [ - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [ { @@ -299,7 +299,7 @@ suite('RipgrepTextSearchEngine', () => { makeRgMatch('file1.js', 'foo\nbar\nbaz\nquux', 4, [{ start: 0, end: 5 }, { start: 8, end: 13 }]), ], [ - new TextSearchMatchNew( + new TextSearchMatch2( joinPath(TEST_FOLDER, 'file1.js'), [ { @@ -321,7 +321,7 @@ suite('RipgrepTextSearchEngine', () => { test('simple includes', () => { // Only testing the args that come from includes. function testGetRgArgs(includes: string[], expectedFromIncludes: string[]): void { - const query: TextSearchQueryNew = { + const query: TextSearchQuery2 = { pattern: 'test' }; diff --git a/src/vs/workbench/services/search/test/node/textSearchManager.test.ts b/src/vs/workbench/services/search/test/node/textSearchManager.test.ts index eda186aa3e4..190ec3005f3 100644 --- a/src/vs/workbench/services/search/test/node/textSearchManager.test.ts +++ b/src/vs/workbench/services/search/test/node/textSearchManager.test.ts @@ -9,14 +9,14 @@ import { URI } from '../../../../../base/common/uri.js'; import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js'; import { Progress } from '../../../../../platform/progress/common/progress.js'; import { ITextQuery, QueryType } from '../../common/search.js'; -import { ProviderResult, TextSearchCompleteNew, TextSearchProviderOptions, TextSearchProviderNew, TextSearchQueryNew, TextSearchResultNew } from '../../common/searchExtTypes.js'; +import { ProviderResult, TextSearchComplete2, TextSearchProviderOptions, TextSearchProvider2, TextSearchQuery2, TextSearchResult2 } from '../../common/searchExtTypes.js'; import { NativeTextSearchManager } from '../../node/textSearchManager.js'; suite('NativeTextSearchManager', () => { test('fixes encoding', async () => { let correctEncoding = false; - const provider: TextSearchProviderNew = { - provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): ProviderResult { + const provider: TextSearchProvider2 = { + provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): ProviderResult { correctEncoding = options.folderOptions[0].encoding === 'windows-1252'; return null; diff --git a/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts b/src/vscode-dts/vscode.proposed.aiTextSearchProvider2.d.ts similarity index 83% rename from src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts rename to src/vscode-dts/vscode.proposed.aiTextSearchProvider2.d.ts index f54a9ef2b14..05c9c6b0415 100644 --- a/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts +++ b/src/vscode-dts/vscode.proposed.aiTextSearchProvider2.d.ts @@ -7,7 +7,7 @@ declare module 'vscode' { /** * An AITextSearchProvider provides additional AI text search results in the workspace. */ - export interface AITextSearchProviderNew { + export interface AITextSearchProvider2 { /** * The name of the AI searcher. Will be displayed as `{name} Results` in the Search View. */ @@ -22,7 +22,7 @@ declare module 'vscode' { * @param progress A progress callback that must be invoked for all results. * @param token A cancellation token. */ - provideAITextSearchResults(query: string, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): ProviderResult; + provideAITextSearchResults(query: string, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): ProviderResult; } export namespace workspace { @@ -35,6 +35,6 @@ declare module 'vscode' { * @param provider The provider. * @return A {@link Disposable} that unregisters this provider when being disposed. */ - export function registerAITextSearchProviderNew(scheme: string, provider: AITextSearchProviderNew): Disposable; + export function registerAITextSearchProvider2(scheme: string, provider: AITextSearchProvider2): Disposable; } } diff --git a/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts b/src/vscode-dts/vscode.proposed.fileSearchProvider2.d.ts similarity index 95% rename from src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts rename to src/vscode-dts/vscode.proposed.fileSearchProvider2.d.ts index 36b0b482313..e23123d376c 100644 --- a/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts +++ b/src/vscode-dts/vscode.proposed.fileSearchProvider2.d.ts @@ -73,7 +73,7 @@ declare module 'vscode' { * * The FileSearchProvider will be invoked on every keypress in quickopen. */ - export interface FileSearchProviderNew { + export interface FileSearchProvider2 { /** * WARNING: VERY EXPERIMENTAL. * @@ -96,6 +96,6 @@ declare module 'vscode' { * @param provider The provider. * @return A {@link Disposable} that unregisters this provider when being disposed. */ - export function registerFileSearchProviderNew(scheme: string, provider: FileSearchProviderNew): Disposable; + export function registerFileSearchProvider2(scheme: string, provider: FileSearchProvider2): Disposable; } } diff --git a/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts b/src/vscode-dts/vscode.proposed.findTextInFiles2.d.ts similarity index 85% rename from src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts rename to src/vscode-dts/vscode.proposed.findTextInFiles2.d.ts index 2756dce1aab..6fcec3d0a1e 100644 --- a/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts +++ b/src/vscode-dts/vscode.proposed.findTextInFiles2.d.ts @@ -7,7 +7,7 @@ declare module 'vscode' { // https://github.com/microsoft/vscode/issues/59924 - export interface FindTextInFilesOptionsNew { + export interface FindTextInFilesOptions2 { /** * An array of {@link GlobPattern GlobPattern} that defines the files to search for. * The glob patterns will be matched against the file paths of files relative to their workspace or {@link baseUri GlobPattern.baseUri} if applicable. @@ -18,9 +18,9 @@ declare module 'vscode' { * For example, consider the following code: * * ```ts - * const ab = findTextInFilesNew('foo', {include: ['*.ts', '*.js']}); - * const a = findTextInFilesNew('foo', {include: ['*.ts']}); - * const b = findTextInFilesNew('foo', {include: ['*.js']}); + * const ab = findTextInFiles2('foo', {include: ['*.ts', '*.js']}); + * const a = findTextInFiles2('foo', {include: ['*.ts']}); + * const b = findTextInFiles2('foo', {include: ['*.js']}); * ``` * * In this, `ab` will be the union of results from `a` and `b`. @@ -35,9 +35,9 @@ declare module 'vscode' { * For example, consider the following code: * * ```ts - * const ab = findTextInFilesNew('foo', {exclude: ['*.ts', '*.js']}); - * const a = findTextInFilesNew('foo', {exclude: ['*.ts']}); - * const b = findTextInFilesNew('foo', {exclude: ['*.js']}); + * const ab = findTextInFiles2('foo', {exclude: ['*.ts', '*.js']}); + * const a = findTextInFiles2('foo', {exclude: ['*.ts']}); + * const b = findTextInFiles2('foo', {exclude: ['*.js']}); * ``` * * In this, `ab` will be the intersection of results from `a` and `b`. @@ -73,12 +73,12 @@ declare module 'vscode' { */ local?: boolean; /** - * Use ignore files at the parent directory. When set to `true`, {@link FindTextInFilesOptionsNew.useIgnoreFiles.local} must be `true`. + * Use ignore files at the parent directory. When set to `true`, {@link FindTextInFilesOptions2.useIgnoreFiles.local} must be `true`. * May default to `search.useParentIgnoreFiles` setting if not set. */ parent?: boolean; /** - * Use global ignore files. When set to `true`, {@link FindTextInFilesOptionsNew.useIgnoreFiles.local} must also be `true`. + * Use global ignore files. When set to `true`, {@link FindTextInFilesOptions2.useIgnoreFiles.local} must also be `true`. * May default to `search.useGlobalIgnoreFiles` setting if not set. */ global?: boolean; @@ -123,11 +123,11 @@ declare module 'vscode' { /** * The results of the text search, in batches. To get completion information, wait on the `complete` property. */ - results: AsyncIterable; + results: AsyncIterable; /** * The text search completion information. This resolves on completion. */ - complete: Thenable; + complete: Thenable; } /** @@ -155,10 +155,10 @@ declare module 'vscode' { * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace. * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words. * @param options An optional set of query options. - * @param callback A callback, called for each {@link TextSearchResultNew result}. This can be a direct match, or context that surrounds a match. + * @param callback A callback, called for each {@link TextSearchResult2 result}. This can be a direct match, or context that surrounds a match. * @param token A token that can be used to signal cancellation to the underlying search engine. * @return A thenable that resolves when the search is complete. */ - export function findTextInFilesNew(query: TextSearchQueryNew, options?: FindTextInFilesOptionsNew, token?: CancellationToken): FindTextInFilesResponse; + export function findTextInFiles2(query: TextSearchQuery2, options?: FindTextInFilesOptions2, token?: CancellationToken): FindTextInFilesResponse; } } diff --git a/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts b/src/vscode-dts/vscode.proposed.textSearchComplete2.d.ts similarity index 90% rename from src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts rename to src/vscode-dts/vscode.proposed.textSearchComplete2.d.ts index 60c3503210f..f75db1af753 100644 --- a/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts +++ b/src/vscode-dts/vscode.proposed.textSearchComplete2.d.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ declare module 'vscode' { - export interface TextSearchCompleteNew { + export interface TextSearchComplete2 { /** * Additional information regarding the state of the completed search. * @@ -14,13 +14,13 @@ declare module 'vscode' { * * Commands may optionally return { triggerSearch: true } to signal to the editor that the original search should run be again. */ - message?: TextSearchCompleteMessageNew[]; + message?: TextSearchCompleteMessage2[]; } /** * A message regarding a completed search. */ - export interface TextSearchCompleteMessageNew { + export interface TextSearchCompleteMessage2 { /** * Markdown text of the message. */ diff --git a/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts b/src/vscode-dts/vscode.proposed.textSearchProvider2.d.ts similarity index 89% rename from src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts rename to src/vscode-dts/vscode.proposed.textSearchProvider2.d.ts index a82ca8f4ae2..23d1ba018b5 100644 --- a/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts +++ b/src/vscode-dts/vscode.proposed.textSearchProvider2.d.ts @@ -10,7 +10,7 @@ declare module 'vscode' { /** * The parameters of a query for text search. All optional booleans default to `false`. */ - export interface TextSearchQueryNew { + export interface TextSearchQuery2 { /** * The text pattern to search for. * @@ -142,7 +142,7 @@ declare module 'vscode' { /** * Information collected when text search is complete. */ - export interface TextSearchCompleteNew { + export interface TextSearchComplete2 { /** * Whether the search hit the limit on the maximum number of search results. * `maxResults` on {@linkcode TextSearchProviderOptions} specifies the max number of results. @@ -164,9 +164,9 @@ declare module 'vscode' { * const foo = bar; * ``` * - * If the query is `log`, then the line `console.log(bar);` should be represented using a {@link TextSearchMatchNew}. + * If the query is `log`, then the line `console.log(bar);` should be represented using a {@link TextSearchMatch2}. */ - export class TextSearchMatchNew { + export class TextSearchMatch2 { /** * @param uri The uri for the matching document. * @param ranges The ranges associated with this match. @@ -198,7 +198,7 @@ declare module 'vscode' { /** * The context lines of text that are not a part of a match, - * but that surround a match line of type {@link TextSearchMatchNew}. + * but that surround a match line of type {@link TextSearchMatch2}. * * For example, consider this excerpt: * @@ -209,10 +209,10 @@ declare module 'vscode' { * ``` * * If the query is `log`, then the lines `const bar = 1;` and `const foo = bar;` - * should be represented using two separate {@link TextSearchContextNew} for the search instance. + * should be represented using two separate {@link TextSearchContext2} for the search instance. * This example assumes that the finder requests one line of surrounding context. */ - export class TextSearchContextNew { + export class TextSearchContext2 { /** * @param uri The uri for the matching document. * @param text The line of context text. @@ -238,26 +238,26 @@ declare module 'vscode' { } /** - * A result payload for a text search, pertaining to {@link TextSearchMatchNew matches} - * and its associated {@link TextSearchContextNew context} within a single file. + * A result payload for a text search, pertaining to {@link TextSearchMatch2 matches} + * and its associated {@link TextSearchContext2 context} within a single file. */ - export type TextSearchResultNew = TextSearchMatchNew | TextSearchContextNew; + export type TextSearchResult2 = TextSearchMatch2 | TextSearchContext2; /** * A TextSearchProvider provides search results for text results inside files in the workspace. */ - export interface TextSearchProviderNew { + export interface TextSearchProvider2 { /** * WARNING: VERY EXPERIMENTAL. * * Provide results that match the given text pattern. * @param query The parameters for this query. * @param options A set of options to consider while searching. - * @param progress A progress callback that must be invoked for all {@link TextSearchResultNew results}. + * @param progress A progress callback that must be invoked for all {@link TextSearchResult2 results}. * These results can be direct matches, or context that surrounds matches. * @param token A cancellation token. */ - provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): ProviderResult; + provideTextSearchResults(query: TextSearchQuery2, options: TextSearchProviderOptions, progress: Progress, token: CancellationToken): ProviderResult; } export namespace workspace { @@ -270,6 +270,6 @@ declare module 'vscode' { * @param provider The provider. * @return A {@link Disposable} that unregisters this provider when being disposed. */ - export function registerTextSearchProviderNew(scheme: string, provider: TextSearchProviderNew): Disposable; + export function registerTextSearchProvider2(scheme: string, provider: TextSearchProvider2): Disposable; } }