Merged
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,25 +5,25 @@ import vscode = require("vscode");
import { ILogger } from "../logging";

export class CodeActionsFeature implements vscode.Disposable {
private showDocumentationCommand: vscode.Disposable;
private command: vscode.Disposable;

constructor(private log: ILogger) {
// NOTE: While not exposed to the user via package.json, this is
// required as the server's code action sends across a command name.
//
// TODO: In the far future with LSP 3.19 the server can just set a URL
// and this can go away. See https://.com/microsoft/language-server-protocol/issues/1548
this.showDocumentationCommand =
this.command =
vscode.commands.registerCommand("PowerShell.ShowCodeActionDocumentation", async (ruleName: string) => {
await this.showRuleDocumentation(ruleName);
});
}

public dispose(): void {
this.showDocumentationCommand.dispose();
this.command.dispose();
}

public async showRuleDocumentation(ruleId: string): Promise<void> {
private async showRuleDocumentation(ruleId: string): Promise<void> {
const pssaDocBaseURL = "https://docs.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/";

if (!ruleId) {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,8 +200,8 @@ export class ConsoleFeature extends LanguageClientConsumer {
} else {
selectionRange = editor.document.lineAt(editor.selection.start.line).range;
}

await this.languageClient?.sendRequest(EvaluateRequestType, {
const client = await LanguageClientConsumer.getLanguageClient();
await client.sendRequest(EvaluateRequestType, {
expression: editor.document.getText(selectionRange),
});

Expand All@@ -217,19 +217,19 @@ export class ConsoleFeature extends LanguageClientConsumer {
for (const command of this.commands) {
command.dispose();
}

for (const handler of this.handlers) {
handler.dispose();
}
}

public override setLanguageClient(languageClient: LanguageClient): void {
this.languageClient = languageClient;
public override onLanguageClientSet(languageClient: LanguageClient): void {
this.handlers = [
this.languageClient.onRequest(
languageClient.onRequest(
ShowChoicePromptRequestType,
(promptDetails) => showChoicePrompt(promptDetails)),

this.languageClient.onRequest(
languageClient.onRequest(
ShowInputPromptRequestType,
(promptDetails) => showInputPrompt(promptDetails)),
];
Expand Down
Loading