private static async Task <SearchResult> AddLocationsReferenceSymbolsAsync( SymbolAndProjectId symbolAndProjectId, Solution solution, CancellationToken cancellationToken) { var symbol = symbolAndProjectId.Symbol; var locations = new HashSet <RenameLocation>(); var referenceSymbols = await SymbolFinder.FindRenamableReferencesAsync( symbolAndProjectId, solution, cancellationToken).ConfigureAwait(false); foreach (var referencedSymbol in referenceSymbols) { locations.AddAll( await ReferenceProcessing.GetRenamableDefinitionLocationsAsync(referencedSymbol.Definition, symbol, solution, cancellationToken).ConfigureAwait(false)); locations.AddAll( await referencedSymbol.Locations.SelectManyAsync <ReferenceLocation, RenameLocation>( (l, c) => ReferenceProcessing.GetRenamableReferenceLocationsAsync(referencedSymbol.Definition, symbol, l, solution, c), cancellationToken).ConfigureAwait(false)); } var implicitLocations = referenceSymbols.SelectMany(refSym => refSym.Locations).Where(loc => loc.IsImplicit).ToList(); var referencedSymbols = referenceSymbols.Select(r => r.DefinitionAndProjectId).Where(r => !r.Symbol.Equals(symbol)).ToList(); return(new SearchResult(locations, implicitLocations, referencedSymbols)); }
private static async Task<SearchResult> AddLocationsReferenceSymbolsAsync( ISymbol symbol, Solution solution, CancellationToken cancellationToken) { var locations = ImmutableHashSet.CreateBuilder<RenameLocation>(); var referenceSymbols = await SymbolFinder.FindRenamableReferencesAsync( symbol, solution, cancellationToken).ConfigureAwait(false); foreach (var referencedSymbol in referenceSymbols) { locations.AddAll( await ReferenceProcessing.GetRenamableDefinitionLocationsAsync(referencedSymbol.Definition, symbol, solution, cancellationToken).ConfigureAwait(false)); locations.AddAll( await referencedSymbol.Locations.SelectManyInParallelAsync( (l, c) => ReferenceProcessing.GetRenamableReferenceLocationsAsync(referencedSymbol.Definition, symbol, l, solution, c), cancellationToken).ConfigureAwait(false)); } var implicitLocations = referenceSymbols.SelectMany(refSym => refSym.Locations).Where(loc => loc.IsImplicit).ToImmutableArray(); var referencedSymbols = referenceSymbols.Select(r => r.Definition).Where(r => !r.Equals(symbol)).ToImmutableArray(); return new SearchResult(locations.ToImmutable(), implicitLocations, referencedSymbols); }