public DiagnosticGetter( DiagnosticIncrementalAnalyzer owner, Solution solution, ProjectId projectId, DocumentId documentId, object id, bool includeSuppressedDiagnostics) { Owner = owner; CurrentSolution = solution; CurrentDocumentId = documentId; CurrentProjectId = projectId ?? documentId?.ProjectId; Id = id; IncludeSuppressedDiagnostics = includeSuppressedDiagnostics; // try to retrieve projectId/documentId from id if possible. if (id is LiveDiagnosticUpdateArgsId argsId) { CurrentDocumentId = CurrentDocumentId ?? argsId.Key as DocumentId; CurrentProjectId = CurrentProjectId ?? (argsId.Key as ProjectId) ?? CurrentDocumentId.ProjectId; } _builder = null; }
private async Task <DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> > GetCompilerAnalysisResultAsync(Stream stream, Dictionary <string, DiagnosticAnalyzer> analyzerMap, Project project, CancellationToken cancellationToken) { // handling of cancellation and exception var version = await DiagnosticIncrementalAnalyzer.GetDiagnosticVersionAsync(project, cancellationToken).ConfigureAwait(false); using (var reader = ObjectReader.TryGetReader(stream)) { Debug.Assert(reader != null, @"We only ge a reader for data transmitted between live processes. This data should always be correct as we're never persisting the data between sessions."); return(DiagnosticResultSerializer.Deserialize(reader, analyzerMap, project, version, cancellationToken)); } }
public static async Task <LatestDiagnosticsForSpanGetter> CreateAsync( DiagnosticIncrementalAnalyzer owner, Document document, TextSpan range, bool blockForData, bool includeSuppressedDiagnostics = false, string diagnosticIdOpt = null, CancellationToken cancellationToken = default) { // REVIEW: IsAnalyzerSuppressed can be quite expensive in some cases. try to find a way to make it cheaper // Here we don't filter out hidden diagnostic only analyzer since such analyzer can produce hidden diagnostic // on active file (non local diagnostic) var stateSets = owner._stateManager .GetOrCreateStateSets(document.Project).Where(s => !owner.Owner.IsAnalyzerSuppressed(s.Analyzer, document.Project)); // filter to specific diagnostic it is looking for if (diagnosticIdOpt != null) { stateSets = stateSets.Where(s => owner.Owner.GetDiagnosticDescriptors(s.Analyzer).Any(d => d.Id == diagnosticIdOpt)).ToList(); } var analyzerDriverOpt = await owner._compilationManager.CreateAnalyzerDriverAsync(document.Project, stateSets, includeSuppressedDiagnostics, cancellationToken).ConfigureAwait(false); return(new LatestDiagnosticsForSpanGetter(owner, analyzerDriverOpt, document, stateSets, diagnosticIdOpt, range, blockForData, includeSuppressedDiagnostics)); }
private LatestDiagnosticsForSpanGetter( DiagnosticIncrementalAnalyzer owner, CompilationWithAnalyzers analyzerDriverOpt, Document document, IEnumerable <StateSet> stateSets, string diagnosticId, TextSpan range, bool blockForData, bool includeSuppressedDiagnostics) { _owner = owner; _project = document.Project; _document = document; _stateSets = stateSets; _diagnosticId = diagnosticId; _analyzerDriverOpt = analyzerDriverOpt; _compilerAnalyzer = _owner.HostAnalyzerManager.GetCompilerDiagnosticAnalyzer(_document.Project.Language); _range = range; _blockForData = blockForData; _includeSuppressedDiagnostics = includeSuppressedDiagnostics; }
private async Task <DiagnosticAnalysisResultMap <DiagnosticAnalyzer, DiagnosticAnalysisResult> > AnalyzeInProcAsync( CompilationWithAnalyzers analyzerDriver, Project project, RemoteHostClient client, CancellationToken cancellationToken) { if (analyzerDriver == null || analyzerDriver.Analyzers.Length == 0) { // quick bail out return(DiagnosticAnalysisResultMap.Create(ImmutableDictionary <DiagnosticAnalyzer, DiagnosticAnalysisResult> .Empty, ImmutableDictionary <DiagnosticAnalyzer, AnalyzerTelemetryInfo> .Empty)); } var version = await DiagnosticIncrementalAnalyzer.GetDiagnosticVersionAsync(project, cancellationToken).ConfigureAwait(false); // PERF: Run all analyzers at once using the new GetAnalysisResultAsync API. var analysisResult = await analyzerDriver.GetAnalysisResultAsync(cancellationToken).ConfigureAwait(false); // if remote host is there, report performance data var asyncToken = _owner?.Listener.BeginAsyncOperation(nameof(AnalyzeInProcAsync)); var _ = FireAndForgetReportAnalyzerPerformanceAsync(project, client, analysisResult, cancellationToken).CompletesAsyncOperation(asyncToken); // get compiler result builder map var builderMap = analysisResult.ToResultBuilderMap(project, version, analyzerDriver.Compilation, analyzerDriver.Analyzers, cancellationToken); return(DiagnosticAnalysisResultMap.Create(builderMap.ToImmutableDictionary(kv => kv.Key, kv => DiagnosticAnalysisResult.CreateFromBuilder(kv.Value)), analysisResult.AnalyzerTelemetryInfo)); }
public IDELatestDiagnosticGetter(DiagnosticIncrementalAnalyzer owner, ImmutableHashSet <string> diagnosticIds, Solution solution, ProjectId projectId, DocumentId documentId, bool includeSuppressedDiagnostics) : base(owner, solution, projectId, documentId, id : null, includeSuppressedDiagnostics : includeSuppressedDiagnostics) { _diagnosticIds = diagnosticIds; }
public IDELatestDiagnosticGetter(DiagnosticIncrementalAnalyzer owner, Solution solution, object id, bool includeSuppressedDiagnostics) : base(owner, solution, projectId: null, documentId: null, id: id, includeSuppressedDiagnostics: includeSuppressedDiagnostics) { _diagnosticIds = null; }
public IDECachedDiagnosticGetter(DiagnosticIncrementalAnalyzer owner, Solution solution, ProjectId projectId, DocumentId documentId, bool includeSuppressedDiagnostics) : base(owner, solution, projectId, documentId, id: null, includeSuppressedDiagnostics: includeSuppressedDiagnostics) { }
public Executor(DiagnosticIncrementalAnalyzer owner) { _owner = owner; _diagnosticAnalyzerRunner = new InProcOrRemoteHostAnalyzerRunner(_owner.Owner, _owner.HostDiagnosticUpdateSource); }
public CompilationManager(DiagnosticIncrementalAnalyzer owner) { _owner = owner; _map = new ConditionalWeakTable <Project, CompilationWithAnalyzers>(); }