File tree Expand file tree Collapse file tree 5 files changed +49
-2
lines changed
PowerShellEditorServices.Protocol
PowerShellEditorServices/Analysis Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,6 @@ class GetPSSARulesRequest
11
11
{
12
12
public static readonly
13
13
RequestType < string , object > Type =
14
- RequestType < string , object > . Create ( "powerShell/GetPSSARules " ) ;
14
+ RequestType < string , object > . Create ( "powerShell/getPSSARules " ) ;
15
15
}
16
16
}
Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ using Microsoft . PowerShell . EditorServices . Protocol . MessageProtocol ;
7
+
8
+ namespace Microsoft . PowerShell . EditorServices . Protocol . LanguageServer
9
+ {
10
+ class SetPSSARulesRequest
11
+ {
12
+ public static readonly
13
+ RequestType < object , object > Type =
14
+ RequestType < object , object > . Create ( "powerShell/setPSSARules" ) ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change 61
61
<Compile Include =" LanguageServer\FindModuleRequest.cs" />
62
62
<Compile Include =" LanguageServer\InstallModuleRequest.cs" />
63
63
<Compile Include =" LanguageServer\PowerShellVersionRequest.cs" />
64
+ <Compile Include =" LanguageServer\SetPSSARulesRequest.cs" />
64
65
<Compile Include =" MessageProtocol\Channel\NamedPipeClientChannel.cs" />
65
66
<Compile Include =" MessageProtocol\Channel\NamedPipeServerChannel.cs" />
66
67
<Compile Include =" MessageProtocol\Channel\TcpSocketClientChannel.cs" />
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ protected override void Initialize()
110
110
this . SetRequestHandler ( DebugAdapterMessages . EvaluateRequest . Type , this . HandleEvaluateRequest ) ;
111
111
112
112
this . SetRequestHandler ( GetPSSARulesRequest . Type , this . HandleGetPSSARulesRequest ) ;
113
+ this . SetRequestHandler ( SetPSSARulesRequest . Type , this . HandleSetPSSARulesRequest ) ;
113
114
114
115
// Initialize the extension service
115
116
// TODO: This should be made awaited once Initialize is async!
@@ -182,6 +183,28 @@ protected async Task HandleShowOnlineHelpRequest(
182
183
await requestContext . SendResult ( null ) ;
183
184
}
184
185
186
+ private async Task HandleSetPSSARulesRequest (
187
+ object param ,
188
+ RequestContext < object > requestContext )
189
+ {
190
+ if ( editorSession . AnalysisService != null )
191
+ {
192
+ var activeRules = new List < string > ( ) ;
193
+ var dynParam = param as dynamic ;
194
+ foreach ( dynamic ruleInfo in dynParam )
195
+ {
196
+
197
+ if ( ( Boolean ) ruleInfo . IsEnabled )
198
+ {
199
+ activeRules . Add ( ( string ) ruleInfo . Name ) ;
200
+ }
201
+ }
202
+ editorSession . AnalysisService . ActiveRules = activeRules . ToArray ( ) ;
203
+ }
204
+
205
+ await requestContext . SendResult ( null ) ;
206
+ }
207
+
185
208
private async Task HandleGetPSSARulesRequest (
186
209
object param ,
187
210
RequestContext < object > requestContext )
Original file line number Diff line number Diff line change @@ -55,7 +55,14 @@ public class AnalysisService : IDisposable
55
55
56
56
public string [ ] ActiveRules
57
57
{
58
- get { return activeRules != null ? activeRules . ToArray ( ) : null ; }
58
+ get
59
+ {
60
+ return activeRules != null ? activeRules . ToArray ( ) : null ;
61
+ }
62
+ set
63
+ {
64
+ activeRules = new List < string > ( value ) ; // TODO check the argument
65
+ }
59
66
}
60
67
61
68
/// <summary>
You can’t perform that action at this time.
0 commit comments