From 8134d8c9e7ca00b43ec7ec36034c4dd345eed36b Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Mon, 16 Nov 2020 18:07:15 +0100 Subject: [PATCH] rename to OnTypeRenameRangeProvider. For #109923 --- .../client/src/htmlClient.ts | 2 +- src/vs/editor/common/modes.ts | 6 +++--- src/vs/editor/contrib/rename/onTypeRename.ts | 8 ++++---- .../contrib/rename/test/onTypeRename.test.ts | 2 +- .../standalone/browser/standaloneLanguages.ts | 8 ++++---- src/vs/monaco.d.ts | 8 ++++---- src/vs/vscode.proposed.d.ts | 10 +++++----- .../api/browser/mainThreadLanguageFeatures.ts | 4 ++-- src/vs/workbench/api/common/extHost.api.impl.ts | 4 ++-- src/vs/workbench/api/common/extHost.protocol.ts | 2 +- .../api/common/extHostLanguageFeatures.ts | 14 +++++++------- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/extensions/html-language-features/client/src/htmlClient.ts b/extensions/html-language-features/client/src/htmlClient.ts index 6917b56950ba6..b537efd4ecce9 100644 --- a/extensions/html-language-features/client/src/htmlClient.ts +++ b/extensions/html-language-features/client/src/htmlClient.ts @@ -169,7 +169,7 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua } }); - disposable = languages.registerOnTypeRenameProvider(documentSelector, { + disposable = languages.registerOnTypeRenameRangeProvider(documentSelector, { async provideOnTypeRenameRanges(document, position) { const param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position); return client.sendRequest(OnTypeRenameRequest.type, param).then(response => { diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 5392d0931cf02..62f3fced6ea58 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -819,10 +819,10 @@ export interface DocumentHighlightProvider { } /** - * The rename provider interface defines the contract between extensions and + * The rename range provider interface defines the contract between extensions and * the live-rename feature. */ -export interface OnTypeRenameProvider { +export interface OnTypeRenameRangeProvider { /** * Provide a list of ranges that can be live-renamed together. @@ -1733,7 +1733,7 @@ export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry(); +export const OnTypeRenameRangeProviderRegistry = new LanguageFeatureRegistry(); /** * @internal diff --git a/src/vs/editor/contrib/rename/onTypeRename.ts b/src/vs/editor/contrib/rename/onTypeRename.ts index bc9962d57b239..e6b164f35d35e 100644 --- a/src/vs/editor/contrib/rename/onTypeRename.ts +++ b/src/vs/editor/contrib/rename/onTypeRename.ts @@ -15,7 +15,7 @@ import { Position, IPosition } from 'vs/editor/common/core/position'; import { ITextModel, IModelDeltaDecoration, TrackedRangeStickiness, IIdentifiedSingleEditOperation } from 'vs/editor/common/model'; import { CancellationToken } from 'vs/base/common/cancellation'; import { IRange, Range } from 'vs/editor/common/core/range'; -import { OnTypeRenameProviderRegistry, OnTypeRenameRanges } from 'vs/editor/common/modes'; +import { OnTypeRenameRangeProviderRegistry, OnTypeRenameRanges } from 'vs/editor/common/modes'; import { first, createCancelablePromise, CancelablePromise, Delayer } from 'vs/base/common/async'; import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { ContextKeyExpr, RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; @@ -96,7 +96,7 @@ export class OnTypeRenameContribution extends Disposable implements IEditorContr this.reinitialize(); } })); - this._register(OnTypeRenameProviderRegistry.onDidChange(() => this.reinitialize())); + this._register(OnTypeRenameRangeProviderRegistry.onDidChange(() => this.reinitialize())); this._register(this._editor.onDidChangeModelLanguage(() => this.reinitialize())); this.reinitialize(); @@ -104,7 +104,7 @@ export class OnTypeRenameContribution extends Disposable implements IEditorContr private reinitialize() { const model = this._editor.getModel(); - const isEnabled = model !== null && this._editor.getOption(EditorOption.renameOnType) && OnTypeRenameProviderRegistry.has(model); + const isEnabled = model !== null && this._editor.getOption(EditorOption.renameOnType) && OnTypeRenameRangeProviderRegistry.has(model); if (isEnabled === this._enabled) { return; } @@ -420,7 +420,7 @@ registerEditorCommand(new OnTypeRenameCommand({ function getOnTypeRenameRanges(model: ITextModel, position: Position, token: CancellationToken): Promise { - const orderedByScore = OnTypeRenameProviderRegistry.ordered(model); + const orderedByScore = OnTypeRenameRangeProviderRegistry.ordered(model); // in order of score ask the on type rename provider // until someone response with a good result diff --git a/src/vs/editor/contrib/rename/test/onTypeRename.test.ts b/src/vs/editor/contrib/rename/test/onTypeRename.test.ts index 354e5f12aa95a..34d30e861b9f4 100644 --- a/src/vs/editor/contrib/rename/test/onTypeRename.test.ts +++ b/src/vs/editor/contrib/rename/test/onTypeRename.test.ts @@ -66,7 +66,7 @@ suite('On type rename', () => { expectedEndText: string | string[] ) { test(name, async () => { - disposables.add(modes.OnTypeRenameProviderRegistry.register(mockFileSelector, { + disposables.add(modes.OnTypeRenameRangeProviderRegistry.register(mockFileSelector, { provideOnTypeRenameRanges(model: ITextModel, pos: IPosition) { const wordAtPos = model.getWordAtPosition(pos); if (wordAtPos) { diff --git a/src/vs/editor/standalone/browser/standaloneLanguages.ts b/src/vs/editor/standalone/browser/standaloneLanguages.ts index b95826e915603..e9ce3faf2b3b1 100644 --- a/src/vs/editor/standalone/browser/standaloneLanguages.ts +++ b/src/vs/editor/standalone/browser/standaloneLanguages.ts @@ -392,10 +392,10 @@ export function registerDocumentHighlightProvider(languageId: string, provider: } /** - * Register an on type rename provider. + * Register an on type rename range provider. */ -export function registerOnTypeRenameProvider(languageId: string, provider: modes.OnTypeRenameProvider): IDisposable { - return modes.OnTypeRenameProviderRegistry.register(languageId, provider); +export function registerOnTypeRenameRangeProvider(languageId: string, provider: modes.OnTypeRenameRangeProvider): IDisposable { + return modes.OnTypeRenameRangeProviderRegistry.register(languageId, provider); } /** @@ -566,7 +566,7 @@ export function createMonacoLanguagesAPI(): typeof monaco.languages { registerHoverProvider: registerHoverProvider, registerDocumentSymbolProvider: registerDocumentSymbolProvider, registerDocumentHighlightProvider: registerDocumentHighlightProvider, - registerOnTypeRenameProvider: registerOnTypeRenameProvider, + registerOnTypeRenameRangeProvider: registerOnTypeRenameRangeProvider, registerDefinitionProvider: registerDefinitionProvider, registerImplementationProvider: registerImplementationProvider, registerTypeDefinitionProvider: registerTypeDefinitionProvider, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 94e42171485f5..93b7044d73e7a 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -5091,9 +5091,9 @@ declare namespace monaco.languages { export function registerDocumentHighlightProvider(languageId: string, provider: DocumentHighlightProvider): IDisposable; /** - * Register an on type rename provider. + * Register an on type rename range provider. */ - export function registerOnTypeRenameProvider(languageId: string, provider: OnTypeRenameProvider): IDisposable; + export function registerOnTypeRenameRangeProvider(languageId: string, provider: OnTypeRenameRangeProvider): IDisposable; /** * Register a definition provider (used by e.g. go to definition). @@ -5837,10 +5837,10 @@ declare namespace monaco.languages { } /** - * The rename provider interface defines the contract between extensions and + * The rename range provider interface defines the contract between extensions and * the live-rename feature. */ - export interface OnTypeRenameProvider { + export interface OnTypeRenameRangeProvider { /** * Provide a list of ranges that can be live-renamed together. */ diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index b64d06cc4acd3..7b524b8925a38 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1081,10 +1081,10 @@ declare module 'vscode' { //#region OnTypeRename: https://github.com/microsoft/vscode/issues/109923 @aeschli /** - * The 'on type' rename provider interface defines the contract between extensions and + * The 'on type' rename range provider interface defines the contract between extensions and * the 'on type' rename feature. */ - export interface OnTypeRenameProvider { + export interface OnTypeRenameRangeProvider { /** * For a given position in a document, returns the range of the symbol at the position and all ranges * that have the same content and can be renamed together. Optionally a word pattern can be returned @@ -1102,17 +1102,17 @@ declare module 'vscode' { namespace languages { /** - * Register a 'on type' rename provider. + * Register a 'on type' rename range provider. * * Multiple providers can be registered for a language. In that case providers are sorted * by their [score](#languages.match) and the best-matching provider that has a result is used. Failure * of the selected provider will cause a failure of the whole operation. * * @param selector A selector that defines the documents this provider is applicable to. - * @param provider An 'on type' rename provider. + * @param provider An 'on type' rename range provider. * @return A [disposable](#Disposable) that unregisters this provider when being disposed. */ - export function registerOnTypeRenameProvider(selector: DocumentSelector, provider: OnTypeRenameProvider): Disposable; + export function registerOnTypeRenameRangeProvider(selector: DocumentSelector, provider: OnTypeRenameRangeProvider): Disposable; } /** diff --git a/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts b/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts index 5e06096a342bc..f06c51cdc75a1 100644 --- a/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts +++ b/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts @@ -262,8 +262,8 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha // --- on type rename - $registerOnTypeRenameProvider(handle: number, selector: IDocumentFilterDto[]): void { - this._registrations.set(handle, modes.OnTypeRenameProviderRegistry.register(selector, { + $registerOnTypeRenameRangeProvider(handle: number, selector: IDocumentFilterDto[]): void { + this._registrations.set(handle, modes.OnTypeRenameRangeProviderRegistry.register(selector, { provideOnTypeRenameRanges: async (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise => { const res = await this._proxy.$provideOnTypeRenameRanges(handle, model.uri, position, token); if (res) { diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 1adb95a19ba31..42f167a6cd7ab 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -397,9 +397,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I registerDocumentHighlightProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentHighlightProvider): vscode.Disposable { return extHostLanguageFeatures.registerDocumentHighlightProvider(extension, checkSelector(selector), provider); }, - registerOnTypeRenameProvider(selector: vscode.DocumentSelector, provider: vscode.OnTypeRenameProvider): vscode.Disposable { + registerOnTypeRenameRangeProvider(selector: vscode.DocumentSelector, provider: vscode.OnTypeRenameRangeProvider): vscode.Disposable { checkProposedApiEnabled(extension); - return extHostLanguageFeatures.registerOnTypeRenameProvider(extension, checkSelector(selector), provider); + return extHostLanguageFeatures.registerOnTypeRenameRangeProvider(extension, checkSelector(selector), provider); }, registerReferenceProvider(selector: vscode.DocumentSelector, provider: vscode.ReferenceProvider): vscode.Disposable { return extHostLanguageFeatures.registerReferenceProvider(extension, checkSelector(selector), provider); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 0a8679fd6dee9..8c0dbb34885df 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -383,7 +383,7 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable { $registerHoverProvider(handle: number, selector: IDocumentFilterDto[]): void; $registerEvaluatableExpressionProvider(handle: number, selector: IDocumentFilterDto[]): void; $registerDocumentHighlightProvider(handle: number, selector: IDocumentFilterDto[]): void; - $registerOnTypeRenameProvider(handle: number, selector: IDocumentFilterDto[]): void; + $registerOnTypeRenameRangeProvider(handle: number, selector: IDocumentFilterDto[]): void; $registerReferenceSupport(handle: number, selector: IDocumentFilterDto[]): void; $registerQuickFixSupport(handle: number, selector: IDocumentFilterDto[], metadata: ICodeActionProviderMetadataDto, displayName: string, supportsResolve: boolean): void; $registerDocumentFormattingSupport(handle: number, selector: IDocumentFilterDto[], extensionId: ExtensionIdentifier, displayName: string): void; diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index ac81660326dd0..6868dd77e0737 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -311,10 +311,10 @@ class DocumentHighlightAdapter { } } -class OnTypeRenameAdapter { +class OnTypeRenameRangeAdapter { constructor( private readonly _documents: ExtHostDocuments, - private readonly _provider: vscode.OnTypeRenameProvider + private readonly _provider: vscode.OnTypeRenameRangeProvider ) { } provideOnTypeRenameRanges(resource: URI, position: IPosition, token: CancellationToken): Promise { @@ -1320,7 +1320,7 @@ type Adapter = DocumentSymbolAdapter | CodeLensAdapter | DefinitionAdapter | Hov | SuggestAdapter | SignatureHelpAdapter | LinkProviderAdapter | ImplementationAdapter | TypeDefinitionAdapter | ColorProviderAdapter | FoldingProviderAdapter | DeclarationAdapter | SelectionRangeAdapter | CallHierarchyAdapter | DocumentSemanticTokensAdapter | DocumentRangeSemanticTokensAdapter | EvaluatableExpressionAdapter - | OnTypeRenameAdapter; + | OnTypeRenameRangeAdapter; class AdapterData { constructor( @@ -1564,14 +1564,14 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF // --- on type rename - registerOnTypeRenameProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.OnTypeRenameProvider): vscode.Disposable { - const handle = this._addNewAdapter(new OnTypeRenameAdapter(this._documents, provider), extension); - this._proxy.$registerOnTypeRenameProvider(handle, this._transformDocumentSelector(selector)); + registerOnTypeRenameRangeProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.OnTypeRenameRangeProvider): vscode.Disposable { + const handle = this._addNewAdapter(new OnTypeRenameRangeAdapter(this._documents, provider), extension); + this._proxy.$registerOnTypeRenameRangeProvider(handle, this._transformDocumentSelector(selector)); return this._createDisposable(handle); } $provideOnTypeRenameRanges(handle: number, resource: UriComponents, position: IPosition, token: CancellationToken): Promise { - return this._withAdapter(handle, OnTypeRenameAdapter, async adapter => { + return this._withAdapter(handle, OnTypeRenameRangeAdapter, async adapter => { const res = await adapter.provideOnTypeRenameRanges(URI.revive(resource), position, token); if (res) { return {