Skip to content

Commit b3ba01f

Browse files
author
Kapil Borle
committed
Update interface names and clean-up some
1 parent b00bc50 commit b3ba01f

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

src/checkboxQuickPick.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import vscode = require('vscode');
5+
import vscode = require("vscode");
66
import QuickPickItem = vscode.QuickPickItem;
7-
const figures = require('figures');
7+
const figures: any = require("figures");
88

9-
export interface Option {
9+
export interface ICheckboxOption {
1010
name: string;
1111
isSelected: boolean;
1212
}
1313

1414
export class CheckboxQuickPick {
15-
private options: Option[];
15+
private options: ICheckboxOption[];
1616
private readonly confirm: string;
1717
private readonly checkboxOn: string;
1818
private readonly checkboxOff: string;
1919
private readonly confirmPlaceHolder: string;
2020

21-
constructor(options: Option[]) {
21+
constructor(options: ICheckboxOption[]) {
2222
this.options = options;
2323
this.confirm = figures.tick;
2424
this.checkboxOn = "[ x ]";
2525
this.checkboxOff = "[ ]";
2626
this.confirmPlaceHolder = "Select " + this.confirm + " to confirm";
2727
}
2828

29-
public show(callback: (options: Option[]) => void) {
30-
let tempOptions = this.options.slice();
29+
public show(callback: (options: ICheckboxOption[]) => void): void {
30+
let tempOptions: ICheckboxOption[] = this.options.slice();
3131
this.showInner(tempOptions, callback);
3232
}
3333

34-
private showInner(tempOptions: Option[], callback: (options: Option[]) => void) {
34+
private showInner(tempOptions: ICheckboxOption[], callback: (options: ICheckboxOption[]) => void): void {
3535
vscode.window.showQuickPick(
3636
this.getQuickPickItems(tempOptions),
3737
{ ignoreFocusOut: true, placeHolder: this.confirmPlaceHolder }).then((selection) => {
@@ -45,18 +45,17 @@ export class CheckboxQuickPick {
4545
return;
4646
}
4747

48-
let index = this.getRuleIndex(tempOptions, selection.description);
49-
// this.toggleOption(tempOptions[index]);
50-
tempOptions[index].isSelected = this.toggleState(tempOptions[index].isSelected);
48+
let index: number = this.getRuleIndex(tempOptions, selection.description);
49+
this.toggleOption(tempOptions[index]);
5150
this.showInner(tempOptions, callback);
5251
});
5352
}
5453

55-
private getRuleIndex(options: Option[], optionLabel: string) {
54+
private getRuleIndex(options: ICheckboxOption[], optionLabel: string): number {
5655
return options.findIndex(opt => opt.name == optionLabel);
5756
}
5857

59-
private getQuickPickItems(tempOptions: Option[]): QuickPickItem[] {
58+
private getQuickPickItems(tempOptions: ICheckboxOption[]): QuickPickItem[] {
6059
let quickPickItems: QuickPickItem[] = [];
6160
tempOptions.forEach(option =>
6261
quickPickItems.push({
@@ -70,14 +69,14 @@ export class CheckboxQuickPick {
7069
return checkBox == this.checkboxOn;
7170
}
7271

73-
private toggleOption(option: Option) {
74-
option.isSelected = this.toggleState(option.isSelected);
75-
}
76-
7772
private toggleState(state: boolean): boolean {
7873
return !state;
7974
}
8075

76+
private toggleOption(option: ICheckboxOption): void {
77+
option.isSelected = this.toggleState(option.isSelected);
78+
}
79+
8180
private toggleCheckBox(checkBox: string): string {
8281
return this.convertToCheckBox(this.toggleState(this.convertToState(checkBox)));
8382
}

src/features/SelectPSSARules.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import vscode = require('vscode');
6-
import { IFeature } from '../feature';
7-
import QuickPickItem = vscode.QuickPickItem;
8-
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
9-
import { Option, CheckboxQuickPick } from '../checkboxQuickPick';
10-
const figures = require('figures');
5+
import vscode = require("vscode");
6+
import { IFeature } from "../feature";
7+
import { LanguageClient, RequestType } from "vscode-languageclient";
8+
import { ICheckboxOption, CheckboxQuickPick } from "../checkboxQuickPick";
119

1210
export namespace GetPSSARulesRequest {
13-
export const type: RequestType<any, any, void> = { get method() { return 'powerShell/getPSSARules'; } };
11+
export const type: RequestType<any, any, void> = { get method(): string { return "powerShell/getPSSARules"; } };
1412
}
1513

1614
export namespace SetPSSARulesRequest {
17-
export const type: RequestType<any, any, void> = { get method() { return 'powerShell/setPSSARules'; } }
15+
export const type: RequestType<any, any, void> = { get method(): string { return "powerShell/setPSSARules"; } };
1816
}
1917

20-
interface RuleInfo {
18+
interface IRuleInfo {
2119
name: string;
2220
isEnabled: boolean;
2321
}
@@ -28,33 +26,32 @@ export class SelectPSSARulesFeature implements IFeature {
2826
private languageClient: LanguageClient;
2927

3028
constructor() {
31-
this.command = vscode.commands.registerCommand('PowerShell.SelectPSSARules', () => {
29+
this.command = vscode.commands.registerCommand("PowerShell.SelectPSSARules", () => {
3230
if (this.languageClient === undefined) {
3331
// TODO: Log error message
3432
return;
3533
}
3634

37-
let options: Option[] = [];
3835
this.languageClient.sendRequest(GetPSSARulesRequest.type, null).then((returnedRules) => {
39-
let options: Option[] = returnedRules.map(function (rule): Option {
36+
let options: ICheckboxOption[] = returnedRules.map(function (rule: IRuleInfo): ICheckboxOption {
4037
return { name: rule.name, isSelected: rule.isEnabled };
4138
});
4239
(new CheckboxQuickPick(options)).show((updatedOptions) => {
4340
this.languageClient.sendRequest(
4441
SetPSSARulesRequest.type,
45-
updatedOptions.map(function (option): RuleInfo {
42+
updatedOptions.map(function (option: ICheckboxOption): IRuleInfo {
4643
return { name: option.name, isEnabled: option.isSelected };
4744
}));
4845
});
4946
});
5047
});
5148
}
5249

53-
public setLanguageClient(languageclient: LanguageClient) {
50+
public setLanguageClient(languageclient: LanguageClient): void {
5451
this.languageClient = languageclient;
5552
}
5653

57-
public dispose() {
54+
public dispose(): void {
5855
this.command.dispose();
5956
}
6057
}

0 commit comments

Comments
 (0)