public bool EqualsWithoutSelection(SearchLocation other) { return other != null && Target == other.Target && BaseDirectory == other.BaseDirectory && Filter == other.Filter && SearchSubdirs == other.SearchSubdirs; }
public bool EqualsWithoutSelection(SearchLocation other) { return(other != null && Target == other.Target && BaseDirectory == other.BaseDirectory && Filter == other.Filter && SearchSubdirs == other.SearchSubdirs); }
public static IEnumerable <SearchedFile> FindAll(ISearchStrategy strategy, SearchLocation location, IProgressMonitor progressMonitor) { currentSearchRegion = null; SearchableFileContentFinder fileFinder = new SearchableFileContentFinder(); return(new SearchRun(strategy, fileFinder, location.GenerateFileList(), progressMonitor) { Target = location.Target, Selection = location.Selection }.GetResults()); }
SearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location) { if (files == null) { throw new ArgumentNullException("files"); } this.files = files; this.strategy = strategy; this.location = location; }
public override void Run() { if (SearchOptions.CurrentFindPattern.Length > 0) { var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); var result = SearchManager.FindNext(strategy, location); SearchManager.SelectResult(result); } else { Find find = new Find(); find.Run(); } }
void FindNextButtonClicked(object sender, EventArgs e) { try { WritebackOptions(); var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); lastMatch = SearchManager.FindNext(strategy, location); SearchManager.SelectResult(lastMatch); Focus(); } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); } }
void BookmarkAllButtonClicked(object sender, EventArgs e) { WritebackOptions(); using (var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor()) { monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); try { var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); var results = SearchManager.FindAllParallel(strategy, location, monitor); SearchManager.MarkAll(results); } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); } catch (OperationCanceledException) {} } }
void FindAllButtonClicked(object sender, EventArgs e) { WritebackOptions(); var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); ISearchStrategy strategy; try { strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); return; } // No using block for the monitor; it is disposed when the asynchronous search finishes var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(); monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); var results = SearchManager.FindAllParallel(strategy, location, monitor); SearchManager.ShowSearchResults(SearchOptions.FindPattern, results); }
void ReplaceAllButtonClicked(object sender, EventArgs e) { WritebackOptions(); int count = -1; try { AsynchronousWaitDialog.RunInCancellableWaitDialog( StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"), null, monitor => { var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); var results = SearchManager.FindAll(strategy, location, monitor); count = SearchManager.ReplaceAll(results, SearchOptions.ReplacePattern, monitor.CancellationToken); }); if (count != -1) { SearchManager.ShowReplaceDoneMessage(count); } } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); } }
public static SearchResultMatch FindNext(ISearchStrategy strategy, SearchLocation location) { var files = location.GenerateFileList().ToArray(); if (files.Length == 0) { return(null); } if (currentSearchRegion == null || !currentSearchRegion.IsSameState(files, strategy, location)) { currentSearchRegion = SearchRegion.CreateSearchRegion(files, strategy, location); } if (currentSearchRegion == null) { return(null); } var result = currentSearchRegion.FindNext(); if (result == null) { currentSearchRegion = null; } return(result); }
void ReplaceButtonClicked(object sender, EventArgs e) { try { WritebackOptions(); if (SearchManager.IsResultSelected(lastMatch)) SearchManager.Replace(lastMatch, SearchOptions.ReplacePattern); var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); lastMatch = SearchManager.FindNext(strategy, location); SearchManager.SelectResult(lastMatch); Focus(); } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); } }
void ReplaceAllButtonClicked(object sender, EventArgs e) { WritebackOptions(); int count = -1; try { AsynchronousWaitDialog.RunInCancellableWaitDialog( StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"), null, monitor => { var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); var results = SearchManager.FindAll(strategy, location, monitor); count = SearchManager.ReplaceAll(results, SearchOptions.ReplacePattern, monitor.CancellationToken); }); if (count != -1) SearchManager.ShowReplaceDoneMessage(count); } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); } }
void BookmarkAllButtonClicked(object sender, EventArgs e) { WritebackOptions(); var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); ISearchStrategy strategy; try { strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); } catch (SearchPatternException ex) { MessageService.ShowError(ex.Message); return; } // No using block for the monitor; it is disposed when the asynchronous search finishes var monitor = SD.StatusBar.CreateProgressMonitor(); monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); var results = SearchManager.FindAllParallel(strategy, location, monitor); SearchManager.MarkAll(results); }
public static SearchRegion CreateSearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location) { ITextEditor editor = GetActiveTextEditor(); if (editor != null) { return(new SearchRegion(files, strategy, location)); } return(null); }
void FindAllButtonClicked(object sender, EventArgs e) { WritebackOptions(); var monitor = WorkbenchSingleton.StatusBar.CreateProgressMonitor(); monitor.TaskName = StringParser.Parse("${res:AddIns.SearchReplace.SearchProgressTitle}"); try { var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(false) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); var results = SearchManager.FindAllParallel(strategy, location, monitor); SearchManager.ShowSearchResults(SearchOptions.FindPattern, results); } catch (OperationCanceledException) {} }
void FindNextButtonClicked(object sender, EventArgs e) { WritebackOptions(); var location = new SearchLocation(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); lastMatch = SearchManager.FindNext(strategy, location); SearchManager.SelectResult(lastMatch); Focus(); }
public bool IsSameState(FileName[] files, ISearchStrategy strategy, SearchLocation location) { return(this.files.SequenceEqual(files) && this.strategy.Equals(strategy) && this.location.EqualsWithoutSelection(location)); }
public static SearchRegion CreateSearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location) { return(new SearchRegion(files, strategy, location)); }