Пример #1
0
        private Func <TextRange, TextRange?> CreateFilterForOtherEntries(
            CompiledTextSearchData compiledTextSearchData)
        {
            if (compiledTextSearchData.ParsedSearchString.EntriesBeforeMainEntry.Count == 0 &&
                compiledTextSearchData.ParsedSearchString.EntriesAfterMainEntry.Count == 0)
            {
                return(x => x);
            }

            // Search for a match for "entry" withing "textRange"
            FindEntryFunction findEntry = (textRange, entry) => {
                var algo = this.GetCompiledTextSearch(compiledTextSearchData.GetSearchContainer(entry));
                return(algo.FindFirst(CreateFragmentFromRange(textRange), OperationProgressTracker.None));
            };

            // Return the extent of the line to look into for non-main entries.
            GetLineRangeFunction getLineRange = position =>
                                                this.GetLineTextRangeFromPosition(position, MaxLineExtentOffset);

            var sourceTextSearch = new TextSourceTextSearch(
                getLineRange,
                findEntry,
                compiledTextSearchData.ParsedSearchString);

            return(sourceTextSearch.FilterSearchHit);
        }
Пример #2
0
 public IList <TextRange> FindAll(
     CompiledTextSearchData compiledTextSearchData,
     IOperationProgressTracker progressTracker)
 {
     return(_fileContents.FindAll(
                compiledTextSearchData,
                _textRange,
                progressTracker));
 }
Пример #3
0
        /// <summary>
        /// Find all instances of the search pattern stored in <paramref
        /// name="compiledTextSearchData"/> within the passed in <paramref
        /// name="textRange"/>
        /// </summary>
        public IList <TextRange> FindAll(
            CompiledTextSearchData compiledTextSearchData,
            TextRange textRange,
            IOperationProgressTracker progressTracker)
        {
            var textFragment         = CreateFragmentFromRange(textRange);
            var providerForMainEntry = compiledTextSearchData
                                       .GetSearchContainer(compiledTextSearchData.ParsedSearchString.MainEntry);
            var textSearch           = GetCompiledTextSearch(providerForMainEntry);
            var postProcessSearchHit = CreateFilterForOtherEntries(compiledTextSearchData);
            var result = textSearch.FindAll(textFragment, postProcessSearchHit, progressTracker);

            return(result);
        }