From 2813b4955ce80b836dfdd897e83373f2532ec704 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Mon, 9 Sep 2024 13:31:18 -0700 Subject: [PATCH] Merge pull request #7536 from dibarbet/fix_all_fix Ensure the fix all resolve request reads an existing field --- src/lsptoolshost/fixAllCodeAction.ts | 10 +++++++--- src/lsptoolshost/roslynProtocol.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lsptoolshost/fixAllCodeAction.ts b/src/lsptoolshost/fixAllCodeAction.ts index d0741b5e5..d4a510f94 100644 --- a/src/lsptoolshost/fixAllCodeAction.ts +++ b/src/lsptoolshost/fixAllCodeAction.ts @@ -24,10 +24,14 @@ export function registerCodeActionFixAllCommands( } export async function getFixAllResponse( - data: LSPAny, + data: RoslynProtocol.CodeActionResolveData, languageServer: RoslynLanguageServer, outputChannel: vscode.OutputChannel ) { + if (!data.FixAllFlavors) { + throw new Error(`FixAllFlavors is missing from data ${JSON.stringify(data)}`); + } + const result = await vscode.window.showQuickPick(data.FixAllFlavors, { placeHolder: vscode.l10n.t('Pick a fix all scope'), }); @@ -41,7 +45,7 @@ export async function getFixAllResponse( async (_, token) => { if (result) { const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - title: data.title, + title: data.UniqueIdentifier, data: data, scope: result, }; @@ -71,7 +75,7 @@ export async function getFixAllResponse( async function registerFixAllResolveCodeAction( languageServer: RoslynLanguageServer, - codeActionData: any, + codeActionData: RoslynProtocol.CodeActionResolveData, outputChannel: vscode.OutputChannel ) { if (codeActionData) { diff --git a/src/lsptoolshost/roslynProtocol.ts b/src/lsptoolshost/roslynProtocol.ts index 7c0801886..4e5850770 100644 --- a/src/lsptoolshost/roslynProtocol.ts +++ b/src/lsptoolshost/roslynProtocol.ts @@ -188,6 +188,15 @@ export interface RoslynFixAllCodeAction extends CodeAction { scope: string; } +/** + * Should match the definition on the server side, but only the properties we require on the client side. + * https://github.com/dotnet/roslyn/blob/bd5c00e5e09de8564093f42d87fe49d4971f2e84/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs#L16C20-L16C41 + */ +export interface CodeActionResolveData { + UniqueIdentifier: string; + FixAllFlavors?: string[]; +} + export interface NamedPipeInformation { pipeName: string; }