コード例 #1
0
 public IList <TextRange> FindAll(
     TextFragment textFragment,
     Func <TextRange, TextRange?> postProcess,
     IOperationProgressTracker progressTracker)
 {
     return(NoResult);
 }
コード例 #2
0
 public IList<TextRange> FindAll(
   CompiledTextSearchData compiledTextSearchData,
   IOperationProgressTracker progressTracker) {
   return _fileContents.FindAll(
     compiledTextSearchData,
     _textRange,
     progressTracker);
 }
コード例 #3
0
 public IList <TextRange> FindAll(
     CompiledTextSearchData compiledTextSearchData,
     IOperationProgressTracker progressTracker)
 {
     return(_fileContents.FindAll(
                compiledTextSearchData,
                _textRange,
                progressTracker));
 }
コード例 #4
0
        private unsafe List <TextRange> FindWorker(
            TextFragment textFragment,
            Func <TextRange, TextRange?> postProcess,
            IOperationProgressTracker progressTracker,
            int maxResultSize)
        {
            List <TextRange> result = null;

            // Note: From C# spec: If E is zero, then no allocation is made, and
            // the pointer returned is implementation-defined.
            byte *searchBuffer = stackalloc byte[this.SearchBufferSize];
            var   searchParams = new NativeMethods.SearchParams {
                TextStart    = textFragment.StartPtr,
                TextLength   = textFragment.Length,
                SearchBuffer = new IntPtr(searchBuffer),
            };

            while (true)
            {
                // Perform next search
                Search(ref searchParams);
                if (searchParams.MatchStart == IntPtr.Zero)
                {
                    break;
                }

                // Convert match from *byte* pointers to a *text* range
                var matchFragment = textFragment.Sub(searchParams.MatchStart, searchParams.MatchLength);
                var matchRange    = new TextRange(matchFragment.Position, matchFragment.Length);

                // Post process match, maybe skipping it
                var postMatchRange = postProcess(matchRange);
                if (postMatchRange == null)
                {
                    continue;
                }
                matchRange = postMatchRange.Value;

                // Add to result collection
                if (result == null)
                {
                    result = new List <TextRange>();
                }
                result.Add(matchRange);

                // Check it is time to end processing early.
                maxResultSize--;
                progressTracker.AddResults(1);
                if (maxResultSize <= 0 || progressTracker.ShouldEndProcessing)
                {
                    CancelSearch(ref searchParams);
                    break;
                }
            }

            return(result ?? NoResult);
        }
コード例 #5
0
        public TextRange?FindFirst(TextFragment textFragment, IOperationProgressTracker progressTracker)
        {
            var result = FindWorker(textFragment, x => x, progressTracker, 1);

            if (result.Count == 0)
            {
                return(null);
            }
            return(result.First());
        }
コード例 #6
0
ファイル: FileContents.cs プロジェクト: mbbill/vs-chromium
    /// <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;
    }
コード例 #7
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);
        }
コード例 #8
0
    private unsafe List<TextRange> FindWorker(
      TextFragment textFragment,
      Func<TextRange, TextRange?> postProcess, 
      IOperationProgressTracker progressTracker,
      int maxResultSize) {
      List<TextRange> result = null;

      // Note: From C# spec: If E is zero, then no allocation is made, and
      // the pointer returned is implementation-defined.
      byte* searchBuffer = stackalloc byte[this.SearchBufferSize];
      var searchParams = new NativeMethods.SearchParams {
        TextStart = textFragment.StartPtr,
        TextLength = textFragment.Length,
        SearchBuffer = new IntPtr(searchBuffer),
      };

      while (true) {
        // Perform next search
        Search(ref searchParams);
        if (searchParams.MatchStart == IntPtr.Zero)
          break;

        // Convert match from *byte* pointers to a *text* range
        var matchFragment = textFragment.Sub(searchParams.MatchStart, searchParams.MatchLength);
        var matchRange = new TextRange(matchFragment.Position, matchFragment.Length);

        // Post process match, maybe skipping it
        var postMatchRange = postProcess(matchRange);
        if (postMatchRange == null)
          continue;
        matchRange = postMatchRange.Value;

        // Add to result collection
        if (result == null)
          result = new List<TextRange>();
        result.Add(matchRange);

        // Check it is time to end processing early.
        maxResultSize--;
        progressTracker.AddResults(1);
        if (maxResultSize <= 0 || progressTracker.ShouldEndProcessing) {
          CancelSearch(ref searchParams);
          break;
        }
      }

      return result ?? NoResult;
    }
コード例 #9
0
 public TextRange? FindFirst(TextFragment textFragment, IOperationProgressTracker progressTracker) {
   return null;
 }
コード例 #10
0
 public IList<TextRange> FindAll(
   TextFragment textFragment,
   Func<TextRange, TextRange?> postProcess,
   IOperationProgressTracker progressTracker) {
   return NoResult;
 }
コード例 #11
0
 public IList <TextRange> FindAll(TextFragment textFragment, Func <TextRange, TextRange?> postProcess, IOperationProgressTracker progressTracker)
 {
     if (progressTracker.ShouldEndProcessing)
     {
         return(NoResult);
     }
     return(FindWorker(textFragment, postProcess, progressTracker, int.MaxValue));
 }
コード例 #12
0
 public TextRange?FindFirst(TextFragment textFragment, IOperationProgressTracker progressTracker)
 {
     return(null);
 }
コード例 #13
0
 public TextRange? FindFirst(TextFragment textFragment, IOperationProgressTracker progressTracker) {
   var result = FindWorker(textFragment, x => x, progressTracker, 1);
   if (result.Count == 0)
     return null;
   return result.First();
 }
コード例 #14
0
 public IList<TextRange> FindAll(TextFragment textFragment, Func<TextRange, TextRange?> postProcess, IOperationProgressTracker progressTracker) {
   if (progressTracker.ShouldEndProcessing)
     return NoResult;
   return FindWorker(textFragment, postProcess, progressTracker, int.MaxValue);
 }