From f9c16a950d0791aab269b1a5507487d058712421 Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Mon, 7 Sep 2020 09:51:56 +0200 Subject: [PATCH] Support for prepare rename default behavior --- client/src/common/client.ts | 14 ++++++++++++++ protocol/src/common/protocol.ts | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/client/src/common/client.ts b/client/src/common/client.ts index bfeb22ed2..f37b55dae 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -2155,6 +2155,10 @@ class DocumentOnTypeFormattingFeature extends TextDocumentFeature { constructor(client: BaseLanguageClient) { @@ -2165,6 +2169,7 @@ class RenameFeature extends TextDocumentFeature { if (Range.is(result)) { return client.protocol2CodeConverter.asRange(result); + } else if (this.isDefaultBehavior(result)) { + return result.defaultBehavior === true + ? null + : Promise.reject(new Error(`The element can't be renamed.`)); } else if (result && Range.is(result.range)) { return { range: client.protocol2CodeConverter.asRange(result.range), @@ -2234,6 +2243,11 @@ class RenameFeature extends TextDocumentFeature { diff --git a/protocol/src/common/protocol.ts b/protocol/src/common/protocol.ts index c0703370c..1b2aae77c 100644 --- a/protocol/src/common/protocol.ts +++ b/protocol/src/common/protocol.ts @@ -2596,6 +2596,13 @@ export interface RenameClientCapabilities { * @since version 3.12.0 */ prepareSupport?: boolean; + + /** + * Client supports the default behavior result. + * + * @since version 3.16.0 + */ + prepareSupportDefaultBehavior?: boolean; } /** @@ -2651,10 +2658,12 @@ export interface PrepareRenameParams extends TextDocumentPositionParams, WorkDon /** * A request to test and perform the setup necessary for a rename. + * + * @since 3.16 - support for default behavior */ export namespace PrepareRenameRequest { export const method: 'textDocument/prepareRename' = 'textDocument/prepareRename'; - export const type = new ProtocolRequestType(method); + export const type = new ProtocolRequestType(method); } //---- Command Execution -------------------------------------------