mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
rename to OnTypeRenameRangeProvider. For #109923
This commit is contained in:
parent
0b8a242be0
commit
8134d8c9e7
|
@ -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 => {
|
||||
|
|
|
@ -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<Doc
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const OnTypeRenameProviderRegistry = new LanguageFeatureRegistry<OnTypeRenameProvider>();
|
||||
export const OnTypeRenameRangeProviderRegistry = new LanguageFeatureRegistry<OnTypeRenameRangeProvider>();
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
|
|
@ -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<OnTypeRenameRanges | undefined | null> {
|
||||
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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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: <any>registerHoverProvider,
|
||||
registerDocumentSymbolProvider: <any>registerDocumentSymbolProvider,
|
||||
registerDocumentHighlightProvider: <any>registerDocumentHighlightProvider,
|
||||
registerOnTypeRenameProvider: <any>registerOnTypeRenameProvider,
|
||||
registerOnTypeRenameRangeProvider: <any>registerOnTypeRenameRangeProvider,
|
||||
registerDefinitionProvider: <any>registerDefinitionProvider,
|
||||
registerImplementationProvider: <any>registerImplementationProvider,
|
||||
registerTypeDefinitionProvider: <any>registerTypeDefinitionProvider,
|
||||
|
|
8
src/vs/monaco.d.ts
vendored
8
src/vs/monaco.d.ts
vendored
|
@ -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.
|
||||
*/
|
||||
|
|
10
src/vs/vscode.proposed.d.ts
vendored
10
src/vs/vscode.proposed.d.ts
vendored
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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, <modes.OnTypeRenameProvider>{
|
||||
$registerOnTypeRenameRangeProvider(handle: number, selector: IDocumentFilterDto[]): void {
|
||||
this._registrations.set(handle, modes.OnTypeRenameRangeProviderRegistry.register(selector, <modes.OnTypeRenameRangeProvider>{
|
||||
provideOnTypeRenameRanges: async (model: ITextModel, position: EditorPosition, token: CancellationToken): Promise<modes.OnTypeRenameRanges | undefined> => {
|
||||
const res = await this._proxy.$provideOnTypeRenameRanges(handle, model.uri, position, token);
|
||||
if (res) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<modes.OnTypeRenameRanges | undefined> {
|
||||
|
@ -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<extHostProtocol.IOnTypeRenameRangesDto | undefined> {
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue