Skip to content

Commit

Permalink
mroe
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Oct 30, 2024
1 parent 36b8ab8 commit 5f3a610
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/csharpExtensionExports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ export interface CSharpExtensionExperimentalExports {
token: vscode.CancellationToken
) => Promise<Response>;
languageServerEvents: LanguageServerEvents;
outputChannel: vscode.OutputChannel;
traceChannel: vscode.OutputChannel;
}
5 changes: 2 additions & 3 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1039,15 +1039,14 @@ export async function activateRoslynLanguageServer(
platformInfo: PlatformInformation,
optionObservable: Observable<void>,
outputChannel: vscode.OutputChannel,
traceChannel: vscode.OutputChannel,
dotnetTestChannel: vscode.OutputChannel,
dotnetChannel: vscode.OutputChannel,
reporter: TelemetryReporter,
languageServerEvents: RoslynLanguageServerEvents
): Promise<RoslynLanguageServer> {
// 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,
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function activate(
let roslynLanguageServerStartedPromise: Promise<RoslynLanguageServer> | undefined = undefined;
let razorLanguageServerStartedPromise: Promise<void> | undefined = undefined;
let projectInitializationCompletePromise: Promise<void> | 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.
Expand Down Expand Up @@ -141,6 +141,7 @@ export async function activate(
platformInfo,
optionStream,
csharpChannel,
traceChannel,
dotnetTestChannel,
dotnetChannel,
reporter,
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 10 additions & 8 deletions test/lsptoolshost/integrationTests/codeactions.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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(', '));
Expand Down Expand Up @@ -314,22 +320,18 @@ async function getCodeActions(
range: vscode.Range,
resolveCount: number | undefined = undefined
): Promise<vscode.CodeAction[]> {
const uri = vscode.window.activeTextEditor!.document.uri;
console.log(`Getting actions for ${uri.toString()}`);
const codeActions = await vscode.commands.executeCommand<vscode.CodeAction[]>(
'vscode.executeCodeActionProvider',
vscode.window.activeTextEditor!.document.uri,
uri,
range,
/** kind **/ undefined,
resolveCount
);

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;
}

Expand Down
4 changes: 3 additions & 1 deletion test/lsptoolshost/integrationTests/integrationHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function activateCSharpExtension(): Promise<CSharpExtensionExports> {
const csharpExtension = vscode.extensions.getExtension<CSharpExtensionExports>('ms-dotnettools.csharp');
if (!csharpExtension) {
throw new Error('Failed to find installation of ms-dotnettools.csharp');
Expand Down Expand Up @@ -53,6 +53,8 @@ export async function activateCSharpExtension(): Promise<void> {
if (shouldRestart) {
await restartLanguageServer();
}

return csharpExtension.exports;
}

export function usingDevKit(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion test/vscodeLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function prepareVSCodeAndExecuteTests(
userDataDir: string,
env: NodeJS.ProcessEnv
): Promise<number> {
const vscodeExecutablePath = await downloadAndUnzipVSCode('1.94.2');
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable');
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);

console.log('Display: ' + env.DISPLAY);
Expand Down

0 comments on commit 5f3a610

Please sign in to comment.