Exemplo n.º 1
0
        private ISearchDomain NarrowSearchDomain(ISolution solution, IEnumerable <string> words, IEnumerable <string> extendedWords, ISearchDomain domain)
        {
            List <string> allWords         = words.ToList();
            List <string> allExtendedWords = extendedWords.ToList();

            if (domain.IsEmpty || allWords.IsEmpty())
            {
                return(domain);
            }
            IWordIndex wordIndex   = solution.GetPsiServices().CacheManager.WordIndex;
            var        jetHashSet1 = new JetHashSet <IPsiSourceFile>(wordIndex.GetFilesContainingWord(allWords.First()), null);

            foreach (string word in allWords.Skip(1))
            {
                jetHashSet1.IntersectWith(wordIndex.GetFilesContainingWord(word));
            }
            if (allExtendedWords.Any())
            {
                var jetHashSet2 = new JetHashSet <IPsiSourceFile>(null);
                using (JetHashSet <IPsiSourceFile> .ElementEnumerator enumerator = jetHashSet1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IPsiSourceFile file = enumerator.Current;
                        if (allExtendedWords.Any(word => wordIndex.CanContainWord(file, word)))
                        {
                            jetHashSet2.Add(file);
                        }
                    }
                }
                jetHashSet1 = jetHashSet2;
            }
            return(domain.Intersect(searchDomainFactory.CreateSearchDomain(jetHashSet1)));
        }
Exemplo n.º 2
0
        private ISearchDomain NarrowSearchDomain(ISolution solution, IEnumerable<string> words, IEnumerable<string> extendedWords, ISearchDomain domain)
        {
            List<string> allWords = words.ToList();
            List<string> allExtendedWords = extendedWords.ToList();

            if (domain.IsEmpty || allWords.IsEmpty())
                return domain;
            IWordIndex wordIndex = solution.GetPsiServices().CacheManager.WordIndex;
            var jetHashSet1 = new JetHashSet<IPsiSourceFile>(wordIndex.GetFilesContainingWord(allWords.First()), null);
            foreach (string word in allWords.Skip(1))
                jetHashSet1.IntersectWith(wordIndex.GetFilesContainingWord(word));
            if (allExtendedWords.Any())
            {
                var jetHashSet2 = new JetHashSet<IPsiSourceFile>(null);
                using (JetHashSet<IPsiSourceFile>.ElementEnumerator enumerator = jetHashSet1.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IPsiSourceFile file = enumerator.Current;
                        if (allExtendedWords.Any(word => wordIndex.CanContainWord(file, word)))
                            jetHashSet2.Add(file);
                    }
                }
                jetHashSet1 = jetHashSet2;
            }
            return domain.Intersect(searchDomainFactory.CreateSearchDomain(jetHashSet1));
        }