@@ -187,11 +187,13 @@ private async Task HandleSetPSSARulesRequest(
187
187
object param ,
188
188
RequestContext < object > requestContext )
189
189
{
190
- if ( editorSession . AnalysisService != null )
190
+ var dynParams = param as dynamic ;
191
+ if ( editorSession . AnalysisService != null &&
192
+ editorSession . AnalysisService . SettingsPath == null )
191
193
{
192
194
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 )
195
197
{
196
198
if ( ( Boolean ) ruleInfo . isEnabled )
197
199
{
@@ -201,17 +203,30 @@ private async Task HandleSetPSSARulesRequest(
201
203
editorSession . AnalysisService . ActiveRules = activeRules . ToArray ( ) ;
202
204
}
203
205
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);
205
219
}
206
220
207
221
private async Task HandleGetPSSARulesRequest (
208
222
object param ,
209
223
RequestContext < object > requestContext )
210
224
{
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 )
214
228
{
229
+ rules = new List < object > ( ) ;
215
230
var ruleNames = editorSession . AnalysisService . GetPSScriptAnalyzerRules ( ) ;
216
231
var activeRules = editorSession . AnalysisService . ActiveRules ;
217
232
foreach ( var ruleName in ruleNames )
@@ -1007,6 +1022,14 @@ private Task RunScriptDiagnostics(
1007
1022
ScriptFile [ ] filesToAnalyze ,
1008
1023
EditorSession editorSession ,
1009
1024
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 )
1010
1033
{
1011
1034
if ( ! this . currentSettings . ScriptAnalysis . Enable . Value )
1012
1035
{
@@ -1054,7 +1077,7 @@ private Task RunScriptDiagnostics(
1054
1077
filesToAnalyze ,
1055
1078
this . codeActionsPerFile ,
1056
1079
editorSession ,
1057
- eventContext ,
1080
+ eventSender ,
1058
1081
existingRequestCancellation . Token ) ,
1059
1082
CancellationToken . None ,
1060
1083
TaskCreationOptions . None ,
@@ -1063,13 +1086,32 @@ private Task RunScriptDiagnostics(
1063
1086
return Task . FromResult ( true ) ;
1064
1087
}
1065
1088
1089
+
1066
1090
private static async Task DelayThenInvokeDiagnostics (
1067
1091
int delayMilliseconds ,
1068
1092
ScriptFile [ ] filesToAnalyze ,
1069
1093
Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1070
1094
EditorSession editorSession ,
1071
1095
EventContext eventContext ,
1072
1096
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 )
1073
1115
{
1074
1116
// First of all, wait for the desired delay period before
1075
1117
// analyzing the provided list of files
@@ -1115,7 +1157,7 @@ await PublishScriptDiagnostics(
1115
1157
scriptFile ,
1116
1158
semanticMarkers ,
1117
1159
correctionIndex ,
1118
- eventContext ) ;
1160
+ eventSender ) ;
1119
1161
}
1120
1162
}
1121
1163
@@ -1124,6 +1166,19 @@ private static async Task PublishScriptDiagnostics(
1124
1166
ScriptFileMarker [ ] semanticMarkers ,
1125
1167
Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1126
1168
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 )
1127
1182
{
1128
1183
List < Diagnostic > diagnostics = new List < Diagnostic > ( ) ;
1129
1184
@@ -1147,7 +1202,7 @@ private static async Task PublishScriptDiagnostics(
1147
1202
1148
1203
// Always send syntax and semantic errors. We want to
1149
1204
// make sure no out-of-date markers are being displayed.
1150
- await eventContext . SendEvent (
1205
+ await eventSender (
1151
1206
PublishDiagnosticsNotification . Type ,
1152
1207
new PublishDiagnosticsNotification
1153
1208
{
0 commit comments