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
1111 {
1212 public static readonly
1313 RequestType < string , object > Type =
14- RequestType < string , object > . Create ( "powerShell/GetPSSARules " ) ;
14+ RequestType < string , object > . Create ( "powerShell/getPSSARules " ) ;
1515 }
1616}
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 6161 <Compile Include =" LanguageServer\FindModuleRequest.cs" />
6262 <Compile Include =" LanguageServer\InstallModuleRequest.cs" />
6363 <Compile Include =" LanguageServer\PowerShellVersionRequest.cs" />
64+ <Compile Include =" LanguageServer\SetPSSARulesRequest.cs" />
6465 <Compile Include =" MessageProtocol\Channel\NamedPipeClientChannel.cs" />
6566 <Compile Include =" MessageProtocol\Channel\NamedPipeServerChannel.cs" />
6667 <Compile Include =" MessageProtocol\Channel\TcpSocketClientChannel.cs" />
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ protected override void Initialize()
110110 this . SetRequestHandler ( DebugAdapterMessages . EvaluateRequest . Type , this . HandleEvaluateRequest ) ;
111111
112112 this . SetRequestHandler ( GetPSSARulesRequest . Type , this . HandleGetPSSARulesRequest ) ;
113+ this . SetRequestHandler ( SetPSSARulesRequest . Type , this . HandleSetPSSARulesRequest ) ;
113114
114115 // Initialize the extension service
115116 // TODO: This should be made awaited once Initialize is async!
@@ -182,6 +183,28 @@ protected async Task HandleShowOnlineHelpRequest(
182183 await requestContext . SendResult ( null ) ;
183184 }
184185
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+
185208 private async Task HandleGetPSSARulesRequest (
186209 object param ,
187210 RequestContext < object > requestContext )
Original file line number Diff line number Diff line change @@ -55,7 +55,14 @@ public class AnalysisService : IDisposable
5555
5656 public string [ ] ActiveRules
5757 {
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+ }
5966 }
6067
6168 /// <summary>
You can’t perform that action at this time.
0 commit comments