public async Task <MSBuildDiagnosticSeverity> GetFixSeverity(
            ITextBuffer buffer, MSBuildParseResult result, SnapshotSpan range,
            MSBuildDiagnosticSeverity severities, CancellationToken cancellationToken)
        {
            var filteredDiags = result.Diagnostics.Where(d => range.IntersectsWith(new SnapshotSpan(range.Snapshot, d.Span.Start, d.Span.Length)));

            var severity = MSBuildDiagnosticSeverity.None;

            void ReportFix(MSBuildAction a, ImmutableArray <MSBuildDiagnostic> diags)
            {
                foreach (var d in diags)
                {
                    severity |= d.Descriptor.Severity;
                }
            };

            //TODO invoke the provider once for all the diagnostics it supports
            foreach (var diagnostic in filteredDiags)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return(severity);
                }
                if (range.IntersectsWith(new SnapshotSpan(range.Snapshot, diagnostic.Span.Start, diagnostic.Span.Length)))
                {
                    if (diagnosticIdToFixProviderMap.TryGetValue(diagnostic.Descriptor.Id, out var fixProvider))
                    {
                        var ctx = new MSBuildFixContext(
                            buffer,
                            result.MSBuildDocument,
                            result.MSBuildDocument.XDocument,
                            new Xml.Dom.TextSpan(range.Start, range.Length),
                            ImmutableArray.Create(diagnostic),
                            ReportFix, cancellationToken);
                        await fixProvider.RegisterCodeFixesAsync(ctx);

                        //callers only really care about the highest severity, so if we got error, we can early out
                        if ((severity | MSBuildDiagnosticSeverity.Error) != 0)
                        {
                            return(severity);
                        }
                    }
                }
            }

            return(severity);
        }
        /// <remarks>
        /// FIXME: The buffer parameter is workaround for the spellchecker. It can be removed when
        /// there is a better concept of a durable context/scope to which information can be bound.
        /// </remarks>
        public async Task <List <MSBuildCodeFix> > GetFixes(
            ITextBuffer buffer, MSBuildParseResult result, SnapshotSpan range,
            MSBuildDiagnosticSeverity requestedSeverities, CancellationToken cancellationToken)
        {
            var filteredDiags = ImmutableArray.CreateRange(
                result.Diagnostics.Where(d => range.IntersectsWith(new SnapshotSpan(range.Snapshot, d.Span.Start, d.Span.Length))));

            var fixes = new List <MSBuildCodeFix> ();

            void ReportFix(MSBuildAction a, ImmutableArray <MSBuildDiagnostic> d)
            {
                lock (fixes) {
                    fixes.Add(new MSBuildCodeFix(a, d));
                }
            }

            //TODO invoke the provider once for all the diagnostics it supports
            foreach (var diagnostic in filteredDiags)
            {
                if ((diagnostic.Descriptor.Severity | requestedSeverities) == 0)
                {
                    continue;
                }
                if (cancellationToken.IsCancellationRequested)
                {
                    return(null);
                }
                if (range.IntersectsWith(new SnapshotSpan(range.Snapshot, diagnostic.Span.Start, diagnostic.Span.Length)))
                {
                    if (diagnosticIdToFixProviderMap.TryGetValue(diagnostic.Descriptor.Id, out var fixProvider))
                    {
                        var ctx = new MSBuildFixContext(
                            buffer,
                            result.MSBuildDocument,
                            result.MSBuildDocument.XDocument,
                            new Xml.Dom.TextSpan(range.Start, range.Length),
                            ImmutableArray.Create(diagnostic),
                            ReportFix, cancellationToken);
                        await fixProvider.RegisterCodeFixesAsync(ctx);
                    }
                }
            }

            return(fixes);
        }
 public abstract Task RegisterCodeFixesAsync(MSBuildFixContext context);