private async Task <ProjectMap> CreateProjectMapAsync(ConcurrentSet <SymbolGroup> symbolGroups, CancellationToken cancellationToken) { using (Logger.LogBlock(FunctionId.FindReference_CreateProjectMapAsync, cancellationToken)) { var projectMap = new ProjectMap(); var scope = _documents?.Select(d => d.Project).ToImmutableHashSet(); foreach (var symbolGroup in symbolGroups) { foreach (var symbol in symbolGroup.Symbols) { cancellationToken.ThrowIfCancellationRequested(); var projects = await DependentProjectsFinder.GetDependentProjectsAsync( _solution, symbol, scope, cancellationToken).ConfigureAwait(false); foreach (var project in projects.Distinct().WhereNotNull()) { if (scope == null || scope.Contains(project)) { projectMap.MultiAdd(project, symbol); } } } } Contract.ThrowIfTrue(projectMap.Any(kvp => kvp.Value.Count != kvp.Value.ToSet().Count)); return(projectMap); } }
private async Task<ProjectMap> CreateProjectMapAsync(ConcurrentSet<SymbolAndProjectId> symbols) { using (Logger.LogBlock(FunctionId.FindReference_CreateProjectMapAsync, _cancellationToken)) { var projectMap = new ProjectMap(); var scope = _documents?.Select(d => d.Project).ToImmutableHashSet(); foreach (var symbolAndProjectId in symbols) { foreach (var finder in _finders) { _cancellationToken.ThrowIfCancellationRequested(); var projects = await finder.DetermineProjectsToSearchAsync(symbolAndProjectId.Symbol, _solution, scope, _cancellationToken).ConfigureAwait(false); foreach (var project in projects.Distinct().WhereNotNull()) { if (scope == null || scope.Contains(project)) { projectMap.Add(project, (symbolAndProjectId, finder)); } } } } Contract.ThrowIfTrue(projectMap.Any(kvp => kvp.Value.Count != kvp.Value.ToSet().Count)); return projectMap; } }