Skip to content

Commit

Permalink
Use common helper for diagnostics (#77109)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Feb 7, 2025
2 parents 1061ea0 + 9e30885 commit 5ce4040
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ internal partial class DiagnosticAnalyzerService
private partial class DiagnosticIncrementalAnalyzer
{
private static Task<CompilationWithAnalyzersPair?> CreateCompilationWithAnalyzersAsync(Project project, ImmutableArray<StateSet> stateSets, bool crashOnAnalyzerException, CancellationToken cancellationToken)
=> DocumentAnalysisExecutor.CreateCompilationWithAnalyzersAsync(project, stateSets.SelectAsArray(s => !s.IsHostAnalyzer, s => s.Analyzer), stateSets.SelectAsArray(s => s.IsHostAnalyzer, s => s.Analyzer), crashOnAnalyzerException, cancellationToken);
=> DocumentAnalysisExecutor.CreateCompilationWithAnalyzersAsync(
project,
stateSets.SelectAsArray(s => !s.IsHostAnalyzer, s => s.Analyzer),
stateSets.SelectAsArray(s => s.IsHostAnalyzer, s => s.Analyzer),
crashOnAnalyzerException,
cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ public async Task<ImmutableArray<DiagnosticData>> ForceAnalyzeProjectAsync(Proje
var stateSetsForProject = await _stateManager.GetOrCreateStateSetsAsync(project, cancellationToken).ConfigureAwait(false);
var stateSets = GetStateSetsForFullSolutionAnalysis(stateSetsForProject, project);

// PERF: get analyzers that are not suppressed and marked as open file only
// this is perf optimization. we cache these result since we know the result. (no diagnostics)
var activeProjectAnalyzers = stateSets.SelectAsArray(s => !s.IsHostAnalyzer, s => s.Analyzer);
var activeHostAnalyzers = stateSets.SelectAsArray(s => s.IsHostAnalyzer, s => s.Analyzer);

var compilationWithAnalyzers = await DocumentAnalysisExecutor.CreateCompilationWithAnalyzersAsync(
project, activeProjectAnalyzers, activeHostAnalyzers, AnalyzerService.CrashOnAnalyzerException, cancellationToken).ConfigureAwait(false);
var compilationWithAnalyzers = await CreateCompilationWithAnalyzersAsync(
project, stateSets, AnalyzerService.CrashOnAnalyzerException, cancellationToken).ConfigureAwait(false);

var result = await GetProjectAnalysisDataAsync(compilationWithAnalyzers, project, stateSets, cancellationToken).ConfigureAwait(false);

Expand Down

0 comments on commit 5ce4040

Please sign in to comment.