Skip to content

Commit a36e053

Browse files
committed
Add logging when language client not defined.
Clean up TODO comments Clean up request type naming. White space cleanup
1 parent 565e0ad commit a36e053

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/features/GetCommands.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import * as vscode from "vscode";
55
import { LanguageClient, RequestType } from "vscode-languageclient";
66
import { IFeature } from "../feature";
7+
import { Logger } from "../logging";
78

89
// TODO: Document this export: https://github.com/PowerShell/vscode-powershell/pull/1406#discussion_r209325655
910
// TODO: Also use something other than any if possible... We may have already addressed this with a previous attempt.
@@ -14,13 +15,13 @@ export class GetCommandsFeature implements IFeature {
1415
private languageClient: LanguageClient;
1516
private commandsExplorerProvider: CommandsExplorerProvider;
1617

17-
constructor() {
18+
constructor(private log: Logger) {
1819
this.command = vscode.commands.registerCommand("PowerShell.RefreshCommandsExplorer", () => {
1920
if (this.languageClient === undefined) {
20-
// TODO: Log error message
21+
this.log.writeAndShowError(`<${GetCommandsFeature.name}>: ` +
22+
"Unable to instantiate; language client undefined.");
2123
return;
2224
}
23-
// TODO: Refactor network code out of constructor
2425
this.languageClient.sendRequest(GetAllCommandsRequestType, "").then((result) => {
2526
this.commandsExplorerProvider.powerShellCommands = result.map(toCommand);
2627
this.commandsExplorerProvider.refresh();
@@ -102,10 +103,8 @@ class Command extends vscode.TreeItem {
102103
};
103104
}
104105

105-
public async getChildren(element): Promise<Command[]> {
106+
public async getChildren(element?): Promise<Command[]> {
106107
return [];
107-
// TODO: Determine why we're returning an empty array...
108-
// I think it's because we have to return something and
109-
// we're not actually using the tree view part just yet...
108+
// Returning an empty array because we need to return something.
110109
}
111110
}

src/features/ShowHelp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export class ShowHelpFeature implements IFeature {
3131
const cwr = doc.getWordRangeAtPosition(selection.active);
3232
const text = doc.getText(cwr);
3333

34-
this.languageClient.sendRequest(ShowHelpRequestType, text);
34+
this.languageClient.sendRequest(ShowHelpRequestType, text);
3535
} else {
36-
this.languageClient.sendRequest(ShowOnlineHelpRequestType, item.Name);
36+
this.languageClient.sendRequest(ShowHelpRequestType, item.Name);
3737
}
3838
});
3939

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function activate(context: vscode.ExtensionContext): void {
124124
new OpenInISEFeature(),
125125
new GenerateBugReportFeature(sessionManager),
126126
new ExpandAliasFeature(logger),
127-
new GetCommandsFeature(),
127+
new GetCommandsFeature(logger),
128128
new ShowHelpFeature(logger),
129129
new FindModuleFeature(),
130130
new PesterTestsFeature(sessionManager),
@@ -141,6 +141,7 @@ export function activate(context: vscode.ExtensionContext): void {
141141
new CustomViewsFeature(),
142142
new FoldingFeature(logger, documentSelector),
143143
];
144+
144145
sessionManager.setExtensionFeatures(extensionFeatures);
145146

146147
if (extensionSettings.startAutomatically) {

0 commit comments

Comments
 (0)