diff --git a/src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs b/src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs index ea33b9d93b..3c1bf3c84b 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs @@ -138,17 +138,18 @@ namespace ICSharpCode.SharpDevelop.Dom { if (getMembersBusy) return new List(); getMembersBusy = true; - List l; + List l = new List(); + l.AddRange(c.Fields); if (c.ClassType == ClassType.Interface) { - l = new List(); foreach (IReturnType baseType in c.BaseTypes) { l.AddRange(baseType.GetFields()); } } else { IReturnType baseType = c.BaseType; - l = baseType != null ? c.BaseType.GetFields() : new List(); + if (baseType != null) { + l.AddRange(baseType.GetFields()); + } } - l.AddRange(c.Fields); getMembersBusy = false; return l; } @@ -157,17 +158,18 @@ namespace ICSharpCode.SharpDevelop.Dom { if (getMembersBusy) return new List(); getMembersBusy = true; - List l; + List l = new List(); + l.AddRange(c.Events); if (c.ClassType == ClassType.Interface) { - l = new List(); foreach (IReturnType baseType in c.BaseTypes) { l.AddRange(baseType.GetEvents()); } } else { IReturnType baseType = c.BaseType; - l = baseType != null ? c.BaseType.GetEvents() : new List(); + if (baseType != null) { + l.AddRange(baseType.GetEvents()); + } } - l.AddRange(c.Events); getMembersBusy = false; return l; } diff --git a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/DocumentIterator/IDocumentIterator.cs b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/DocumentIterator/IDocumentIterator.cs index 8f68c49684..28fb726dee 100644 --- a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/DocumentIterator/IDocumentIterator.cs +++ b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/DocumentIterator/IDocumentIterator.cs @@ -26,7 +26,7 @@ namespace SearchAndReplace /// backward is called but they're not mixed. After a reset the move operation /// can be switched. /// - public interface IDocumentIterator + public interface IDocumentIterator { /// /// Returns the current ProvidedDocumentInformation. This method @@ -60,4 +60,36 @@ namespace SearchAndReplace /// void Reset(); } + + /// + /// A document iterator which never returns any results. + /// + public sealed class DummyDocumentIterator : IDocumentIterator + { + public ProvidedDocumentInformation Current { + get { + return null; + } + } + + public string CurrentFileName { + get { + return null; + } + } + + public bool MoveForward() + { + return false; + } + + public bool MoveBackward() + { + return false; + } + + public void Reset() + { + } + } } diff --git a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceUtilities.cs b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceUtilities.cs index 9225144ce2..3404dc5116 100644 --- a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceUtilities.cs +++ b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceUtilities.cs @@ -22,7 +22,7 @@ namespace SearchAndReplace public static bool IsTextAreaSelected { get { return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null && - WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is ITextEditorControlProvider; + WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is ITextEditorControlProvider; } } @@ -38,15 +38,7 @@ namespace SearchAndReplace public static bool IsWholeWordAt(ITextBufferStrategy document, int offset, int length) { return (offset - 1 < 0 || Char.IsWhiteSpace(document.GetCharAt(offset - 1))) && - (offset + length + 1 >= document.Length || Char.IsWhiteSpace(document.GetCharAt(offset + length))); - } - - public static int CalcCurrentOffset(IDocument document) - { -// TODO: -// int endOffset = document.Caret.Offset % document.TextLength; -// return endOffset; - return 0; + (offset + length + 1 >= document.Length || Char.IsWhiteSpace(document.GetCharAt(offset + length))); } public static ISearchStrategy CreateSearchStrategy(SearchStrategyType type) @@ -70,8 +62,17 @@ namespace SearchAndReplace case DocumentIteratorType.CurrentSelection: return new CurrentDocumentIterator(); case DocumentIteratorType.Directory: - return new DirectoryDocumentIterator(SearchOptions.LookIn, - SearchOptions.LookInFiletypes, + try { + if (!Directory.Exists(SearchOptions.LookIn)) { + MessageService.ShowMessageFormatted("${res:Dialog.NewProject.SearchReplace.SearchStringNotFound.Title}", "${res:Dialog.NewProject.SearchReplace.LookIn.DirectoryNotFound}", Path.GetFullPath(SearchOptions.LookIn)); + return new DummyDocumentIterator(); + } + } catch (Exception ex) { + MessageService.ShowMessage(ex.Message); + return new DummyDocumentIterator(); + } + return new DirectoryDocumentIterator(SearchOptions.LookIn, + SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories); case DocumentIteratorType.AllOpenFiles: return new AllOpenDocumentIterator(); @@ -88,7 +89,7 @@ namespace SearchAndReplace public static bool IsSearchable(string fileName) { - if (fileName == null) + if (fileName == null) return false; if (excludedFileExtensions == null) {