private void UpdateImplementation(OmniSharpOptions options)
        {
            var firstRun = _implementation is null;

            if (options.RoslynExtensionsOptions.EnableAnalyzersSupport && (firstRun || _implementation is CSharpDiagnosticWorker))
            {
                var old = Interlocked.Exchange(ref _implementation, new CSharpDiagnosticWorkerWithAnalyzers(_workspace, _providers, _loggerFactory, _forwarder, options));
                if (old is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }
            else if (!options.RoslynExtensionsOptions.EnableAnalyzersSupport && (firstRun || _implementation is CSharpDiagnosticWorkerWithAnalyzers))
            {
                var old = Interlocked.Exchange(ref _implementation, new CSharpDiagnosticWorker(_workspace, _forwarder, _loggerFactory));
                if (old is IDisposable disposable)
                {
                    disposable.Dispose();
                }

                if (!firstRun)
                {
                    _implementation.QueueDocumentsForDiagnostics();
                }
            }
        }
Exemple #2
0
        public Task <DiagnosticsResponse> Handle(DiagnosticsRequest request)
        {
            if (!_forwarder.IsEnabled)
            {
                _forwarder.IsEnabled = true;
            }

            _diagWorker.QueueDocumentsForDiagnostics();

            return(Task.FromResult(new DiagnosticsResponse()));
        }
        public Task <ReanalyzeResponse> Handle(ReAnalyzeRequest request)
        {
            if (!string.IsNullOrEmpty(request.FileName))
            {
                var currentSolution = _workspace.CurrentSolution;

                var projectIds = WhenRequestIsProjectFileItselfGetFilesFromIt(request.FileName, currentSolution)
                                 ?? GetProjectIdsFromDocumentFilePaths(request.FileName, currentSolution);

                _logger.LogInformation($"Queue analysis for project(s) {string.Join(", ", projectIds)}");

                _diagWorker.QueueDocumentsForDiagnostics(projectIds);
            }
            else
            {
                _logger.LogInformation($"Queue analysis for all projects.");
                _diagWorker.QueueDocumentsForDiagnostics();
            }

            return(Task.FromResult(new ReanalyzeResponse()));
        }
 public ImmutableArray <DocumentId> QueueDocumentsForDiagnostics()
 {
     return(_implementation.QueueDocumentsForDiagnostics());
 }