public void Reanalyze( IIncrementalAnalyzer analyzer, ReanalyzeScope scope, bool highPriority = false ) { _eventProcessingQueue.ScheduleTask( "Reanalyze", () => EnqueueWorkItemAsync(analyzer, scope, highPriority), _shutdownToken ); if (scope.HasMultipleDocuments) { // log big reanalysis request from things like fix all, suppress all or option changes // we are not interested in 1 file re-analysis request which can happen from like venus typing var solution = _registration.CurrentSolution; SolutionCrawlerLogger.LogReanalyze( CorrelationId, analyzer, scope.GetDocumentCount(solution), scope.GetLanguagesStringForTelemetry(solution), highPriority ); } }
private void ReanalyzeOnOptionChange(object?sender, OptionChangedEventArgs e) { // get off from option changed event handler since it runs on UI thread // getting analyzer can be slow for the very first time since it is lazily initialized _eventProcessingQueue.ScheduleTask( nameof(ReanalyzeOnOptionChange), () => { // Force analyze all analyzers if background analysis scope has changed. var forceAnalyze = e.Option == SolutionCrawlerOptions.BackgroundAnalysisScopeOption; // let each analyzer decide what they want on option change foreach (var analyzer in _documentAndProjectWorkerProcessor.Analyzers) { if (forceAnalyze || analyzer.NeedsReanalysisOnOptionChanged(sender, e)) { var scope = new ReanalyzeScope(_registration.CurrentSolution.Id); Reanalyze(analyzer, scope); } } }, _shutdownToken ); }
public void AddAnalyzer(IIncrementalAnalyzer analyzer, bool highPriorityForActiveFile) { // add analyzer _documentAndProjectWorkerProcessor.AddAnalyzer(analyzer, highPriorityForActiveFile); // and ask to re-analyze whole solution for the given analyzer var scope = new ReanalyzeScope(_registration.CurrentSolution.Id); Reanalyze(analyzer, scope); }
private async Task EnqueueWorkItemAsync(IIncrementalAnalyzer analyzer, ReanalyzeScope scope, bool highPriority) { var solution = _registration.CurrentSolution; var invocationReasons = highPriority ? InvocationReasons.ReanalyzeHighPriority : InvocationReasons.Reanalyze; foreach (var document in scope.GetDocuments(solution)) { await EnqueueWorkItemAsync(analyzer, document, invocationReasons).ConfigureAwait(false); } }
private async Task EnqueueWorkItemAsync(IIncrementalAnalyzer analyzer, ReanalyzeScope scope, bool highPriority) { var solution = _registration.GetSolutionToAnalyze(); var invocationReasons = highPriority ? InvocationReasons.ReanalyzeHighPriority : InvocationReasons.Reanalyze; foreach (var(project, documentId) in scope.GetDocumentIds(solution)) { await EnqueueWorkItemAsync(analyzer, project, documentId, document : null, invocationReasons).ConfigureAwait(false); } }
private void ReanalyzeOnOptionChange(object sender, OptionChangedEventArgs e) { // let each analyzer decide what they want on option change foreach (var analyzer in _documentAndProjectWorkerProcessor.Analyzers) { if (analyzer.NeedsReanalysisOnOptionChanged(sender, e)) { var scope = new ReanalyzeScope(_registration.CurrentSolution.Id); Reanalyze(analyzer, scope); } } }
private void ReanalyzeOnOptionChange(object?sender, OptionChangedEventArgs e) { // get off from option changed event handler since it runs on UI thread // getting analyzer can be slow for the very first time since it is lazily initialized _eventProcessingQueue.ScheduleTask(nameof(ReanalyzeOnOptionChange), () => { // let each analyzer decide what they want on option change foreach (var analyzer in _documentAndProjectWorkerProcessor.Analyzers) { if (analyzer.NeedsReanalysisOnOptionChanged(sender, e)) { var scope = new ReanalyzeScope(_registration.GetSolutionToAnalyze().Id); Reanalyze(analyzer, scope); } } }, _shutdownToken); }
private void ReanalyzeOnOptionChange(object sender, OptionChangedEventArgs e) { // get off from option changed event handler since it runs on UI thread // getting analyzer can be slow for the very first time since it is lazily initialized var asyncToken = _listener.BeginAsyncOperation("ReanalyzeOnOptionChange"); _eventProcessingQueue.ScheduleTask(() => { // let each analyzer decide what they want on option change foreach (var analyzer in _documentAndProjectWorkerProcessor.Analyzers) { if (analyzer.NeedsReanalysisOnOptionChanged(sender, e)) { var scope = new ReanalyzeScope(_registration.CurrentSolution.Id); Reanalyze(analyzer, scope); } } }, _shutdownToken).CompletesAsyncOperation(asyncToken); }