Exemple #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)));
        }
        public bool ProcessProjectItem <TResult>(IPsiSourceFile sourceFile, IFindResultConsumer <TResult> consumer)
        {
            if (myWordsInText.Any(word => myWordIndex.CanContainWord(sourceFile, word)))
            {
                return(sourceFile.GetPsiFiles <DslLanguage>().Any(file => ProcessElement(file, consumer)));
            }

            return(false);
        }
 private IContainerInfo GetMatchingContainer(IPsiSourceFile sourceFile)
 {
     return(knownContainers.FirstOrDefault(knownContainer =>
                                           knownContainer.ContainerQualifiedNames.Any(s => wordIndex.CanContainWord(sourceFile, s))));
 }