public static DiagnosticsInDoc Create(DocumentId documentId, IList <Diagnostic> diagnostics, SyntaxNode root) { var nodes = diagnostics.Select(d => root.FindNode(d.Location.SourceSpan)).Where(n => !n.IsMissing).ToList(); var diagnosticsInDoc = new DiagnosticsInDoc { DocumentId = documentId, TrackedRoot = root.TrackNodes(nodes), Nodes = nodes }; return(diagnosticsInDoc); }
private static async Task <DiagnosticsInDoc> GetDiagnosticsInDocAsync(FixAllContext fixAllContext, Document document) { var diagnostics = await fixAllContext.GetDocumentDiagnosticsAsync(document).ConfigureAwait(false); if (!diagnostics.Any()) { return(DiagnosticsInDoc.Empty); } var root = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); var doc = DiagnosticsInDoc.Create(document.Id, diagnostics, root); return(doc); }
public static DiagnosticsInDoc Create(DocumentId documentId, IList<Diagnostic> diagnostics, SyntaxNode root) { var nodes = diagnostics.Select(d => root.FindNode(d.Location.SourceSpan)).Where(n => !n.IsMissing).ToList(); var diagnosticsInDoc = new DiagnosticsInDoc { DocumentId = documentId, TrackedRoot = root.TrackNodes(nodes), Nodes = nodes }; return diagnosticsInDoc; }