GetInterestingFiles() public méthode

Gets the file names that possibly contain references to the element being searched for.
public GetInterestingFiles ( IFindReferenceSearchScope searchScope, ICompilation compilation ) : IEnumerable
searchScope IFindReferenceSearchScope
compilation ICompilation
Résultat IEnumerable
        void TestFindReferences(IEntity entity)
        {
            if (IgnoreEntity(entity))
                return;
            FindReferences fr = new FindReferences();
            fr.FindTypeReferencesEvenIfAliased = true;

            Stopwatch w = new Stopwatch();
            var searchScopes = fr.GetSearchScopes(entity);
            foreach (var project in solution.Projects) {
                w.Restart();
                HashSet<AstNode> foundReferences = new HashSet<AstNode>();
                var interestingFiles = new HashSet<CSharpFile>();
                foreach (var searchScope in searchScopes) {
                    foreach (var unresolvedFile in fr.GetInterestingFiles(searchScope, project.Compilation)) {
                        var file = project.Files.Single(f => f.FileName == unresolvedFile.FileName);
                        Debug.Assert(file.UnresolvedTypeSystemForFile == unresolvedFile);

                        // Skip file if it doesn't contain the search term
                        if (searchScope.SearchTerm != null && file.OriginalText.IndexOf(searchScope.SearchTerm, StringComparison.Ordinal) < 0)
                            continue;

                        interestingFiles.Add(file);
                    }
                }
                foreach (var file in interestingFiles) {
                    fr.FindReferencesInFile(searchScopes, file.UnresolvedTypeSystemForFile, file.SyntaxTree, project.Compilation,
                                            delegate(AstNode node, ResolveResult result) {
                                                foundReferences.Add(node);
                                            }, CancellationToken.None);
                }
                w.Stop();
                if (timings.ContainsKey(entity.EntityType)) {
                    timings[entity.EntityType] += w.Elapsed;
                } else {
                    timings[entity.EntityType] = w.Elapsed;
                }

                IEntity importedEntity = project.Compilation.Import(entity);

                HashSet<AstNode> expectedReferences;
                if (importedEntity == null || !referenceDict.TryGetValue(importedEntity, out expectedReferences)) {
                    if (foundReferences.Any()) {
                        // There aren't any expected references stored, but we found some references anyways:
                        Console.WriteLine();
                        Console.WriteLine("Entity not in reference dictionary: " + entity);
                    }
                    return;
                }
                if (foundReferences.Except(expectedReferences).Any()) {
                    Console.WriteLine();
                    Console.WriteLine("Reference mismatch for " + entity + ":");
                    var n = foundReferences.Except(expectedReferences).First();
                    Console.WriteLine("Found unexpected reference " + n + " (" + n.GetRegion() + ")");
                }
                if (expectedReferences.Except(foundReferences).Any()) {
                    Console.WriteLine();
                    Console.WriteLine("Reference mismatch for " + entity + ":");
                    var n = expectedReferences.Except(foundReferences).First();
                    Console.WriteLine("Did not find expected reference " + n + " (" + n.GetRegion() + ")");
                }
            }

            if (entityCount.ContainsKey(entity.EntityType)) {
                entityCount[entity.EntityType]++;
            } else {
                entityCount[entity.EntityType] = 1;
            }
        }
        public FindUsagesResponse FindUsages(FindUsagesRequest request)
        {
            var res = _parser.ParsedContent(request.Buffer, request.FileName);
            var loc = new TextLocation(request.Line, request.Column);
            var result = new ConcurrentBag<AstNode>();
            var findReferences = new FindReferences();
            ResolveResult resolveResult = ResolveAtLocation.Resolve(res.Compilation, res.UnresolvedFile, res.SyntaxTree, loc);
            if (resolveResult is LocalResolveResult)
            {
                var variable = (resolveResult as LocalResolveResult).Variable;
                findReferences.FindLocalReferences(variable, res.UnresolvedFile, res.SyntaxTree, res.Compilation, (node, rr) => result.Add(node), CancellationToken.None);
            }
            else
            {
                IEntity entity = null;
                if (resolveResult is TypeResolveResult)
                {
                    entity = (resolveResult as TypeResolveResult).Type.GetDefinition();
                }

                if (resolveResult is MemberResolveResult)
                {
                    entity = (resolveResult as MemberResolveResult).Member;
                }

                if (entity == null)
                {
                    return new FindUsagesResponse {Usages = new List<Usage>()};
                }
                var searchScopes = findReferences.GetSearchScopes(entity);

                var interesting = new List<CSharpUnresolvedFile>();

                foreach (var scope in searchScopes)
                {
                    var scopeInteresting = findReferences.GetInterestingFiles(scope, res.Compilation);
                    interesting.AddRange(scopeInteresting);
                }

                Parallel.ForEach(interesting, file =>
                    {
                        ParsedResult parsedResult = _parser.ParsedContent(
                            _solution.GetFile(file.FileName).Content.Text, file.FileName);
                        findReferences.FindReferencesInFile(searchScopes, file, parsedResult.SyntaxTree,
                                                            parsedResult.Compilation,
                                                            (node, rr) => result.Add(node), CancellationToken.None);
                    });

            }

            var usages = result.Select(node => new Usage
            {
                FileName = node.GetRegion().FileName,
                Text = node.Preview(_solution.GetFile(node.GetRegion().FileName)).Replace("'", "''"),
                Line = node.StartLocation.Line,
                Column = node.StartLocation.Column,
            });

            return new FindUsagesResponse { Usages = usages };
        }