From d82ae79c9e6fbbc6096cfeda63fac388b1aa7d94 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Wed, 4 Oct 2023 14:16:15 -0700 Subject: [PATCH 01/11] version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3de232c87..e59c58688 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csharp", "publisher": "ms-dotnettools", - "version": "2.0.0-placeholder", + "version": "2.0.1-placeholder", "description": "Base language support for C#", "displayName": "C#", "author": "Microsoft Corporation", From f026eb8da6166a59d6bb722901b3bf92561d5e0d Mon Sep 17 00:00:00 2001 From: akhera99 Date: Tue, 10 Oct 2023 10:47:12 -0700 Subject: [PATCH 02/11] wip --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6b3afd773..348c729bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "csharp", - "version": "2.0.0-placeholder", + "version": "42.42.42-placeholder", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "csharp", - "version": "2.0.0-placeholder", + "version": "42.42.42-placeholder", "license": "SEE LICENSE IN RuntimeLicenses/license.txt", "dependencies": { "@microsoft/servicehub-framework": "4.2.99-beta", diff --git a/package.json b/package.json index e59c58688..171d5e128 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csharp", "publisher": "ms-dotnettools", - "version": "2.0.1-placeholder", + "version": "42.42.42-placeholder", "description": "Base language support for C#", "displayName": "C#", "author": "Microsoft Corporation", From c4877e4df6a1b9a226992e4a45b55aa56d9baca7 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Thu, 19 Oct 2023 15:34:54 -0700 Subject: [PATCH 03/11] wip --- l10n/bundle.l10n.json | 2 + src/lsptoolshost/nestedCodeAction.ts | 164 +++++++++++++++++++++++ src/lsptoolshost/roslynLanguageServer.ts | 3 +- 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/lsptoolshost/nestedCodeAction.ts diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 859647485..6dabe733e 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -128,6 +128,8 @@ "Choose and set default": "Choose and set default", "Do not load any": "Do not load any", "C# configuration has changed. Would you like to reload the window to apply your changes?": "C# configuration has changed. Would you like to reload the window to apply your changes?", + "Pick a nested action": "Pick a nested action", + "Nested Code Action": "Nested Code Action", "Pick a fix all scope": "Pick a fix all scope", "Fix All Code Action": "Fix All Code Action", "pipeArgs must be a string or a string array type": "pipeArgs must be a string or a string array type", diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts new file mode 100644 index 000000000..e29cb2f5f --- /dev/null +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -0,0 +1,164 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as vscode from 'vscode'; +import * as RoslynProtocol from './roslynProtocol'; +import { CodeAction, CodeActionResolveRequest, LSPAny } from 'vscode-languageserver-protocol'; +import { RoslynLanguageServer } from './roslynLanguageServer'; +import { URIConverter, createConverter } from 'vscode-languageclient/lib/common/protocolConverter'; +import { UriConverter } from './uriConverter'; + +export function registerNestedCodeActionCommands( + context: vscode.ExtensionContext, + languageServer: RoslynLanguageServer, + outputChannel: vscode.OutputChannel +) { + context.subscriptions.push( + vscode.commands.registerCommand( + 'roslyn.client.nestedCodeAction', + async (request): Promise => registerNestedResolveCodeAction(languageServer, request, outputChannel) + ) + ); +} + +async function registerNestedResolveCodeAction( + languageServer: RoslynLanguageServer, + codeActionData: any, + outputChannel: vscode.OutputChannel +) { + if (codeActionData) { + const data = codeActionData; + const action = data.NestedCodeAction; + + if (action && action.nestedActions && action.nestedActions.length > 0) { + vscode.window + .showQuickPick( + action.nestedActions?.map((child: { title: string }) => child.title), + { + placeHolder: vscode.l10n.t('Pick a nested action'), + } + ) + .then(async (selectedValue) => { + if (selectedValue) { + const selectedAction = action.nestedActions?.find( + (child: { title: string }) => child.title === selectedValue + ); + if (selectedAction) { + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: vscode.l10n.t('Nested Code Action'), + cancellable: true, + }, + async (_, token) => { + let result: string | undefined; + if (selectedAction.data.FixAllFlavors) { + result = await vscode.window.showQuickPick(data.FixAllFlavors, { + placeHolder: vscode.l10n.t('Pick a fix all scope'), + }); + } + let response: CodeAction; + if (result) { + const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { + title: data.UniqueIdentifier, + data: data, + scope: result, + }; + + response = await languageServer.sendRequest( + RoslynProtocol.CodeActionFixAllResolveRequest.type, + fixAllCodeAction, + token + ); + } else { + const nestedCodeActionResolve: CodeAction = { + title: selectedAction.data.UniqueIdentifier, + data: selectedAction.data, + }; + + response = await languageServer.sendRequest( + CodeActionResolveRequest.type, + nestedCodeActionResolve, + token + ); + } + + if (response.edit) { + const uriConverter: URIConverter = (value: string): vscode.Uri => + UriConverter.deserialize(value); + const protocolConverter = createConverter(uriConverter, true, true); + const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); + if (!(await vscode.workspace.applyEdit(fixAllEdit))) { + if (result) { + const componentName = '[roslyn.client.fixAllCodeAction]'; + const errorMessage = 'Failed to make a fix all edit for completion.'; + outputChannel.show(); + outputChannel.appendLine(`${componentName} ${errorMessage}`); + throw new Error( + 'Tried to insert multiple code action edits, but an error occurred.' + ); + } else { + const componentName = '[roslyn.client.nestedCodeAction]'; + const errorMessage = 'Failed to make a edit for completion.'; + outputChannel.show(); + outputChannel.appendLine(`${componentName} ${errorMessage}`); + throw new Error( + 'Tried to insert code action edit, but an error occurred.' + ); + } + } + } + } + ); + } + } + }); + } + } + // if (codeActionData) { + // const data = codeActionData; + + // const result = await vscode.window.showQuickPick(data.NestedCodeAction, { + // placeHolder: vscode.l10n.t('Pick a nested action'), + // }); + + // await vscode.window.withProgress( + // { + // location: vscode.ProgressLocation.Notification, + // title: vscode.l10n.t('Nested Code Action'), + // cancellable: true, + // }, + // async (_, token) => { + // if (result) { + // const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { + // title: data.UniqueIdentifier, + // data: data, + // scope: result, + // }; + + // const response = await languageServer.sendRequest( + // RoslynProtocol.CodeActionFixAllResolveRequest.type, + // fixAllCodeAction, + // token + // ); + + // if (response.edit) { + // const uriConverter: URIConverter = (value: string): vscode.Uri => + // UriConverter.deserialize(value); + // const protocolConverter = createConverter(uriConverter, true, true); + // const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); + // if (!(await vscode.workspace.applyEdit(fixAllEdit))) { + // const componentName = '[roslyn.client.fixAllCodeAction]'; + // const errorMessage = 'Failed to make a fix all edit for completion.'; + // outputChannel.show(); + // outputChannel.appendLine(`${componentName} ${errorMessage}`); + // throw new Error('Tried to insert multiple code action edits, but an error occurred.'); + // } + // } + // } + // } + // ); + // } +} diff --git a/src/lsptoolshost/roslynLanguageServer.ts b/src/lsptoolshost/roslynLanguageServer.ts index 946fc3609..2783e3d2c 100644 --- a/src/lsptoolshost/roslynLanguageServer.ts +++ b/src/lsptoolshost/roslynLanguageServer.ts @@ -56,6 +56,7 @@ import { registerCodeActionFixAllCommands } from './fixAllCodeAction'; import { commonOptions, languageServerOptions, omnisharpOptions } from '../shared/options'; import { NamedPipeInformation } from './roslynProtocol'; import { IDisposable } from '../disposable'; +import { registerNestedCodeActionCommands } from './nestedCodeAction'; let _channel: vscode.OutputChannel; let _traceChannel: vscode.OutputChannel; @@ -862,7 +863,7 @@ export async function activateRoslynLanguageServer( // Register any commands that need to be handled by the extension. registerCommands(context, languageServer, hostExecutableResolver, _channel); - + registerNestedCodeActionCommands(context, languageServer, _channel); registerCodeActionFixAllCommands(context, languageServer, _channel); registerRazorCommands(context, languageServer); From a352cdc9188f74bc683bb2332dbba351f31822a5 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Mon, 23 Oct 2023 13:55:51 -0700 Subject: [PATCH 04/11] comments --- src/lsptoolshost/nestedCodeAction.ts | 46 +--------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index e29cb2f5f..121106b77 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -101,7 +101,7 @@ async function registerNestedResolveCodeAction( ); } else { const componentName = '[roslyn.client.nestedCodeAction]'; - const errorMessage = 'Failed to make a edit for completion.'; + const errorMessage = 'Failed to make am edit for completion.'; outputChannel.show(); outputChannel.appendLine(`${componentName} ${errorMessage}`); throw new Error( @@ -117,48 +117,4 @@ async function registerNestedResolveCodeAction( }); } } - // if (codeActionData) { - // const data = codeActionData; - - // const result = await vscode.window.showQuickPick(data.NestedCodeAction, { - // placeHolder: vscode.l10n.t('Pick a nested action'), - // }); - - // await vscode.window.withProgress( - // { - // location: vscode.ProgressLocation.Notification, - // title: vscode.l10n.t('Nested Code Action'), - // cancellable: true, - // }, - // async (_, token) => { - // if (result) { - // const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - // title: data.UniqueIdentifier, - // data: data, - // scope: result, - // }; - - // const response = await languageServer.sendRequest( - // RoslynProtocol.CodeActionFixAllResolveRequest.type, - // fixAllCodeAction, - // token - // ); - - // if (response.edit) { - // const uriConverter: URIConverter = (value: string): vscode.Uri => - // UriConverter.deserialize(value); - // const protocolConverter = createConverter(uriConverter, true, true); - // const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); - // if (!(await vscode.workspace.applyEdit(fixAllEdit))) { - // const componentName = '[roslyn.client.fixAllCodeAction]'; - // const errorMessage = 'Failed to make a fix all edit for completion.'; - // outputChannel.show(); - // outputChannel.appendLine(`${componentName} ${errorMessage}`); - // throw new Error('Tried to insert multiple code action edits, but an error occurred.'); - // } - // } - // } - // } - // ); - // } } From 6f307245fd6d9909a6139ac7dfcae8eff58a3465 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Mon, 30 Oct 2023 12:35:47 -0700 Subject: [PATCH 05/11] fixes --- src/lsptoolshost/nestedCodeAction.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index 121106b77..2ea0263ec 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -33,11 +33,12 @@ async function registerNestedResolveCodeAction( const action = data.NestedCodeAction; if (action && action.nestedActions && action.nestedActions.length > 0) { - vscode.window + await vscode.window .showQuickPick( action.nestedActions?.map((child: { title: string }) => child.title), { placeHolder: vscode.l10n.t('Pick a nested action'), + ignoreFocusOut: true, } ) .then(async (selectedValue) => { @@ -55,15 +56,16 @@ async function registerNestedResolveCodeAction( async (_, token) => { let result: string | undefined; if (selectedAction.data.FixAllFlavors) { - result = await vscode.window.showQuickPick(data.FixAllFlavors, { + result = await vscode.window.showQuickPick(selectedAction.data.FixAllFlavors, { placeHolder: vscode.l10n.t('Pick a fix all scope'), + ignoreFocusOut: true, }); } let response: CodeAction; if (result) { const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - title: data.UniqueIdentifier, - data: data, + title: selectedAction.data.UniqueIdentifier, + data: selectedAction.data, scope: result, }; From 5206a20f9ffea31a284245baf982cfbd6ed85922 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Thu, 2 Nov 2023 13:49:29 -0700 Subject: [PATCH 06/11] feedback --- src/lsptoolshost/fixAllCodeAction.ts | 83 ++++++++-------- src/lsptoolshost/nestedCodeAction.ts | 136 +++++++++++---------------- 2 files changed, 101 insertions(+), 118 deletions(-) diff --git a/src/lsptoolshost/fixAllCodeAction.ts b/src/lsptoolshost/fixAllCodeAction.ts index aa133d73a..b95f579f7 100644 --- a/src/lsptoolshost/fixAllCodeAction.ts +++ b/src/lsptoolshost/fixAllCodeAction.ts @@ -23,52 +23,59 @@ export function registerCodeActionFixAllCommands( ); } -async function registerFixAllResolveCodeAction( +export async function getFixAllResponse( + data: LSPAny, languageServer: RoslynLanguageServer, - codeActionData: any, outputChannel: vscode.OutputChannel ) { - if (codeActionData) { - const data = codeActionData; - const result = await vscode.window.showQuickPick(data.FixAllFlavors, { - placeHolder: vscode.l10n.t('Pick a fix all scope'), - }); + const result = await vscode.window.showQuickPick(data.FixAllFlavors, { + placeHolder: vscode.l10n.t('Pick a fix all scope'), + }); - await vscode.window.withProgress( - { - location: vscode.ProgressLocation.Notification, - title: vscode.l10n.t('Fix All Code Action'), - cancellable: true, - }, - async (_, token) => { - if (result) { - const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - title: data.UniqueIdentifier, - data: data, - scope: result, - }; + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: vscode.l10n.t('Fix All Code Action'), + cancellable: true, + }, + async (_, token) => { + if (result) { + const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { + title: data.UniqueIdentifier, + data: data, + scope: result, + }; - const response = await languageServer.sendRequest( - RoslynProtocol.CodeActionFixAllResolveRequest.type, - fixAllCodeAction, - token - ); + const response = await languageServer.sendRequest( + RoslynProtocol.CodeActionFixAllResolveRequest.type, + fixAllCodeAction, + token + ); - if (response.edit) { - const uriConverter: URIConverter = (value: string): vscode.Uri => - UriConverter.deserialize(value); - const protocolConverter = createConverter(uriConverter, true, true); - const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); - if (!(await vscode.workspace.applyEdit(fixAllEdit))) { - const componentName = '[roslyn.client.fixAllCodeAction]'; - const errorMessage = 'Failed to make a fix all edit for completion.'; - outputChannel.show(); - outputChannel.appendLine(`${componentName} ${errorMessage}`); - throw new Error('Tried to insert multiple code action edits, but an error occurred.'); - } + if (response.edit) { + const uriConverter: URIConverter = (value: string): vscode.Uri => UriConverter.deserialize(value); + const protocolConverter = createConverter(uriConverter, true, true); + const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); + if (!(await vscode.workspace.applyEdit(fixAllEdit))) { + const componentName = '[roslyn.client.fixAllCodeAction]'; + const errorMessage = 'Failed to make a fix all edit for completion.'; + outputChannel.show(); + outputChannel.appendLine(`${componentName} ${errorMessage}`); + throw new Error('Tried to insert multiple code action edits, but an error occurred.'); } } } - ); + } + ); +} + +async function registerFixAllResolveCodeAction( + languageServer: RoslynLanguageServer, + codeActionData: any, + outputChannel: vscode.OutputChannel +) { + if (codeActionData) { + const data = codeActionData; + await getFixAllResponse(data, languageServer, outputChannel); } } diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index 2ea0263ec..f72af88d1 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -9,6 +9,7 @@ import { CodeAction, CodeActionResolveRequest, LSPAny } from 'vscode-languageser import { RoslynLanguageServer } from './roslynLanguageServer'; import { URIConverter, createConverter } from 'vscode-languageclient/lib/common/protocolConverter'; import { UriConverter } from './uriConverter'; +import { getFixAllResponse } from './fixAllCodeAction'; export function registerNestedCodeActionCommands( context: vscode.ExtensionContext, @@ -27,96 +28,71 @@ async function registerNestedResolveCodeAction( languageServer: RoslynLanguageServer, codeActionData: any, outputChannel: vscode.OutputChannel -) { +): Promise { if (codeActionData) { const data = codeActionData; const action = data.NestedCodeAction; - if (action && action.nestedActions && action.nestedActions.length > 0) { - await vscode.window - .showQuickPick( - action.nestedActions?.map((child: { title: string }) => child.title), + if (action?.nestedActions?.length > 0) { + const selectedValue = await vscode.window.showQuickPick( + action.nestedActions?.map((child: { title: string }) => child.title), + { + placeHolder: vscode.l10n.t('Pick a nested action'), + ignoreFocusOut: true, + } + ); + if (selectedValue) { + const selectedAction = action.nestedActions?.find( + (child: { title: string }) => child.title === selectedValue + ); + + if (!selectedAction) { + return; + } + + if (selectedAction.data.FixAllFlavors) { + await getFixAllResponse(selectedAction.data, languageServer, outputChannel); + return; + } + + await vscode.window.withProgress( { - placeHolder: vscode.l10n.t('Pick a nested action'), - ignoreFocusOut: true, - } - ) - .then(async (selectedValue) => { - if (selectedValue) { - const selectedAction = action.nestedActions?.find( - (child: { title: string }) => child.title === selectedValue - ); - if (selectedAction) { - await vscode.window.withProgress( - { - location: vscode.ProgressLocation.Notification, - title: vscode.l10n.t('Nested Code Action'), - cancellable: true, - }, - async (_, token) => { - let result: string | undefined; - if (selectedAction.data.FixAllFlavors) { - result = await vscode.window.showQuickPick(selectedAction.data.FixAllFlavors, { - placeHolder: vscode.l10n.t('Pick a fix all scope'), - ignoreFocusOut: true, - }); - } - let response: CodeAction; - if (result) { - const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - title: selectedAction.data.UniqueIdentifier, - data: selectedAction.data, - scope: result, - }; + location: vscode.ProgressLocation.Notification, + title: vscode.l10n.t('Nested Code Action'), + cancellable: true, + }, + async (_, token) => { + const nestedCodeActionResolve: CodeAction = { + title: selectedAction.data.UniqueIdentifier, + data: selectedAction.data, + }; - response = await languageServer.sendRequest( - RoslynProtocol.CodeActionFixAllResolveRequest.type, - fixAllCodeAction, - token - ); - } else { - const nestedCodeActionResolve: CodeAction = { - title: selectedAction.data.UniqueIdentifier, - data: selectedAction.data, - }; + const response = await languageServer.sendRequest( + CodeActionResolveRequest.type, + nestedCodeActionResolve, + token + ); - response = await languageServer.sendRequest( - CodeActionResolveRequest.type, - nestedCodeActionResolve, - token - ); - } + if (!response.edit) { + outputChannel.show(); + outputChannel.appendLine(`Failed to make an edit for completion.`); + return; + } - if (response.edit) { - const uriConverter: URIConverter = (value: string): vscode.Uri => - UriConverter.deserialize(value); - const protocolConverter = createConverter(uriConverter, true, true); - const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); - if (!(await vscode.workspace.applyEdit(fixAllEdit))) { - if (result) { - const componentName = '[roslyn.client.fixAllCodeAction]'; - const errorMessage = 'Failed to make a fix all edit for completion.'; - outputChannel.show(); - outputChannel.appendLine(`${componentName} ${errorMessage}`); - throw new Error( - 'Tried to insert multiple code action edits, but an error occurred.' - ); - } else { - const componentName = '[roslyn.client.nestedCodeAction]'; - const errorMessage = 'Failed to make am edit for completion.'; - outputChannel.show(); - outputChannel.appendLine(`${componentName} ${errorMessage}`); - throw new Error( - 'Tried to insert code action edit, but an error occurred.' - ); - } - } - } - } - ); + const uriConverter: URIConverter = (value: string): vscode.Uri => + UriConverter.deserialize(value); + const protocolConverter = createConverter(uriConverter, true, true); + const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit); + if (!(await vscode.workspace.applyEdit(fixAllEdit))) { + const componentName = '[roslyn.client.nestedCodeAction]'; + const errorMessage = 'Failed to make am edit for completion.'; + outputChannel.show(); + outputChannel.appendLine(`${componentName} ${errorMessage}`); + throw new Error('Tried to insert code action edit, but an error occurred.'); } } - }); + ); + } } } } From 91168460f7011770cbfe7857bc28930285074950 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Mon, 6 Nov 2023 09:38:28 -0800 Subject: [PATCH 07/11] fixes --- l10n/bundle.l10n.json | 9 ++++++++- src/lsptoolshost/fixAllCodeAction.ts | 12 +++++++++--- src/lsptoolshost/nestedCodeAction.ts | 7 +++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 6dabe733e..3c92f264d 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -5,6 +5,7 @@ "Does not contain .NET Core projects.": "Does not contain .NET Core projects.", "No launchable target found for '{0}'": "No launchable target found for '{0}'", "Cannot resolve .NET debug configurations. The server is still initializing or has exited unexpectedly.": "Cannot resolve .NET debug configurations. The server is still initializing or has exited unexpectedly.", + "Unable to determine a configuration for '{0}'. Please generate C# debug assets instead.": "Unable to determine a configuration for '{0}'. Please generate C# debug assets instead.", "'{0}' is not an executable project.": "'{0}' is not an executable project.", "Unable to determine debug settings for project '{0}'": "Unable to determine debug settings for project '{0}'", "No process was selected.": "No process was selected.", @@ -15,6 +16,7 @@ "More Information": "More Information", "The selected launch configuration is configured to launch a web browser but no trusted development certificate was found. Create a trusted self-signed certificate?": "The selected launch configuration is configured to launch a web browser but no trusted development certificate was found. Create a trusted self-signed certificate?", "Self-signed certificate sucessfully {0}": "Self-signed certificate sucessfully {0}", + "Couldn't create self-signed certificate. {0}\ncode: {1}\nstdout: {2}": "Couldn't create self-signed certificate. {0}\ncode: {1}\nstdout: {2}", "Show Output": "Show Output", "Couldn't create self-signed certificate. See output for more information.": "Couldn't create self-signed certificate. See output for more information.", "No executable projects": "No executable projects", @@ -35,6 +37,7 @@ "Required assets to build and debug are missing from '{0}'. Add them?": "Required assets to build and debug are missing from '{0}'. Add them?", "Cancel": "Cancel", "Replace existing build and debug assets?": "Replace existing build and debug assets?", + "Could not locate .NET Core project in '{0}'. Assets were not generated.": "Could not locate .NET Core project in '{0}'. Assets were not generated.", "Unable to generate assets to build and debug. {0}.": "Unable to generate assets to build and debug. {0}.", "Cannot load Razor language server because the directory was not found: '{0}'": "Cannot load Razor language server because the directory was not found: '{0}'", "Could not find '{0}' in or above '{1}'.": "Could not find '{0}' in or above '{1}'.", @@ -128,7 +131,6 @@ "Choose and set default": "Choose and set default", "Do not load any": "Do not load any", "C# configuration has changed. Would you like to reload the window to apply your changes?": "C# configuration has changed. Would you like to reload the window to apply your changes?", - "Pick a nested action": "Pick a nested action", "Nested Code Action": "Nested Code Action", "Pick a fix all scope": "Pick a fix all scope", "Fix All Code Action": "Fix All Code Action", @@ -144,12 +146,17 @@ "Failed to set extension directory": "Failed to set extension directory", "Failed to set debugadpter directory": "Failed to set debugadpter directory", "Failed to set install complete file path": "Failed to set install complete file path", + "The .NET Core SDK located on the path is too old. .NET Core debugging will not be enabled. The minimum supported version is {0}.": "The .NET Core SDK located on the path is too old. .NET Core debugging will not be enabled. The minimum supported version is {0}.", + "The .NET Core SDK cannot be located: {0}. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.": "The .NET Core SDK cannot be located: {0}. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.", + "The value '{0}' for 'targetArchitecture' in launch configuraiton is invalid. Expected 'x86_64' or 'arm64'.": "The value '{0}' for 'targetArchitecture' in launch configuraiton is invalid. Expected 'x86_64' or 'arm64'.", + "Unable to determine RuntimeId. Please set 'targetArchitecture' in your launch.json configuration.": "Unable to determine RuntimeId. Please set 'targetArchitecture' in your launch.json configuration.", "Unexpected RuntimeId '{0}'.": "Unexpected RuntimeId '{0}'.", "Ignoring non-parseable lines in envFile {0}: {1}.": "Ignoring non-parseable lines in envFile {0}: {1}.", "Unexpected message received from debugger.": "Unexpected message received from debugger.", "[ERROR]: C# Extension failed to install the debugger package.": "[ERROR]: C# Extension failed to install the debugger package.", "Could not find a process id to attach.": "Could not find a process id to attach.", "[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer.": "[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer.", + "[WARNING]: x86 Windows is not supported by the .NET debugger. Debugging will not be available.": "[WARNING]: x86 Windows is not supported by the .NET debugger. Debugging will not be available.", "[ERROR] The debugger cannot be installed. Unknown platform.": "[ERROR] The debugger cannot be installed. Unknown platform.", "Failed to complete the installation of the C# extension. Please see the error in the output window below.": "Failed to complete the installation of the C# extension. Please see the error in the output window below.", "An error occurred during installation of the .NET Debugger. The C# extension may need to be reinstalled.": "An error occurred during installation of the .NET Debugger. The C# extension may need to be reinstalled.", diff --git a/src/lsptoolshost/fixAllCodeAction.ts b/src/lsptoolshost/fixAllCodeAction.ts index b95f579f7..069581899 100644 --- a/src/lsptoolshost/fixAllCodeAction.ts +++ b/src/lsptoolshost/fixAllCodeAction.ts @@ -26,7 +26,8 @@ export function registerCodeActionFixAllCommands( export async function getFixAllResponse( data: LSPAny, languageServer: RoslynLanguageServer, - outputChannel: vscode.OutputChannel + outputChannel: vscode.OutputChannel, + originalCodeActionTitle: string | null ) { const result = await vscode.window.showQuickPick(data.FixAllFlavors, { placeHolder: vscode.l10n.t('Pick a fix all scope'), @@ -40,8 +41,13 @@ export async function getFixAllResponse( }, async (_, token) => { if (result) { + let title: string = data.UniqueIdentifier; + if (originalCodeActionTitle) { + title = 'Fix All: ' + originalCodeActionTitle + '|' + title.replace('Fix All: ', ''); + } + const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - title: data.UniqueIdentifier, + title: title, data: data, scope: result, }; @@ -76,6 +82,6 @@ async function registerFixAllResolveCodeAction( ) { if (codeActionData) { const data = codeActionData; - await getFixAllResponse(data, languageServer, outputChannel); + await getFixAllResponse(data, languageServer, outputChannel, null); } } diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index f72af88d1..05c33c725 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import * as RoslynProtocol from './roslynProtocol'; import { CodeAction, CodeActionResolveRequest, LSPAny } from 'vscode-languageserver-protocol'; import { RoslynLanguageServer } from './roslynLanguageServer'; import { URIConverter, createConverter } from 'vscode-languageclient/lib/common/protocolConverter'; @@ -37,7 +36,7 @@ async function registerNestedResolveCodeAction( const selectedValue = await vscode.window.showQuickPick( action.nestedActions?.map((child: { title: string }) => child.title), { - placeHolder: vscode.l10n.t('Pick a nested action'), + placeHolder: vscode.l10n.t(action.title), ignoreFocusOut: true, } ); @@ -51,7 +50,7 @@ async function registerNestedResolveCodeAction( } if (selectedAction.data.FixAllFlavors) { - await getFixAllResponse(selectedAction.data, languageServer, outputChannel); + await getFixAllResponse(selectedAction.data, languageServer, outputChannel, data.UniqueIdentifier); return; } @@ -63,7 +62,7 @@ async function registerNestedResolveCodeAction( }, async (_, token) => { const nestedCodeActionResolve: CodeAction = { - title: selectedAction.data.UniqueIdentifier, + title: data.UniqueIdentifier + '|' + selectedAction.data.UniqueIdentifier, data: selectedAction.data, }; From fad7d073cb8359944718d73ff9aab76141144c16 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Mon, 13 Nov 2023 14:12:41 -0800 Subject: [PATCH 08/11] feedback --- l10n/bundle.l10n.json | 1 + src/lsptoolshost/fixAllCodeAction.ts | 12 ++---- src/lsptoolshost/nestedCodeAction.ts | 58 ++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 3c92f264d..7cec30906 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -132,6 +132,7 @@ "Do not load any": "Do not load any", "C# configuration has changed. Would you like to reload the window to apply your changes?": "C# configuration has changed. Would you like to reload the window to apply your changes?", "Nested Code Action": "Nested Code Action", + "Fix All: ": "Fix All: ", "Pick a fix all scope": "Pick a fix all scope", "Fix All Code Action": "Fix All Code Action", "pipeArgs must be a string or a string array type": "pipeArgs must be a string or a string array type", diff --git a/src/lsptoolshost/fixAllCodeAction.ts b/src/lsptoolshost/fixAllCodeAction.ts index 069581899..d0741b5e5 100644 --- a/src/lsptoolshost/fixAllCodeAction.ts +++ b/src/lsptoolshost/fixAllCodeAction.ts @@ -26,8 +26,7 @@ export function registerCodeActionFixAllCommands( export async function getFixAllResponse( data: LSPAny, languageServer: RoslynLanguageServer, - outputChannel: vscode.OutputChannel, - originalCodeActionTitle: string | null + outputChannel: vscode.OutputChannel ) { const result = await vscode.window.showQuickPick(data.FixAllFlavors, { placeHolder: vscode.l10n.t('Pick a fix all scope'), @@ -41,13 +40,8 @@ export async function getFixAllResponse( }, async (_, token) => { if (result) { - let title: string = data.UniqueIdentifier; - if (originalCodeActionTitle) { - title = 'Fix All: ' + originalCodeActionTitle + '|' + title.replace('Fix All: ', ''); - } - const fixAllCodeAction: RoslynProtocol.RoslynFixAllCodeAction = { - title: title, + title: data.title, data: data, scope: result, }; @@ -82,6 +76,6 @@ async function registerFixAllResolveCodeAction( ) { if (codeActionData) { const data = codeActionData; - await getFixAllResponse(data, languageServer, outputChannel, null); + await getFixAllResponse(data, languageServer, outputChannel); } } diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index 05c33c725..74f76c98c 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -33,24 +33,20 @@ async function registerNestedResolveCodeAction( const action = data.NestedCodeAction; if (action?.nestedActions?.length > 0) { - const selectedValue = await vscode.window.showQuickPick( - action.nestedActions?.map((child: { title: string }) => child.title), - { - placeHolder: vscode.l10n.t(action.title), - ignoreFocusOut: true, - } - ); + const codeActionTitles: string[] = getCodeActionTitles(action.nestedActions); + const selectedValue = await vscode.window.showQuickPick(codeActionTitles, { + placeHolder: vscode.l10n.t(action.title), + ignoreFocusOut: true, + }); if (selectedValue) { - const selectedAction = action.nestedActions?.find( - (child: { title: string }) => child.title === selectedValue - ); + const selectedAction = retrieveSelectedAction(selectedValue, action.nestedActions); if (!selectedAction) { return; } if (selectedAction.data.FixAllFlavors) { - await getFixAllResponse(selectedAction.data, languageServer, outputChannel, data.UniqueIdentifier); + await getFixAllResponse(selectedAction.data, languageServer, outputChannel); return; } @@ -62,7 +58,7 @@ async function registerNestedResolveCodeAction( }, async (_, token) => { const nestedCodeActionResolve: CodeAction = { - title: data.UniqueIdentifier + '|' + selectedAction.data.UniqueIdentifier, + title: selectedAction.title, data: selectedAction.data, }; @@ -95,3 +91,41 @@ async function registerNestedResolveCodeAction( } } } + +function getCodeActionTitles(nestedActions: any): string[] { + // Flatten the array of strings and concatenate with " ->" + return nestedActions.flatMap( + (nestedAction: { + data: { + FixAllFlavors: string[] | null; + CodeActionPath: string[]; + }; + }) => { + const codeActionPath = nestedAction.data.CodeActionPath; + const fixAllFlavors = nestedAction.data.FixAllFlavors; + // If there's only one string, return it directly + if (codeActionPath.length === 1) { + return codeActionPath; + } + + // Concatenate multiple strings with " ->" + const concatenatedString = codeActionPath.slice(1).join(' -> '); + const fixAllString = vscode.l10n.t('Fix All: '); + return fixAllFlavors ? [`${fixAllString}${concatenatedString}`] : concatenatedString; + } + ); +} + +function retrieveSelectedAction(selectedValue: string, nestedActions: any): any { + return nestedActions.find( + (nestedAction: { data: { CodeActionPath: string[]; FixAllFlavors: string[] | null } }) => { + const codeActionPath = nestedAction.data.CodeActionPath; + const fixAllFlavors = nestedAction.data.FixAllFlavors; + const fixAllString = vscode.l10n.t('Fix All: '); + const concatenatedString = codeActionPath.slice(1).join(' -> '); + return fixAllFlavors + ? `${fixAllString}${concatenatedString}` === selectedValue + : concatenatedString === selectedValue; + } + ); +} From 3bae5d98d25c04b1d71e4f61d295e59722ec8972 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Mon, 13 Nov 2023 22:02:28 -0800 Subject: [PATCH 09/11] feedbacK --- src/lsptoolshost/nestedCodeAction.ts | 56 +++++++++------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index 74f76c98c..28fb064e5 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -33,14 +33,13 @@ async function registerNestedResolveCodeAction( const action = data.NestedCodeAction; if (action?.nestedActions?.length > 0) { - const codeActionTitles: string[] = getCodeActionTitles(action.nestedActions); + const codeActionTitles = getCodeActionTitles(action.nestedActions); const selectedValue = await vscode.window.showQuickPick(codeActionTitles, { placeHolder: vscode.l10n.t(action.title), ignoreFocusOut: true, }); if (selectedValue) { - const selectedAction = retrieveSelectedAction(selectedValue, action.nestedActions); - + const selectedAction = selectedValue.codeAction; if (!selectedAction) { return; } @@ -71,7 +70,7 @@ async function registerNestedResolveCodeAction( if (!response.edit) { outputChannel.show(); outputChannel.appendLine(`Failed to make an edit for completion.`); - return; + throw new Error('Tried to retrieve a code action edit, but an error occurred.'); } const uriConverter: URIConverter = (value: string): vscode.Uri => @@ -92,40 +91,21 @@ async function registerNestedResolveCodeAction( } } -function getCodeActionTitles(nestedActions: any): string[] { - // Flatten the array of strings and concatenate with " ->" - return nestedActions.flatMap( - (nestedAction: { - data: { - FixAllFlavors: string[] | null; - CodeActionPath: string[]; - }; - }) => { - const codeActionPath = nestedAction.data.CodeActionPath; - const fixAllFlavors = nestedAction.data.FixAllFlavors; - // If there's only one string, return it directly - if (codeActionPath.length === 1) { - return codeActionPath; - } - - // Concatenate multiple strings with " ->" - const concatenatedString = codeActionPath.slice(1).join(' -> '); - const fixAllString = vscode.l10n.t('Fix All: '); - return fixAllFlavors ? [`${fixAllString}${concatenatedString}`] : concatenatedString; +function getCodeActionTitles(nestedActions: any): any[] { + return nestedActions.map((nestedAction: { data: { CodeActionPath: any; FixAllFlavors: any } }) => { + const codeActionPath = nestedAction.data.CodeActionPath; + const fixAllFlavors = nestedAction.data.FixAllFlavors; + // If there's only one string, return it directly + if (codeActionPath.length === 1) { + return codeActionPath; } - ); -} -function retrieveSelectedAction(selectedValue: string, nestedActions: any): any { - return nestedActions.find( - (nestedAction: { data: { CodeActionPath: string[]; FixAllFlavors: string[] | null } }) => { - const codeActionPath = nestedAction.data.CodeActionPath; - const fixAllFlavors = nestedAction.data.FixAllFlavors; - const fixAllString = vscode.l10n.t('Fix All: '); - const concatenatedString = codeActionPath.slice(1).join(' -> '); - return fixAllFlavors - ? `${fixAllString}${concatenatedString}` === selectedValue - : concatenatedString === selectedValue; - } - ); + // Concatenate multiple strings with " ->" + const concatenatedString = codeActionPath.slice(1).join(' -> '); + const fixAllString = vscode.l10n.t('Fix All: '); + return { + label: fixAllFlavors ? `${fixAllString}${concatenatedString}` : concatenatedString, + codeAction: nestedAction, + }; + }); } From fb9ef9f997d202b0cb379be482eb0dbdd19f1245 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Tue, 14 Nov 2023 13:57:23 -0800 Subject: [PATCH 10/11] updated based on roslyn side --- src/lsptoolshost/nestedCodeAction.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lsptoolshost/nestedCodeAction.ts b/src/lsptoolshost/nestedCodeAction.ts index 28fb064e5..39bc22db7 100644 --- a/src/lsptoolshost/nestedCodeAction.ts +++ b/src/lsptoolshost/nestedCodeAction.ts @@ -30,12 +30,12 @@ async function registerNestedResolveCodeAction( ): Promise { if (codeActionData) { const data = codeActionData; - const action = data.NestedCodeAction; + const actions = data.NestedCodeActions; - if (action?.nestedActions?.length > 0) { - const codeActionTitles = getCodeActionTitles(action.nestedActions); + if (actions.length > 0) { + const codeActionTitles = getCodeActionTitles(actions); const selectedValue = await vscode.window.showQuickPick(codeActionTitles, { - placeHolder: vscode.l10n.t(action.title), + placeHolder: vscode.l10n.t(data.UniqueIdentifier), ignoreFocusOut: true, }); if (selectedValue) { From 17042b4a17b853867a3835e8ffdebf79252c3769 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Thu, 16 Nov 2023 16:23:07 -0800 Subject: [PATCH 11/11] update roslyn version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e8a15042..c334a16be 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ } }, "defaults": { - "roslyn": "4.9.0-2.23563.2", + "roslyn": "4.9.0-2.23566.1", "omniSharp": "1.39.10", "razor": "7.0.0-preview.23528.1", "razorOmnisharp": "7.0.0-preview.23363.1",