Browse Source

Fixed SD2-1275: Searching using an invalid regex shows search in progress dialog

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2327 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
e1844b5410
  1. 8
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceInFilesManager.cs
  2. 12
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs
  3. 2
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/BruteForceSearchStrategy.cs
  4. 10
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/ISearchStrategy.cs
  5. 5
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/RegExSearchStrategy.cs
  6. 2
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/WildcardSearchStrategy.cs

8
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceInFilesManager.cs

@ -37,12 +37,12 @@ namespace SearchAndReplace @@ -37,12 +37,12 @@ namespace SearchAndReplace
find.DocumentIterator = SearchReplaceUtilities.CreateDocumentIterator(SearchOptions.DocumentIteratorType);
}
static bool InitializeSearchInFiles()
static bool InitializeSearchInFiles(IProgressMonitor monitor)
{
SetSearchOptions();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return false;
currentFileName = String.Empty;
@ -71,7 +71,7 @@ namespace SearchAndReplace @@ -71,7 +71,7 @@ namespace SearchAndReplace
public static void FindAll(IProgressMonitor monitor)
{
if (!InitializeSearchInFiles()) {
if (!InitializeSearchInFiles(monitor)) {
return;
}
@ -88,7 +88,7 @@ namespace SearchAndReplace @@ -88,7 +88,7 @@ namespace SearchAndReplace
public static void FindAll(int offset, int length, IProgressMonitor monitor)
{
if (!InitializeSearchInFiles()) {
if (!InitializeSearchInFiles(monitor)) {
return;
}

12
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs

@ -103,7 +103,7 @@ namespace SearchAndReplace @@ -103,7 +103,7 @@ namespace SearchAndReplace
SetSearchOptions();
ClearSelection();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
List<TextEditorControl> textAreas = new List<TextEditorControl>();
int count;
@ -128,7 +128,7 @@ namespace SearchAndReplace @@ -128,7 +128,7 @@ namespace SearchAndReplace
SetSearchOptions();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
List<TextEditorControl> textAreas = new List<TextEditorControl>();
@ -191,7 +191,7 @@ namespace SearchAndReplace @@ -191,7 +191,7 @@ namespace SearchAndReplace
SetSearchOptions();
ClearSelection();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
List<TextEditorControl> textAreas = new List<TextEditorControl>();
@ -239,7 +239,7 @@ namespace SearchAndReplace @@ -239,7 +239,7 @@ namespace SearchAndReplace
SetSearchOptions();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
for (int count = 0;; count++) {
@ -274,7 +274,7 @@ namespace SearchAndReplace @@ -274,7 +274,7 @@ namespace SearchAndReplace
return;
}
if (!find.SearchStrategy.CompilePattern()) {
if (!find.SearchStrategy.CompilePattern(monitor)) {
find.Reset();
lastResult = null;
return;
@ -319,7 +319,7 @@ namespace SearchAndReplace @@ -319,7 +319,7 @@ namespace SearchAndReplace
return;
}
if (!find.SearchStrategy.CompilePattern()) {
if (!find.SearchStrategy.CompilePattern(monitor)) {
find.Reset();
lastResult = null;
return;

2
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/BruteForceSearchStrategy.cs

@ -71,7 +71,7 @@ namespace SearchAndReplace @@ -71,7 +71,7 @@ namespace SearchAndReplace
return -1;
}
public bool CompilePattern()
public bool CompilePattern(ICSharpCode.SharpDevelop.Gui.IProgressMonitor monitor)
{
searchPattern = SearchOptions.MatchCase ? SearchOptions.FindPattern : SearchOptions.FindPattern.ToUpper();
return true;

10
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/ISearchStrategy.cs

@ -6,24 +6,26 @@ @@ -6,24 +6,26 @@
// </file>
using System;
using ICSharpCode.SharpDevelop.Gui;
namespace SearchAndReplace
{
/// <summary>
/// This interface is the basic interface which all
/// This interface is the basic interface which all
/// search algorithms must implement.
/// </summary>
public interface ISearchStrategy
{
/// <remarks>
/// Only with a call to this method the search strategy must
/// update their pattern information. This method will be called
/// update their pattern information. This method will be called
/// before the FindNext function.
/// The method might show a message box to the user if the pattern is invalid.
/// </remarks>
bool CompilePattern();
bool CompilePattern(IProgressMonitor monitor);
/// <remarks>
/// The find next method should search the next occurrence of the
/// The find next method should search the next occurrence of the
/// compiled pattern in the text using the textIterator and options.
/// </remarks>
SearchResult FindNext(ITextIterator textIterator);

5
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/RegExSearchStrategy.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Text.RegularExpressions;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace SearchAndReplace
{
@ -15,7 +16,7 @@ namespace SearchAndReplace @@ -15,7 +16,7 @@ namespace SearchAndReplace
{
Regex regex = null;
public bool CompilePattern()
public bool CompilePattern(IProgressMonitor monitor)
{
RegexOptions regexOptions = RegexOptions.Compiled;
if (!SearchOptions.MatchCase) {
@ -25,7 +26,9 @@ namespace SearchAndReplace @@ -25,7 +26,9 @@ namespace SearchAndReplace
regex = new Regex(SearchOptions.FindPattern, regexOptions);
return true;
} catch (ArgumentException ex) {
if (monitor != null) monitor.ShowingDialog = true;
MessageService.ShowError("${res:Dialog.NewProject.SearchReplace.ErrorParsingRegex}\n" + ex.Message);
if (monitor != null) monitor.ShowingDialog = false;
return false;
}
}

2
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/WildcardSearchStrategy.cs

@ -164,7 +164,7 @@ namespace SearchAndReplace @@ -164,7 +164,7 @@ namespace SearchAndReplace
return -1;
}
public bool CompilePattern()
public bool CompilePattern(ICSharpCode.SharpDevelop.Gui.IProgressMonitor monitor)
{
CompilePattern(SearchOptions.FindPattern, !SearchOptions.MatchCase);
return true;

Loading…
Cancel
Save