Example #1
0
            /// <summary>
            /// The method determines the set of documents that need to be processed for Rename and also determines
            ///  the possible set of names that need to be checked for conflicts.
            /// </summary>
            private async Task FindDocumentsAndPossibleNameConflicts()
            {
                try
                {
                    var symbol          = _renameLocationSet.Symbol;
                    var solution        = _renameLocationSet.Solution;
                    var dependencyGraph = solution.GetProjectDependencyGraph();
                    _topologicallySortedProjects = dependencyGraph.GetTopologicallySortedProjects(_cancellationToken).ToList();

                    var allRenamedDocuments = _renameLocationSet.Locations.Select(loc => loc.Location.SourceTree).Distinct().Select(solution.GetDocument);
                    _documentsIdsToBeCheckedForConflict.AddRange(allRenamedDocuments.Select(d => d.Id));

                    var documentsFromAffectedProjects = RenameUtilities.GetDocumentsAffectedByRename(symbol, solution, _renameLocationSet.Locations);
                    foreach (var language in documentsFromAffectedProjects.Select(d => d.Project.Language).Distinct())
                    {
                        solution.Workspace.Services.GetLanguageServices(language).GetService <IRenameRewriterLanguageService>()
                        ?.TryAddPossibleNameConflicts(symbol, _replacementText, _possibleNameConflicts);
                    }

                    await AddDocumentsWithPotentialConflicts(documentsFromAffectedProjects).ConfigureAwait(false);
                }
                catch (Exception e) when(FatalError.ReportUnlessCanceled(e))
                {
                    throw ExceptionUtilities.Unreachable;
                }
            }
Example #2
0
            /// <summary>
            /// The method determines the set of documents that need to be processed for Rename and also determines
            ///  the possible set of names that need to be checked for conflicts.
            /// </summary>
            private async Task FindDocumentsAndPossibleNameConflicts()
            {
                var symbol          = renameLocationSet.Symbol;
                var solution        = renameLocationSet.Solution;
                var dependencyGraph = solution.GetProjectDependencyGraph();

                this.topologicallySortedProjects = dependencyGraph.GetTopologicallySortedProjects(cancellationToken).ToList();

                var allRenamedDocuments = renameLocationSet.Locations.Select(loc => loc.Location.SourceTree).Distinct().Select(solution.GetDocument);

                this.documentsIdsToBeCheckedForConflict.AddRange(allRenamedDocuments.Select(d => d.Id));

                var documentsFromAffectedProjects = RenameUtilities.GetDocumentsAffectedByRename(symbol, solution, renameLocationSet.Locations);

                foreach (var language in documentsFromAffectedProjects.Select(d => d.Project.Language).Distinct())
                {
                    solution.Workspace.Services.GetLanguageServices(language).GetService <IRenameRewriterLanguageService>()
                    .TryAddPossibleNameConflicts(symbol, replacementText, possibleNameConflicts);
                }

                await AddDocumentsWithPotentialConflicts(documentsFromAffectedProjects).ConfigureAwait(false);
            }