예제 #1
0
		public bool EqualsWithoutSelection(SearchLocation other)
		{
			return other != null &&
				Target == other.Target &&
				BaseDirectory == other.BaseDirectory &&
				Filter == other.Filter &&
				SearchSubdirs == other.SearchSubdirs;
		}
예제 #2
0
 public bool EqualsWithoutSelection(SearchLocation other)
 {
     return(other != null &&
            Target == other.Target &&
            BaseDirectory == other.BaseDirectory &&
            Filter == other.Filter &&
            SearchSubdirs == other.SearchSubdirs);
 }
예제 #3
0
        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());
        }
예제 #4
0
 SearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location)
 {
     if (files == null)
     {
         throw new ArgumentNullException("files");
     }
     this.files    = files;
     this.strategy = strategy;
     this.location = location;
 }
예제 #5
0
		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);
     }
 }
예제 #7
0
 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 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) {}
     }
 }
예제 #9
0
        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);
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
		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);
			}
		}
예제 #13
0
		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);
			}
		}
예제 #14
0
		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);
		}
예제 #15
0
            public static SearchRegion CreateSearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location)
            {
                ITextEditor editor = GetActiveTextEditor();

                if (editor != null)
                {
                    return(new SearchRegion(files, strategy, location));
                }

                return(null);
            }
예제 #16
0
		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) {}
		}
예제 #17
0
		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();
		}
예제 #18
0
 public bool IsSameState(FileName[] files, ISearchStrategy strategy, SearchLocation location)
 {
     return(this.files.SequenceEqual(files) &&
            this.strategy.Equals(strategy) &&
            this.location.EqualsWithoutSelection(location));
 }
예제 #19
0
 public static SearchRegion CreateSearchRegion(FileName[] files, ISearchStrategy strategy, SearchLocation location)
 {
     return(new SearchRegion(files, strategy, location));
 }