Skip to content

Make AnalysisService use the latest version of PSScriptAnalyzer #677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ protected async Task HandleDidChangeConfigurationNotification(
bool oldScriptAnalysisEnabled =
this.currentSettings.ScriptAnalysis.Enable.HasValue ? this.currentSettings.ScriptAnalysis.Enable.Value : false;
string oldScriptAnalysisSettingsPath =
this.currentSettings.ScriptAnalysis.SettingsPath;
this.currentSettings.ScriptAnalysis?.SettingsPath;

this.currentSettings.Update(
configChangeParams.Settings.Powershell,
Expand Down Expand Up @@ -604,12 +604,15 @@ protected async Task HandleDidChangeConfigurationNotification(
string newSettingsPath = this.currentSettings.ScriptAnalysis.SettingsPath;
if (!string.Equals(oldScriptAnalysisSettingsPath, newSettingsPath, StringComparison.OrdinalIgnoreCase))
{
this.editorSession.AnalysisService.SettingsPath = newSettingsPath;
settingsPathChanged = true;
if (this.editorSession.AnalysisService != null)
{
this.editorSession.AnalysisService.SettingsPath = newSettingsPath;
settingsPathChanged = true;
}
}

// If script analysis settings have changed we need to clear & possibly update the current diagnostic records.
if ((oldScriptAnalysisEnabled != this.currentSettings.ScriptAnalysis.Enable) || settingsPathChanged)
if ((oldScriptAnalysisEnabled != this.currentSettings.ScriptAnalysis?.Enable) || settingsPathChanged)
{
// If the user just turned off script analysis or changed the settings path, send a diagnostics
// event to clear the analysis markers that they already have.
Expand Down Expand Up @@ -1443,7 +1446,7 @@ private Task RunScriptDiagnostics(
DelayThenInvokeDiagnostics(
750,
filesToAnalyze,
this.currentSettings.ScriptAnalysis.Enable.Value,
this.currentSettings.ScriptAnalysis?.Enable.Value ?? false,
this.codeActionsPerFile,
editorSession,
eventSender,
Expand Down
Loading