private async Task<ProjectToDocumentMap> CreateProjectToDocumentMapAsync(ProjectMap projectMap) { using (Logger.LogBlock(FunctionId.FindReference_CreateDocumentMapAsync, _cancellationToken)) { var finalMap = new ProjectToDocumentMap(); foreach (var kvp in projectMap) { var project = kvp.Key; var projectQueue = kvp.Value; var documentMap = new DocumentMap(); foreach (var symbolAndFinder in projectQueue) { _cancellationToken.ThrowIfCancellationRequested(); var symbolAndProjectId = symbolAndFinder.symbolAndProjectId; var symbol = symbolAndProjectId.Symbol; var finder = symbolAndFinder.finder; var documents = await finder.DetermineDocumentsToSearchAsync(symbol, project, _documents, _cancellationToken).ConfigureAwait(false); foreach (var document in documents.Distinct().WhereNotNull()) { if (_documents == null || _documents.Contains(document)) { documentMap.Add(document, symbolAndFinder); } } } Contract.ThrowIfTrue(documentMap.Any(kvp1 => kvp1.Value.Count != kvp1.Value.ToSet().Count)); if (documentMap.Count > 0) { finalMap.Add(project, documentMap); } } return finalMap; } }