private void RefreshWorkflow(BindingConfiguration configuration) { // There might be some race condition here if an analysis is triggered while the delegates are reset and set back // to the new workflow behavior. This race condition would lead to some issues being reported using the old mode // instead of the new one but everything will be fixed on the next analysis. ResetState(); switch (configuration?.Mode) { case SonarLintMode.Standalone: this.logger.WriteLine(Resources.Strings.AnalyzerManager_InStandaloneMode); this.currentWorklow = new SonarAnalyzerStandaloneWorkflow(this.workspace); break; case SonarLintMode.LegacyConnected: case SonarLintMode.Connected: this.logger.WriteLine(Resources.Strings.AnalyzerManager_InConnectedMode); var sonarQubeIssueProvider = new SonarQubeIssuesProvider(sonarQubeService, configuration.Project.ProjectKey, new TimerFactory(), this.logger); this.disposableObjects.Add(sonarQubeIssueProvider); var liveIssueFactory = new LiveIssueFactory(workspace, vsSolution); var suppressionHandler = new SuppressionHandler(liveIssueFactory, sonarQubeIssueProvider); if (configuration.Mode == SonarLintMode.Connected) { this.currentWorklow = new SonarAnalyzerConnectedWorkflow(this.workspace, suppressionHandler); } else // Legacy { this.currentWorklow = new SonarAnalyzerLegacyConnectedWorkflow(this.workspace, suppressionHandler, this.logger); } break; } }
private void ResetState() { this.currentWorklow?.Dispose(); this.currentWorklow = null; SonarAnalysisContext.ShouldDiagnosticBeReported = this.previousShouldDiagnosticBeReported; SonarAnalysisContext.ShouldExecuteRegisteredAction = this.previousShouldExecuteRegisteredAction; SonarAnalysisContext.ReportDiagnostic = this.previousReportDiagnostic; }
private void ResetState() { this.disposableObjects.ForEach(x => x.Dispose()); this.disposableObjects.Clear(); this.currentWorklow?.Dispose(); this.currentWorklow = null; SonarAnalysisContext.ShouldRegisterContextAction = this.previousShouldRegisterContextAction; SonarAnalysisContext.ShouldDiagnosticBeReported = this.previousShouldDiagnosticBeReported; SonarAnalysisContext.ShouldExecuteRegisteredAction = this.previousShouldExecuteRegisteredAction; SonarAnalysisContext.ReportDiagnostic = this.previousReportDiagnostic; }