@@ -187,11 +187,13 @@ private async Task HandleSetPSSARulesRequest(
187187 object param ,
188188 RequestContext < object > requestContext )
189189 {
190- if ( editorSession . AnalysisService != null )
190+ var dynParams = param as dynamic ;
191+ if ( editorSession . AnalysisService != null &&
192+ editorSession . AnalysisService . SettingsPath == null )
191193 {
192194 var activeRules = new List < string > ( ) ;
193- var dynParam = param as dynamic ;
194- foreach ( dynamic ruleInfo in dynParam )
195+ var ruleInfos = dynParams . ruleInfos ;
196+ foreach ( dynamic ruleInfo in ruleInfos )
195197 {
196198 if ( ( Boolean ) ruleInfo . isEnabled )
197199 {
@@ -201,17 +203,30 @@ private async Task HandleSetPSSARulesRequest(
201203 editorSession . AnalysisService . ActiveRules = activeRules . ToArray ( ) ;
202204 }
203205
204- await requestContext . SendResult ( null ) ;
206+ var sendresult = requestContext . SendResult ( null ) ;
207+ // send the file uri from the client
208+ // retrieve the file
209+ // requestcontext is the eventcontext
210+ var scripFile = editorSession . Workspace . GetFile ( ( string ) dynParams . filepath ) ;
211+ await RunScriptDiagnostics (
212+ new ScriptFile [ ] { scripFile } ,
213+ editorSession ,
214+ requestContext . SendEvent ) ;
215+
216+ await sendresult ;
217+
218+ //await requestContext.SendResult(null);
205219 }
206220
207221 private async Task HandleGetPSSARulesRequest (
208222 object param ,
209223 RequestContext < object > requestContext )
210224 {
211- List < string > ruleList = new List < string > ( ) ;
212- List < object > rules = new List < object > ( ) ;
213- if ( editorSession . AnalysisService ! = null )
225+ List < object > rules = null ;
226+ if ( editorSession . AnalysisService != null
227+ && editorSession . AnalysisService . SettingsPath = = null )
214228 {
229+ rules = new List < object > ( ) ;
215230 var ruleNames = editorSession . AnalysisService . GetPSScriptAnalyzerRules ( ) ;
216231 var activeRules = editorSession . AnalysisService . ActiveRules ;
217232 foreach ( var ruleName in ruleNames )
@@ -1007,6 +1022,14 @@ private Task RunScriptDiagnostics(
10071022 ScriptFile [ ] filesToAnalyze ,
10081023 EditorSession editorSession ,
10091024 EventContext eventContext )
1025+ {
1026+ return RunScriptDiagnostics ( filesToAnalyze , editorSession , eventContext . SendEvent ) ;
1027+ }
1028+
1029+ private Task RunScriptDiagnostics (
1030+ ScriptFile [ ] filesToAnalyze ,
1031+ EditorSession editorSession ,
1032+ Func < EventType < PublishDiagnosticsNotification > , PublishDiagnosticsNotification , Task > eventSender )
10101033 {
10111034 if ( ! this . currentSettings . ScriptAnalysis . Enable . Value )
10121035 {
@@ -1054,7 +1077,7 @@ private Task RunScriptDiagnostics(
10541077 filesToAnalyze ,
10551078 this . codeActionsPerFile ,
10561079 editorSession ,
1057- eventContext ,
1080+ eventSender ,
10581081 existingRequestCancellation . Token ) ,
10591082 CancellationToken . None ,
10601083 TaskCreationOptions . None ,
@@ -1063,13 +1086,32 @@ private Task RunScriptDiagnostics(
10631086 return Task . FromResult ( true ) ;
10641087 }
10651088
1089+
10661090 private static async Task DelayThenInvokeDiagnostics (
10671091 int delayMilliseconds ,
10681092 ScriptFile [ ] filesToAnalyze ,
10691093 Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
10701094 EditorSession editorSession ,
10711095 EventContext eventContext ,
10721096 CancellationToken cancellationToken )
1097+ {
1098+ await DelayThenInvokeDiagnostics (
1099+ delayMilliseconds ,
1100+ filesToAnalyze ,
1101+ correctionIndex ,
1102+ editorSession ,
1103+ eventContext . SendEvent ,
1104+ cancellationToken ) ;
1105+ }
1106+
1107+
1108+ private static async Task DelayThenInvokeDiagnostics (
1109+ int delayMilliseconds ,
1110+ ScriptFile [ ] filesToAnalyze ,
1111+ Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1112+ EditorSession editorSession ,
1113+ Func < EventType < PublishDiagnosticsNotification > , PublishDiagnosticsNotification , Task > eventSender ,
1114+ CancellationToken cancellationToken )
10731115 {
10741116 // First of all, wait for the desired delay period before
10751117 // analyzing the provided list of files
@@ -1115,7 +1157,7 @@ await PublishScriptDiagnostics(
11151157 scriptFile ,
11161158 semanticMarkers ,
11171159 correctionIndex ,
1118- eventContext ) ;
1160+ eventSender ) ;
11191161 }
11201162 }
11211163
@@ -1124,6 +1166,19 @@ private static async Task PublishScriptDiagnostics(
11241166 ScriptFileMarker [ ] semanticMarkers ,
11251167 Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
11261168 EventContext eventContext )
1169+ {
1170+ await PublishScriptDiagnostics (
1171+ scriptFile ,
1172+ semanticMarkers ,
1173+ correctionIndex ,
1174+ eventContext . SendEvent ) ;
1175+ }
1176+
1177+ private static async Task PublishScriptDiagnostics (
1178+ ScriptFile scriptFile ,
1179+ ScriptFileMarker [ ] semanticMarkers ,
1180+ Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1181+ Func < EventType < PublishDiagnosticsNotification > , PublishDiagnosticsNotification , Task > eventSender )
11271182 {
11281183 List < Diagnostic > diagnostics = new List < Diagnostic > ( ) ;
11291184
@@ -1147,7 +1202,7 @@ private static async Task PublishScriptDiagnostics(
11471202
11481203 // Always send syntax and semantic errors. We want to
11491204 // make sure no out-of-date markers are being displayed.
1150- await eventContext . SendEvent (
1205+ await eventSender (
11511206 PublishDiagnosticsNotification . Type ,
11521207 new PublishDiagnosticsNotification
11531208 {
0 commit comments