private async Task <ImmutableArray <DocumentDiagnostics> > GetCorrectDiagnosticsInScope(FixAllScope scope, string fileName)
        {
            switch (scope)
            {
            case FixAllScope.Solution:
                var documentsInSolution = Workspace.CurrentSolution.Projects.SelectMany(x => x.Documents).Select(x => x.FilePath).ToImmutableArray();
                return(await diagnostics.GetDiagnostics(documentsInSolution));

            case FixAllScope.Project:
                var documentsInProject = Workspace.GetDocument(fileName).Project.Documents.Select(x => x.FilePath).ToImmutableArray();
                return(await diagnostics.GetDiagnostics(documentsInProject));

            case FixAllScope.Document:
                return(await diagnostics.GetDiagnostics(ImmutableArray.Create(fileName)));

            default:
                throw new NotImplementedException();
            }
        }
        protected async Task <(DocumentId DocumentId, Diagnostic Diagnostic)> GetDocumentIdAndDiagnosticForGivenId(FixAllScope scope, Document document, string diagnosticId)
        {
            var allDocumentDiagnostics = await GetDiagnosticsAsync(scope, document);

            foreach (var documentAndDiagnostics in allDocumentDiagnostics)
            {
                if (documentAndDiagnostics.Diagnostics.FirstOrDefault(d => d.Id == diagnosticId) is Diagnostic diagnostic)
                {
                    return(documentAndDiagnostics.Document.Id, diagnostic);
                }
            }

            return(default);
        // Mapping means: each mapped item has one document that has one code fix provider and it's corresponding diagnostics.
        // If same document has multiple codefixers (diagnostics with different fixers) will them be mapped as separate items.
        protected async Task <ImmutableArray <DocumentWithFixProvidersAndMatchingDiagnostics> > GetDiagnosticsMappedWithFixAllProviders(FixAllScope scope, string fileName)
        {
            ImmutableArray <DocumentDiagnostics> allDiagnostics = await GetCorrectDiagnosticsInScope(scope, fileName);

            var mappedProvidersWithDiagnostics = allDiagnostics
                                                 .SelectMany(diagnosticsInDocument =>
                                                             DocumentWithFixProvidersAndMatchingDiagnostics.CreateWithMatchingProviders(codeFixesForProject.GetAllCodeFixesForProject(diagnosticsInDocument.ProjectId), diagnosticsInDocument));

            return(mappedProvidersWithDiagnostics.ToImmutableArray());
        }