Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 public TextSourceTextSearch(
   GetLineRangeFunction getLineRange,
   FindEntryFunction findEntry,
   ParsedSearchString parsedSearchString) {
   _findEntry = findEntry;
   _parsedSearchString = parsedSearchString;
   _getLineExtentCache = new GetLineExtentCache(getLineRange);
 }
Ejemplo n.º 3
0
 public TextSourceTextSearch(
     GetLineRangeFunction getLineRange,
     FindEntryFunction findEntry,
     ParsedSearchString parsedSearchString)
 {
     _findEntry          = findEntry;
     _parsedSearchString = parsedSearchString;
     _getLineExtentCache = new GetLineExtentCache(getLineRange);
 }
Ejemplo n.º 4
0
        private IEnumerable <FilePositionSpan> FilterOnOtherEntries(SearchContentsData searchContentsData, IEnumerable <FilePositionSpan> matches)
        {
            FindEntryFunction findEntry = (position, length, entry) => {
                var algo   = searchContentsData.GetSearchAlgorithms(entry).AsciiStringSearchAlgo;
                var start  = Pointers.AddPtr(this.Pointer, position);
                var result = algo.Search(start, length);
                if (result == IntPtr.Zero)
                {
                    return(-1);
                }
                return(position + Pointers.Offset32(start, result));
            };
            GetLineExtentFunction getLineExtent = position => {
                int lineStart;
                int lineLength;
                NativeMethods.Ascii_GetLineExtentFromPosition(this.Pointer, (int)this.CharacterCount, position, out lineStart, out lineLength);
                return(new FilePositionSpan {
                    Position = lineStart, Length = lineLength
                });
            };

            return(new TextSourceTextSearch(getLineExtent, findEntry).FilterOnOtherEntries(searchContentsData.ParsedSearchString, matches));
        }
Ejemplo n.º 5
0
 public TextSourceTextSearch(GetLineExtentFunction getLineExtent, FindEntryFunction findEntry)
 {
     _getLineExtent = getLineExtent;
     _findEntry     = findEntry;
 }
 public TextSourceTextSearch(GetLineExtentFunction getLineExtent, FindEntryFunction findEntry)
 {
     _getLineExtent = getLineExtent;
       _findEntry = findEntry;
 }