コード例 #1
0
ファイル: Search.cs プロジェクト: kleinux/SharpDevelop
        public SearchResultMatch FindNext(IProgressMonitor monitor)
        {
            // insanity check
            Debug.Assert(searchStrategy != null);
            Debug.Assert(documentIterator != null);
            Debug.Assert(textIteratorBuilder != null);

            if (monitor != null && monitor.CancellationToken.IsCancellationRequested)
            {
                return(null);
            }

            if (info != null && textIterator != null && documentIterator.CurrentFileName != null)
            {
                ProvidedDocumentInformation currentInfo = documentIterator.Current;
                if (currentInfo != null)
                {
                    if (!info.Equals(currentInfo))                       // create new iterator, if document changed
                    {
                        info         = currentInfo;
                        textIterator = textIteratorBuilder.BuildTextIterator(info);
                    }
                    else                         // old document -> initialize iterator position to caret pos
                    {
                        textIterator.Position = info.CurrentOffset;
                    }

                    SearchResultMatch result = CreateNamedSearchResult(searchStrategy.FindNext(textIterator));
                    if (result != null)
                    {
                        info.CurrentOffset = textIterator.Position;
                        return(result);
                    }
                }
            }

            // not found or first start -> move forward to the next document
            if (documentIterator.MoveForward())
            {
                info = documentIterator.Current;
                // document is valid for searching -> set iterator & fileName
                if (info != null && info.EndOffset >= 0 && info.EndOffset <= info.Document.TextLength)
                {
                    textIterator = textIteratorBuilder.BuildTextIterator(info);
                }
                else
                {
                    textIterator = null;
                }

                return(FindNext(monitor));
            }
            return(null);
        }
コード例 #2
0
ファイル: Search.cs プロジェクト: carlhuth/GenXSource
        public SearchResult FindNext()
        {
            // insanity check
            Debug.Assert(searchStrategy != null);
            Debug.Assert(documentIterator != null);
            Debug.Assert(textIteratorBuilder != null);

            if (info != null && textIterator != null && documentIterator.CurrentFileName != null)
            {
                if (info.FileName != documentIterator.CurrentFileName)                   // create new iterator, if document changed
                {
                    info         = documentIterator.Current;
                    textIterator = textIteratorBuilder.BuildTextIterator(info);
                }
                else                     // old document -> initialize iterator position to caret pos
                {
                    textIterator.Position = info.CurrentOffset;
                }

                SearchResult result = CreateNamedSearchResult(searchStrategy.FindNext(textIterator));
                if (result != null)
                {
                    info.CurrentOffset = textIterator.Position;
                    return(result);
                }
            }

            // not found or first start -> move forward to the next document
            if (documentIterator.MoveForward())
            {
                info = documentIterator.Current;
                // document is valid for searching -> set iterator & fileName
                if (info != null && info.TextBuffer != null && info.EndOffset >= 0 && info.EndOffset < info.TextBuffer.Length)
                {
                    textIterator = textIteratorBuilder.BuildTextIterator(info);
                }
                else
                {
                    textIterator = null;
                }

                return(FindNext());
            }
            return(null);
        }
コード例 #3
0
            SearchResultMatch Find(FileName file, IDocument document, int searchOffset, int length)
            {
                var result = strategy.FindNext(DocumentUtilitites.GetTextSource(document), searchOffset, length);

                if (result != null)
                {
                    var start = document.OffsetToPosition(result.Offset);
                    var end   = document.OffsetToPosition(result.EndOffset);
                    return(new AvalonEditSearchResultMatch(file, start, end, result.Offset, result.Length, null, null, result));
                }
                return(null);
            }
コード例 #4
0
        public void FindNext()
        {
            if (fStrategy == null)
            {
                return;
            }

            if (!fStrategy.HasResults())
            {
                AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_NoMatchesFound));
                return;
            }

            ISearchResult result = fStrategy.FindNext();

            if (result != null)
            {
                SelectResult(result as SearchResult);
            }
        }
コード例 #5
0
        public void Build(ISearchStrategy strategy, ITextIterator it, SearchOptions options)
        {
            int startPos = it.Position;
            it.Reset ();

            ISearchResult res = strategy.FindNext (it, options, false);
            while (res != null) {
                matches.Add (res);
                res = strategy.FindNext (it, options, false);
            }
            it.Position = startPos;
        }