Skip to content

Log when languageClient not loaded during initialization #1555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/features/Console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vscode = require("vscode");
import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient";
import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick";
import { IFeature } from "../feature";
import { Logger } from "../logging";

export const EvaluateRequestType = new RequestType<IEvaluateRequestArguments, void, void, void>("evaluate");
export const OutputNotificationType = new NotificationType<IOutputNotificationBody, void>("output");
Expand Down Expand Up @@ -200,11 +201,12 @@ export class ConsoleFeature implements IFeature {
private languageClient: LanguageClient;
private resolveStatusBarPromise: (value?: {} | PromiseLike<{}>) => void;

constructor() {
constructor(private log: Logger) {
this.commands = [
vscode.commands.registerCommand("PowerShell.RunSelection", async () => {
if (this.languageClient === undefined) {
// TODO: Log error message
this.log.writeAndShowError(`<${ConsoleFeature.name}>: ` +
"Unable to instantiate; language client undefined.");
return;
}

Expand Down
6 changes: 4 additions & 2 deletions src/features/ExpandAlias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import vscode = require("vscode");
import Window = vscode.window;
import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient";
import { IFeature } from "../feature";
import { Logger } from "../logging";

export const ExpandAliasRequestType = new RequestType<string, any, void, void>("powerShell/expandAlias");

export class ExpandAliasFeature implements IFeature {
private command: vscode.Disposable;
private languageClient: LanguageClient;

constructor() {
constructor(private log: Logger) {
this.command = vscode.commands.registerCommand("PowerShell.ExpandAlias", () => {
if (this.languageClient === undefined) {
// TODO: Log error message
this.log.writeAndShowError(`<${ExpandAliasFeature.name}>: ` +
"Unable to instantiate; language client undefined.");
return;
}

Expand Down
5 changes: 4 additions & 1 deletion src/features/SelectPSSARules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vscode = require("vscode");
import { LanguageClient, RequestType } from "vscode-languageclient";
import { ICheckboxQuickPickItem, showCheckboxQuickPick } from "../controls/checkboxQuickPick";
import { IFeature } from "../feature";
import { Logger } from "../logging";

export const GetPSSARulesRequestType = new RequestType<any, any, void, void>("powerShell/getPSSARules");
export const SetPSSARulesRequestType = new RequestType<any, any, void, void>("powerShell/setPSSARules");
Expand All @@ -20,9 +21,11 @@ export class SelectPSSARulesFeature implements IFeature {
private command: vscode.Disposable;
private languageClient: LanguageClient;

constructor() {
constructor(private log: Logger) {
this.command = vscode.commands.registerCommand("PowerShell.SelectPSSARules", () => {
if (this.languageClient === undefined) {
this.log.writeAndShowError(`<${SelectPSSARulesFeature.name}>: ` +
"Unable to instantiate; language client undefined.");
return;
}

Expand Down
6 changes: 4 additions & 2 deletions src/features/ShowHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import vscode = require("vscode");
import { LanguageClient, NotificationType, RequestType } from "vscode-languageclient";
import { IFeature } from "../feature";
import { Logger } from "../logging";

export const ShowHelpRequestType =
new RequestType<string, void, void, void>("powerShell/showHelp");
Expand All @@ -14,10 +15,11 @@ export class ShowHelpFeature implements IFeature {
private deprecatedCommand: vscode.Disposable;
private languageClient: LanguageClient;

constructor() {
constructor(private log: Logger) {
this.command = vscode.commands.registerCommand("PowerShell.ShowHelp", () => {
if (this.languageClient === undefined) {
// TODO: Log error message
this.log.writeAndShowError(`<${ShowHelpFeature.name}>: ` +
"Unable to instantiate; language client undefined.");
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ export function activate(context: vscode.ExtensionContext): void {

// Create features
extensionFeatures = [
new ConsoleFeature(),
new ConsoleFeature(logger),
new ExamplesFeature(),
new OpenInISEFeature(),
new GenerateBugReportFeature(sessionManager),
new ExpandAliasFeature(),
new ShowHelpFeature(),
new ExpandAliasFeature(logger),
new ShowHelpFeature(logger),
new FindModuleFeature(),
new PesterTestsFeature(sessionManager),
new ExtensionCommandsFeature(logger),
new SelectPSSARulesFeature(),
new SelectPSSARulesFeature(logger),
new CodeActionsFeature(),
new NewFileOrProjectFeature(),
new DocumentFormatterFeature(logger, documentSelector),
Expand Down