Skip to content

Commit

Permalink
Merge pull request dotnet#7536 from dibarbet/fix_all_fix
Browse files Browse the repository at this point in the history
Ensure the fix all resolve request reads an existing field
  • Loading branch information
dibarbet committed Sep 9, 2024
1 parent 602baeb commit 2813b49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lsptoolshost/fixAllCodeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
});
Expand All @@ -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,
};
Expand Down Expand Up @@ -71,7 +75,7 @@ export async function getFixAllResponse(

async function registerFixAllResolveCodeAction(
languageServer: RoslynLanguageServer,
codeActionData: any,
codeActionData: RoslynProtocol.CodeActionResolveData,
outputChannel: vscode.OutputChannel
) {
if (codeActionData) {
Expand Down
9 changes: 9 additions & 0 deletions src/lsptoolshost/roslynProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2813b49

Please sign in to comment.