internal static async Task<(ImmutableArray<RenameLocation>, ImmutableArray<RenameLocation>)> GetRenamableLocationsInStringsAndCommentsAsync( ISymbol originalSymbol, Solution solution, ISet<RenameLocation> renameLocations, bool renameInStrings, bool renameInComments, CancellationToken cancellationToken) { if (!renameInStrings && !renameInComments) return default; var renameText = originalSymbol.Name; using var _1 = ArrayBuilder<RenameLocation>.GetInstance(out var stringLocations); using var _2 = ArrayBuilder<RenameLocation>.GetInstance(out var commentLocations); foreach (var documentsGroupedByLanguage in RenameUtilities.GetDocumentsAffectedByRename(originalSymbol, solution, renameLocations).GroupBy(d => d.Project.Language)) { var syntaxFactsLanguageService = solution.Workspace.Services.GetLanguageServices(documentsGroupedByLanguage.Key).GetService<ISyntaxFactsService>(); if (syntaxFactsLanguageService != null) { foreach (var document in documentsGroupedByLanguage) { if (renameInStrings) { await AddLocationsToRenameInStringsAsync( document, renameText, syntaxFactsLanguageService, stringLocations, cancellationToken).ConfigureAwait(false); } if (renameInComments) { await AddLocationsToRenameInCommentsAsync(document, renameText, commentLocations, cancellationToken).ConfigureAwait(false); } } } } return (renameInStrings ? stringLocations.ToImmutable() : default,
internal static async Task <Tuple <IEnumerable <RenameLocation>, IEnumerable <RenameLocation> > > GetRenamableLocationsInStringsAndCommentsAsync( ISymbol originalSymbol, Solution solution, ISet <RenameLocation> renameLocations, bool renameInStrings, bool renameInComments, CancellationToken cancellationToken) { if (!renameInStrings && !renameInComments) { return(new Tuple <IEnumerable <RenameLocation>, IEnumerable <RenameLocation> >(null, null)); } var renameText = originalSymbol.Name; List <RenameLocation> stringLocations = renameInStrings ? new List <RenameLocation>() : null; List <RenameLocation> commentLocations = renameInComments ? new List <RenameLocation>() : null; foreach (var documentsGroupedByLanguage in RenameUtilities.GetDocumentsAffectedByRename(originalSymbol, solution, renameLocations).GroupBy(d => d.Project.Language)) { var syntaxFactsLanguageService = solution.Workspace.Services.GetLanguageServices(documentsGroupedByLanguage.Key).GetService <ISyntaxFactsService>(); foreach (var document in documentsGroupedByLanguage) { if (renameInStrings) { await AddLocationsToRenameInStringsAsync(document, renameText, syntaxFactsLanguageService, stringLocations, cancellationToken).ConfigureAwait(false); } if (renameInComments) { await AddLocationsToRenameInCommentsAsync(document, renameText, commentLocations, cancellationToken).ConfigureAwait(false); } } } return(new Tuple <IEnumerable <RenameLocation>, IEnumerable <RenameLocation> >(stringLocations, commentLocations)); }