@@ -15,11 +15,16 @@ export namespace SetPSSARulesRequest {
15
15
export const type : RequestType < any , any , void > = { get method ( ) : string { return "powerShell/setPSSARules" ; } } ;
16
16
}
17
17
18
- interface IRuleInfo {
18
+ class RuleInfo {
19
19
name : string ;
20
20
isEnabled : boolean ;
21
21
}
22
22
23
+ class SetPSSARulesRequestParams {
24
+ filepath : string ;
25
+ ruleInfos : RuleInfo [ ] ;
26
+ }
27
+
23
28
export class SelectPSSARulesFeature implements IFeature {
24
29
25
30
private command : vscode . Disposable ;
@@ -28,7 +33,6 @@ export class SelectPSSARulesFeature implements IFeature {
28
33
constructor ( ) {
29
34
this . command = vscode . commands . registerCommand ( "PowerShell.SelectPSSARules" , ( ) => {
30
35
if ( this . languageClient === undefined ) {
31
- // TODO: Log error message
32
36
return ;
33
37
}
34
38
@@ -38,15 +42,17 @@ export class SelectPSSARulesFeature implements IFeature {
38
42
"PowerShell extension uses PSScriptAnalyzer settings file - Cannot update rules." ) ;
39
43
return ;
40
44
}
41
- let options : CheckboxQuickPickItem [ ] = returnedRules . map ( function ( rule : IRuleInfo ) : CheckboxQuickPickItem {
45
+ let options : CheckboxQuickPickItem [ ] = returnedRules . map ( function ( rule : RuleInfo ) : CheckboxQuickPickItem {
42
46
return { name : rule . name , isSelected : rule . isEnabled } ;
43
47
} ) ;
44
48
CheckboxQuickPick . show ( options , ( updatedOptions ) => {
45
- this . languageClient . sendRequest (
46
- SetPSSARulesRequest . type ,
47
- updatedOptions . map ( function ( option : CheckboxQuickPickItem ) : IRuleInfo {
49
+ let filepath : string = vscode . window . activeTextEditor . document . uri . fsPath ;
50
+ let ruleInfos : RuleInfo [ ] = updatedOptions . map (
51
+ function ( option : CheckboxQuickPickItem ) : RuleInfo {
48
52
return { name : option . name , isEnabled : option . isSelected } ;
49
- } ) ) ;
53
+ } ) ;
54
+ let requestParams : SetPSSARulesRequestParams = { filepath, ruleInfos} ;
55
+ this . languageClient . sendRequest ( SetPSSARulesRequest . type , requestParams ) ;
50
56
} ) ;
51
57
} ) ;
52
58
} ) ;
0 commit comments