public BeginReplace ( string content ) : void | ||
content | string | |
return | void |
IEnumerable <SearchResult> RegexSearch(ProgressMonitor monitor, FileProvider provider, TextReader reader, string replacePattern, FilterOptions filter) { string content = reader.ReadToEnd(); var results = new List <SearchResult> (); if (replacePattern == null) { foreach (Match match in regex.Matches(content)) { if (monitor.CancellationToken.IsCancellationRequested) { break; } if (provider.SelectionStartPosition > -1 && match.Index < provider.SelectionStartPosition) { continue; } if (provider.SelectionEndPosition > -1 && match.Index + match.Length > provider.SelectionEndPosition) { continue; } if (!filter.WholeWordsOnly || FilterOptions.IsWholeWordAt(content, match.Index, match.Length)) { results.Add(new SearchResult(provider, match.Index, match.Length)); } } } else { var matches = new List <Match> (); foreach (Match match in regex.Matches(content)) { if (provider.SelectionStartPosition > -1 && match.Index < provider.SelectionStartPosition) { continue; } if (provider.SelectionEndPosition > -1 && match.Index + match.Length > provider.SelectionEndPosition) { continue; } matches.Add(match); } provider.BeginReplace(content); int delta = 0; for (int i = 0; !monitor.CancellationToken.IsCancellationRequested && i < matches.Count; i++) { Match match = matches[i]; if (!filter.WholeWordsOnly || FilterOptions.IsWholeWordAt(content, match.Index, match.Length)) { string replacement = match.Result(replacePattern); results.Add(new SearchResult(provider, match.Index + delta, replacement.Length)); provider.Replace(match.Index + delta, match.Length, replacement); delta += replacement.Length - match.Length; } } provider.EndReplace(); } return(results); }
IEnumerable<SearchResult> RegexSearch (ProgressMonitor monitor, FileProvider provider, string content, string replacePattern, FilterOptions filter) { var results = new List<SearchResult> (); if (replacePattern == null) { foreach (Match match in regex.Matches (content)) { if (monitor.CancellationToken.IsCancellationRequested) break; if (provider.SelectionStartPosition > -1 && match.Index < provider.SelectionStartPosition) continue; if (provider.SelectionEndPosition > -1 && match.Index + match.Length > provider.SelectionEndPosition) continue; if (!filter.WholeWordsOnly || FilterOptions.IsWholeWordAt(content, match.Index, match.Length)) results.Add(new SearchResult(provider, match.Index, match.Length)); } } else { var matches = new List<Match> (); foreach (Match match in regex.Matches(content)) { if (provider.SelectionStartPosition > -1 && match.Index < provider.SelectionStartPosition) continue; if (provider.SelectionEndPosition > -1 && match.Index + match.Length > provider.SelectionEndPosition) continue; matches.Add(match); } provider.BeginReplace (content); int delta = 0; for (int i = 0; !monitor.CancellationToken.IsCancellationRequested && i < matches.Count; i++) { Match match = matches[i]; if (!filter.WholeWordsOnly || FilterOptions.IsWholeWordAt (content, match.Index, match.Length)) { string replacement = match.Result (replacePattern); results.Add (new SearchResult (provider, match.Index + delta, replacement.Length)); provider.Replace (match.Index + delta, match.Length, replacement); delta += replacement.Length - match.Length; } } provider.EndReplace (); } return results; }