From cd839146d640ab9e2ab4b761500fd9ee466ae8eb Mon Sep 17 00:00:00 2001 From: David Barbet Date: Wed, 30 Oct 2024 11:44:22 -0700 Subject: [PATCH] mroe --- src/csharpExtensionExports.ts | 2 ++ src/lsptoolshost/roslynLanguageServer.ts | 5 ++--- src/main.ts | 5 ++++- .../codeactions.integration.test.ts | 18 ++++++++++-------- .../integrationTests/integrationHelpers.ts | 4 +++- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/csharpExtensionExports.ts b/src/csharpExtensionExports.ts index 99bc7e3725..113c45e71d 100644 --- a/src/csharpExtensionExports.ts +++ b/src/csharpExtensionExports.ts @@ -35,4 +35,6 @@ export interface CSharpExtensionExperimentalExports { token: vscode.CancellationToken ) => Promise; languageServerEvents: LanguageServerEvents; + outputChannel: vscode.OutputChannel; + traceChannel: vscode.OutputChannel; } diff --git a/src/lsptoolshost/roslynLanguageServer.ts b/src/lsptoolshost/roslynLanguageServer.ts index 817321b9d7..527c8570c2 100644 --- a/src/lsptoolshost/roslynLanguageServer.ts +++ b/src/lsptoolshost/roslynLanguageServer.ts @@ -1039,15 +1039,14 @@ export async function activateRoslynLanguageServer( platformInfo: PlatformInformation, optionObservable: Observable, outputChannel: vscode.OutputChannel, + traceChannel: vscode.OutputChannel, dotnetTestChannel: vscode.OutputChannel, dotnetChannel: vscode.OutputChannel, reporter: TelemetryReporter, languageServerEvents: RoslynLanguageServerEvents ): Promise { - // Create a channel for outputting general logs from the language server. _channel = outputChannel; - // Create a separate channel for outputting trace logs - these are incredibly verbose and make other logs very difficult to see. - _traceChannel = vscode.window.createOutputChannel('C# LSP Trace Logs'); + _traceChannel = traceChannel; const hostExecutableResolver = new DotnetRuntimeExtensionResolver( platformInfo, diff --git a/src/main.ts b/src/main.ts index 3e560dc323..8c5240ee52 100644 --- a/src/main.ts +++ b/src/main.ts @@ -106,7 +106,7 @@ export async function activate( let roslynLanguageServerStartedPromise: Promise | undefined = undefined; let razorLanguageServerStartedPromise: Promise | undefined = undefined; let projectInitializationCompletePromise: Promise | undefined = undefined; - + const traceChannel = vscode.window.createOutputChannel('C# LSP Trace Logs'); if (!useOmnisharpServer) { // Activate Razor. Needs to be activated before Roslyn so commands are registered in the correct order. // Otherwise, if Roslyn starts up first, they could execute commands that don't yet exist on Razor's end. @@ -141,6 +141,7 @@ export async function activate( platformInfo, optionStream, csharpChannel, + traceChannel, dotnetTestChannel, dotnetChannel, reporter, @@ -246,6 +247,8 @@ export async function activate( experimental: { sendServerRequest: async (t, p, ct) => await languageServerExport.sendRequest(t, p, ct), languageServerEvents: roslynLanguageServerEvents, + outputChannel: csharpChannel, + traceChannel: traceChannel, }, getComponentFolder: (componentName) => { return getComponentFolder(componentName, languageServerOptions); diff --git a/test/lsptoolshost/integrationTests/codeactions.integration.test.ts b/test/lsptoolshost/integrationTests/codeactions.integration.test.ts index 708860ddbb..b8d6698c77 100644 --- a/test/lsptoolshost/integrationTests/codeactions.integration.test.ts +++ b/test/lsptoolshost/integrationTests/codeactions.integration.test.ts @@ -13,10 +13,12 @@ import { expectText, openFileInWorkspaceAsync, } from './integrationHelpers'; +import { CSharpExtensionExports } from '../../../src/csharpExtensionExports'; describe(`Code Actions Tests`, () => { + let csharpExports: CSharpExtensionExports | undefined = undefined; beforeAll(async () => { - await activateCSharpExtension(); + csharpExports = await activateCSharpExtension(); }); beforeEach(async () => { @@ -34,7 +36,11 @@ describe(`Code Actions Tests`, () => { test('Lightbulb displays actions', async () => { console.log('LIGHTBULB TEST'); + csharpExports!.experimental.outputChannel.appendLine('Lightbulb displays actions'); + csharpExports!.experimental.traceChannel.appendLine('Lightbulb displays actions'); const actions = await getCodeActions(new vscode.Range(0, 0, 0, 12)); + csharpExports!.experimental.traceChannel.appendLine(`Got actions ${actions.length}`); + csharpExports!.experimental.traceChannel.appendLine(JSON.stringify(actions, null, 4)); expect(actions.length).toBeGreaterThanOrEqual(3); console.log(actions.length); console.log(actions.map((a) => a.title).join(', ')); @@ -314,9 +320,11 @@ async function getCodeActions( range: vscode.Range, resolveCount: number | undefined = undefined ): Promise { + const uri = vscode.window.activeTextEditor!.document.uri; + console.log(`Getting actions for ${uri.toString()}`); const codeActions = await vscode.commands.executeCommand( 'vscode.executeCodeActionProvider', - vscode.window.activeTextEditor!.document.uri, + uri, range, /** kind **/ undefined, resolveCount @@ -324,12 +332,6 @@ async function getCodeActions( console.log(JSON.stringify(codeActions, null, 4)); - const moreAction = codeActions.find((a) => a.title === 'More...'); - if (moreAction) { - console.log('More actions available'); - console.log(JSON.stringify(moreAction, null, 4)); - } - return codeActions; } diff --git a/test/lsptoolshost/integrationTests/integrationHelpers.ts b/test/lsptoolshost/integrationTests/integrationHelpers.ts index c224d4fd90..461b06c7db 100644 --- a/test/lsptoolshost/integrationTests/integrationHelpers.ts +++ b/test/lsptoolshost/integrationTests/integrationHelpers.ts @@ -13,7 +13,7 @@ import testAssetWorkspace from './testAssets/testAssetWorkspace'; import { EOL } from 'os'; import { describe, expect, test } from '@jest/globals'; -export async function activateCSharpExtension(): Promise { +export async function activateCSharpExtension(): Promise { const csharpExtension = vscode.extensions.getExtension('ms-dotnettools.csharp'); if (!csharpExtension) { throw new Error('Failed to find installation of ms-dotnettools.csharp'); @@ -53,6 +53,8 @@ export async function activateCSharpExtension(): Promise { if (shouldRestart) { await restartLanguageServer(); } + + return csharpExtension.exports; } export function usingDevKit(): boolean {